-
-
Notifications
You must be signed in to change notification settings - Fork 458
/
ChatterSet.cpp
84 lines (63 loc) · 2.31 KB
/
ChatterSet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "common/ChatterSet.hpp"
#include <gtest/gtest.h>
#include <QStringList>
TEST(ChatterSet, insert)
{
chatterino::ChatterSet set;
EXPECT_FALSE(set.contains("pajlada"));
EXPECT_FALSE(set.contains("Pajlada"));
set.addRecentChatter("pajlada");
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
set.addRecentChatter("pajlada");
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
set.addRecentChatter("PAJLADA");
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
}
TEST(ChatterSet, MaxSize)
{
chatterino::ChatterSet set;
EXPECT_FALSE(set.contains("pajlada"));
EXPECT_FALSE(set.contains("Pajlada"));
set.addRecentChatter("pajlada");
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
// After adding CHATTER_LIMIT-1 additional chatters, pajlada should still be in the set
for (auto i = 0; i < chatterino::ChatterSet::chatterLimit - 1; ++i)
{
set.addRecentChatter(QString("%1").arg(i));
}
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
// But adding one more chatter should bump pajlada out of the set
set.addRecentChatter("notpajlada");
EXPECT_FALSE(set.contains("pajlada"));
EXPECT_FALSE(set.contains("Pajlada"));
}
TEST(ChatterSet, MaxSizeLastUsed)
{
chatterino::ChatterSet set;
EXPECT_FALSE(set.contains("pajlada"));
EXPECT_FALSE(set.contains("Pajlada"));
set.addRecentChatter("pajlada");
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
// After adding CHATTER_LIMIT-1 additional chatters, pajlada should still be in the set
for (auto i = 0; i < chatterino::ChatterSet::chatterLimit - 1; ++i)
{
set.addRecentChatter(QString("%1").arg(i));
}
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
// Bump pajlada as a recent chatter
set.addRecentChatter("pajlada");
// After another CHATTER_LIMIT-1 additional chatters, pajlada should still be there
for (auto i = 0; i < chatterino::ChatterSet::chatterLimit - 1; ++i)
{
set.addRecentChatter(QString("new-%1").arg(i));
}
EXPECT_TRUE(set.contains("pajlada"));
EXPECT_TRUE(set.contains("Pajlada"));
}