コード例 #1
0
ファイル: IndexerTest.cpp プロジェクト: valbok/twitcher.exmpl
TEST(IndexerTest, testGetUserPostIds) {
    Indexer i;
    const string username = "******";
    const uint64_t postId1 = 666;
    const uint64_t postId2 = 777;
    {
        const TTopics topics = {"please", "give", "me", "job"};
        EXPECT_TRUE(i.index(topics, username, postId1));

        EXPECT_FALSE(i.hasTopicItem("unknown"));
        EXPECT_TRUE(i.hasTopicItem("job"));
        auto item = i.getTopicItem("job");
        EXPECT_EQ(1, item.postsCount);
        auto postIds = item.userPostIds;
        EXPECT_EQ(1, postIds.size());
        auto it = postIds.begin();
        EXPECT_EQ(username, it->first);
        EXPECT_EQ(1, it->second.size());
        auto sit = it->second.begin();
        EXPECT_EQ(postId1, *sit);
    }
    {
        const TTopics topics = {"waiting", "for", "job"};
        EXPECT_TRUE(i.index(topics, username, postId2));

        EXPECT_FALSE(i.hasTopicItem("unknown"));
        EXPECT_TRUE(i.hasTopicItem("job"));
        auto item = i.getTopicItem("job");
        EXPECT_EQ(2, item.postsCount);
        auto postIds = item.userPostIds;
        EXPECT_EQ(1, postIds.size());
        auto it = postIds.begin();
        EXPECT_EQ(username, it->first);
        EXPECT_EQ(2, it->second.size());
        auto sit = it->second.begin();
        EXPECT_EQ(postId2, *sit);
        EXPECT_EQ(postId1, *(++sit));
    }
}
コード例 #2
0
ファイル: IndexerTest.cpp プロジェクト: valbok/twitcher.exmpl
TEST(IndexerTest, testPurgeByUser) {
    Indexer i;
    const string username1 = "val";
    const uint64_t postId1 = 666;
    const string username2 = "kim";
    const uint64_t postId2 = 777;

    EXPECT_TRUE(i.index(TTopics({"href", "cv", "date"}), username1, postId1));
    EXPECT_TRUE(i.index(TTopics({"cv"}), username1, postId1 + 1));

    EXPECT_TRUE(i.hasPostTopics(postId1));
    EXPECT_TRUE(i.hasPostTopics(postId1 + 1));
    EXPECT_FALSE(i.hasPostTopics(postId2));
    EXPECT_TRUE(i.hasTopicItem("href"));
    EXPECT_TRUE(i.hasTopicItem("cv"));
    EXPECT_TRUE(i.hasTopicItem("date"));

    EXPECT_EQ(2, i.getTopicItem("cv").postsCount);

    EXPECT_TRUE(i.index(TTopics({"href", "cv"}), username2, postId2));
    EXPECT_TRUE(i.index(TTopics({"cv"}), username2, postId2 + 1));

    EXPECT_TRUE(i.hasPostTopics(postId2));
    EXPECT_TRUE(i.hasPostTopics(postId2 + 1));
    EXPECT_EQ(4, i.getTopicItem("cv").postsCount);
    EXPECT_EQ(2, i.getTopicItem("href").postsCount);

    EXPECT_TRUE(i.purgeByUser(username1));

    EXPECT_FALSE(i.hasPostTopics(postId1));
    EXPECT_FALSE(i.hasPostTopics(postId1 + 1));

    EXPECT_TRUE(i.hasPostTopics(postId2));
    EXPECT_TRUE(i.hasPostTopics(postId2 + 1));
    EXPECT_EQ(2, i.getTopicItem("cv").postsCount);
    EXPECT_EQ(1, i.getTopicItem("href").postsCount);
    EXPECT_FALSE(i.hasTopicItem("date"));

    EXPECT_TRUE(i.purgeByUser(username2));

    EXPECT_FALSE(i.hasPostTopics(postId2));
    EXPECT_FALSE(i.hasPostTopics(postId2 + 1));
    EXPECT_FALSE(i.hasTopicItem("cv"));
    EXPECT_FALSE(i.hasTopicItem("href"));
}
コード例 #3
0
ファイル: IndexerTest.cpp プロジェクト: valbok/twitcher.exmpl
TEST(IndexerTest, testPurgeByUserSingleItem) {
    Indexer i;
    const string username = "******";
    const uint64_t postId = 666;
    const TTopics topics = {"check", "source", "html"};
    EXPECT_TRUE(i.index(topics, username, postId));
    EXPECT_TRUE(i.hasPostTopics(postId));
    EXPECT_TRUE(i.hasTopicItem("check"));
    EXPECT_TRUE(i.hasTopicItem("source"));
    EXPECT_TRUE(i.hasTopicItem("html"));

    EXPECT_FALSE(i.purgeByUser("kim"));
    EXPECT_TRUE(i.purgeByUser(username));

    EXPECT_FALSE(i.hasPostTopics(postId));
    EXPECT_FALSE(i.hasTopicItem("check"));
    EXPECT_FALSE(i.hasTopicItem("source"));
    EXPECT_FALSE(i.hasTopicItem("html"));
}