diff --git a/test/basic.cpp b/test/basic.cpp index bf0bf39..fb6b0c5 100644 --- a/test/basic.cpp +++ b/test/basic.cpp @@ -113,10 +113,9 @@ TEST_F(BaseTest, AddingKeysToCache) { EXPECT_EQ(db->ready(), true); c1->addRecord(2, "blah balah"); c1->addRecord(-4, "testing goes brrr"); - c1->addRecord(140, "whatever"); + c1->addRecord(40, "whatever"); c1->addRecord(-37, "aaaaa tss tsss tsss tsss aaaaaaa"); - EXPECT_EQ(c1->getRecord(140), "whatever"); - EXPECT_EQ(c1->getRecord(-116), "whatever"); + EXPECT_EQ(c1->getRecord(40), "whatever"); } TEST_F(BaseTest, AddingKeysToVariableCache) { @@ -189,8 +188,8 @@ TEST_F(BaseTest, Persistence) { EXPECT_EQ(t2->count(), t2Size); EXPECT_EQ(c1->count(), c1Size); - EXPECT_EQ(c1->checkRecord(-116), true); - EXPECT_EQ(c1->getRecord(-116), "whatever"); + EXPECT_EQ(c1->checkRecord(40), true); + EXPECT_EQ(c1->getRecord(40), "whatever"); EXPECT_EQ(c1->checkRecord(-4), true); EXPECT_EQ(c1->getRecord(-4), "testing goes brrr"); EXPECT_EQ(c1->getRecord(-4), "testing goes brrr"); diff --git a/test/duplicates.cpp b/test/duplicates.cpp index 4fbe12a..0bc6b56 100644 --- a/test/duplicates.cpp +++ b/test/duplicates.cpp @@ -130,7 +130,10 @@ TEST_F(DuplicatesTest, Adding) { tu3->addRecord(7.20001, 4.00000001); //not sure how exactly, but it works EXPECT_EQ(tu3->count(), 7); - EXPECT_EQ(tu3->getRecord(7.2), -113); + + std::set res72({-113, -53.5478, 697, 4, 4.00000001}); + EXPECT_EQ(res72.count(tu3->getRecord(7.2)), 1); + float tu3dd = tu3->getRecord(5119); EXPECT_TRUE(tu3ds == tu3dd); EXPECT_EQ(tu3ds, tu3dd); @@ -144,8 +147,11 @@ TEST_F(DuplicatesTest, Adding) { EXPECT_THROW(tu4->addRecord(327, 79.624923), LMDBAL::Exist); EXPECT_EQ(tu4->count(), 4); - EXPECT_EQ(tu4->getRecord(172), 0.00000001); - EXPECT_EQ(tu4->getRecord(327), 463.28348); //since they are not int's they are compared sort of lexicographically + + std::set res327({463.28348, 79.624923}); + std::set res172({0.00001, 0.00000001}); + EXPECT_EQ(res172.count(tu4->getRecord(172)), 1); + EXPECT_EQ(res327.count(tu4->getRecord(327)), 1); tu5->addRecord(-84.7, 45656753); EXPECT_THROW(tu5->addRecord(-84.7, 45656753), LMDBAL::Exist); @@ -174,13 +180,19 @@ TEST_F(DuplicatesTest, Forcing) { tu1->addRecord(-56, 71); tu1->addRecord(-56, 274); tu1->addRecord(-56, 732); + + std::set res56({71, 274, 732}); EXPECT_EQ(tu1->count(), tu1Size += 3); EXPECT_TRUE(tu1->forceRecord(-56, 322)); + res56.insert(322); EXPECT_EQ(tu1->count(), tu1Size += 1); - EXPECT_EQ(tu1->getRecord(-56), 274); //like yeah, it's really counterintuitive, since it's compared byte by byte + EXPECT_EQ(res56.count(tu1->getRecord(-56)), 1); + + res56.insert(14); EXPECT_TRUE(tu1->forceRecord(-56, 14)); EXPECT_EQ(tu1->count(), tu1Size += 1); - EXPECT_EQ(tu1->getRecord(-56), 14); + EXPECT_EQ(res56.count(tu1->getRecord(-56)), 1); + EXPECT_FALSE(tu1->forceRecord(-56, 274)); EXPECT_EQ(tu1->count(), tu1Size); @@ -201,26 +213,38 @@ TEST_F(DuplicatesTest, Forcing) { tu3->addRecord(17.3, 93.21); tu3->addRecord(17.3, 6.6); tu3->addRecord(17.3, 105.1); + std::set res17({93.21, 6.6, 105.1}); + EXPECT_EQ(tu3->count(), tu3Size += 3); EXPECT_TRUE(tu3->forceRecord(17.3, 74.9)); + res17.insert(74.9); EXPECT_EQ(tu3->count(), tu3Size += 1); - EXPECT_EQ(tu3->getRecord(17.3), 105.1f); //here too, really one should not use this function with duplicates, - EXPECT_TRUE(tu3->forceRecord(17.3, 5.1)); //unless he wishes for kinda randomish result + EXPECT_EQ(res17.count(tu3->getRecord(17.3)), 1); + + EXPECT_TRUE(tu3->forceRecord(17.3, 5.1)); + res17.insert(5.1); EXPECT_EQ(tu3->count(), tu3Size += 1); - EXPECT_EQ(tu3->getRecord(17.3), 5.1f); + EXPECT_EQ(res17.count(tu3->getRecord(17.3)), 1); + EXPECT_FALSE(tu3->forceRecord(17.3, 93.21)); EXPECT_EQ(tu3->count(), tu3Size); LMDBAL::SizeType tu4Size = tu4->count(); tu4->addRecord(84, -359.109); tu4->addRecord(84, 2879.654); + std::set res84({-359.109, 2879.654}); + EXPECT_EQ(tu4->count(), tu4Size += 2); EXPECT_TRUE(tu4->forceRecord(84, 72.9)); + res84.insert(72.9); EXPECT_EQ(tu4->count(), tu4Size += 1); - EXPECT_EQ(tu4->getRecord(84), 2879.654); + EXPECT_EQ(res84.count(tu4->getRecord(84)), 1); + EXPECT_TRUE(tu4->forceRecord(84, 2679.5)); + res84.insert(2679.5); EXPECT_EQ(tu4->count(), tu4Size += 1); - EXPECT_EQ(tu4->getRecord(84), 2679.5); + EXPECT_EQ(res84.count(tu4->getRecord(84)), 1); + EXPECT_FALSE(tu4->forceRecord(84, -359.109)); EXPECT_EQ(tu4->count(), tu4Size); @@ -286,6 +310,7 @@ TEST_F(DuplicatesTest, Changing) { EXPECT_THROW(tu2->changeRecord("jeremy spins", -7), LMDBAL::Exist); LMDBAL::SizeType tu3Size = tu3->count(); + std::set res26; EXPECT_THROW(tu3->changeRecord(26.7, 68.22), LMDBAL::NotFound); EXPECT_EQ(tu3->count(), tu3Size); tu3->addRecord(26.7, 68.22); @@ -294,11 +319,13 @@ TEST_F(DuplicatesTest, Changing) { tu3->changeRecord(26.7, 68.22); //should just do nothing usefull, but work normally EXPECT_EQ(tu3->getRecord(26.7), 68.22f); tu3->changeRecord(26.7, 23.18); + res26.insert(23.18); EXPECT_EQ(tu3->count(), tu3Size); EXPECT_EQ(tu3->getRecord(26.7), 23.18f); tu3->addRecord(26.7, 22.16); + res26.insert(22.16); EXPECT_EQ(tu3->count(), tu3Size += 1); - EXPECT_EQ(tu3->getRecord(26.7), 23.18f); + EXPECT_EQ(res26.count(tu3->getRecord(26.7)), 1); tu3->changeRecord(26.7, 21.7); EXPECT_EQ(tu3->count(), tu3Size); EXPECT_EQ(tu3->getRecord(26.7), 21.7f); @@ -316,17 +343,21 @@ TEST_F(DuplicatesTest, Changing) { tu4->changeRecord(852, 6795.349); //should just do nothing usefull, but work normally EXPECT_EQ(tu4->getRecord(852), 6795.349); tu4->changeRecord(852, 13.54); + std::set res852({13.54}); EXPECT_EQ(tu4->count(), tu4Size); EXPECT_EQ(tu4->getRecord(852), 13.54); tu4->addRecord(852, 213.85); + res852.insert(213.85); EXPECT_EQ(tu4->count(), tu4Size += 1); - EXPECT_EQ(tu4->getRecord(852), 13.54); + EXPECT_EQ(res852.count(tu4->getRecord(852)), 1); tu4->changeRecord(852, 236.21); + res852.insert(236.21); EXPECT_EQ(tu4->count(), tu4Size); EXPECT_EQ(tu4->getRecord(852), 236.21); tu4->changeRecord(852, 46324.1135); + res852.insert(46324.1135); EXPECT_EQ(tu4->count(), tu4Size); - EXPECT_EQ(tu4->getRecord(852), 213.85); + EXPECT_EQ(res852.count(tu4->getRecord(852)), 1); EXPECT_THROW(tu4->changeRecord(852, 46324.1135), LMDBAL::Exist); }