Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/compiled/StringMap.cpp

Issue 29695640: Issue 6281 - Don't return deleted entries (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Removed unused comment. Created Feb. 13, 2018, 2:46 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/Map.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 27 matching lines...) Expand all
38 38
39 map[u""_str] = "null"; 39 map[u""_str] = "null";
40 EXPECT_EQ(map.size(), 2); 40 EXPECT_EQ(map.size(), 2);
41 41
42 auto entry = map.find(u"Foobar"_str); 42 auto entry = map.find(u"Foobar"_str);
43 EXPECT_TRUE(entry); 43 EXPECT_TRUE(entry);
44 44
45 entry = map.find(u"Foobar2"_str); 45 entry = map.find(u"Foobar2"_str);
46 EXPECT_FALSE(entry); 46 EXPECT_FALSE(entry);
47 47
48 map[u"Foobar2"_str] = "two"; 48 rr map[u"Foobar2"_str] = "two";
sergei 2018/02/13 15:01:39 could you please also remove it? :)
hub 2018/02/13 15:08:44 *sigh*. how did that slide in. Done
49 entry = map.find(u"Foobar2"_str); 49 entry = map.find(u"Foobar2"_str);
50 EXPECT_TRUE(entry); 50 EXPECT_TRUE(entry);
51 51
52 map[u"Foobar3"_str] = "three"; 52 map[u"Foobar3"_str] = "three";
53 entry = map.find(u"Foobar3"_str); 53 entry = map.find(u"Foobar3"_str);
54 EXPECT_TRUE(entry); 54 EXPECT_TRUE(entry);
55 55
56 EXPECT_EQ(map.size(), 4); 56 EXPECT_EQ(map.size(), 4);
57 57
58 map.erase(u"Foobar2"_str); 58 EXPECT_TRUE(map.erase(u"Foobar2"_str));
59 // already deleted. Returns false.
60 EXPECT_FALSE(map.erase(u"Foobar2"_str));
61 // invalid. Returns false.
62 EXPECT_FALSE(map.erase(u"Foobar42"_str));
59 63
60 // DISABLED. This should be true, but it isn't 64 EXPECT_EQ(map.size(), 4);
61 //EXPECT_EQ(map.size(), 3);
62 65
63 entry = map.find(u"Foobar2"_str); 66 entry = map.find(u"Foobar2"_str);
64 EXPECT_FALSE(entry); 67 EXPECT_FALSE(entry);
65 68
66 int i = 0; 69 int i = 0;
67 for (const auto& e : map) 70 for (const auto& e : map)
68 { 71 {
69 EXPECT_FALSE(e.is_invalid()); 72 EXPECT_FALSE(e.is_invalid());
70 // DISABLED entries that are deleted shouldn't be returned. 73 // entries that are deleted shouldn't be returned.
71 // See issue #6281 74 EXPECT_FALSE(e.is_deleted());
72 //EXPECT_FALSE(e.is_deleted());
73 i++; 75 i++;
74 } 76 }
75 77
76 EXPECT_EQ(i, 4); // SHOULD be 3. See issue #6281 78 EXPECT_EQ(i, 3);
77 EXPECT_EQ(i, map.size()); 79 // We did not return deleted entries (there is one).
80 // So size is different than actual count.
81 EXPECT_NE(i, map.size());
78 } 82 }
79 83
80 TEST(TestStringMap, stringMap) 84 TEST(TestStringMap, stringMap)
81 { 85 {
82 testStringMap<StringMap>(); 86 testStringMap<StringMap>();
83 } 87 }
84 88
85 TEST(TestStringMap, ownedStringMap) 89 TEST(TestStringMap, ownedStringMap)
86 { 90 {
87 testStringMap<OwnedStringMap>(); 91 testStringMap<OwnedStringMap>();
88 } 92 }
OLDNEW
« no previous file with comments | « compiled/Map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld