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

Delta Between Two Patch Sets: test/compiled/StringMap.cpp

Issue 29695640: Issue 6281 - Don't return deleted entries (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Feb. 12, 2018, 11:52 p.m.
Right Patch Set: Remove mistakenly added characters. Created Feb. 13, 2018, 3:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/Map.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <string> 18 #include <string>
19 #include "gtest/gtest.h" 19 #include <gtest/gtest.h>
20 #include "compiled/StringMap.h" 20 #include "compiled/StringMap.h"
21 21
22 ABP_NS_USING 22 ABP_NS_USING
23 23
24 template<template <typename T> class S> 24 template<template <typename T> class S>
25 void testStringMap() 25 void testStringMap()
26 { 26 {
27 S<std::string> map; 27 S<std::string> map;
28 28
29 EXPECT_EQ(map.begin(), map.end()); 29 EXPECT_EQ(map.begin(), map.end());
(...skipping 24 matching lines...) Expand all
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 EXPECT_TRUE(map.erase(u"Foobar2"_str)); 58 EXPECT_TRUE(map.erase(u"Foobar2"_str));
59 // already deleted. Returns false. 59 // already deleted. Returns false.
60 EXPECT_FALSE(map.erase(u"Foobar2"_str)); 60 EXPECT_FALSE(map.erase(u"Foobar2"_str));
61 // invalid. Returns false. 61 // invalid. Returns false.
62 EXPECT_FALSE(map.erase(u"Foobar42"_str)); 62 EXPECT_FALSE(map.erase(u"Foobar42"_str));
63 63
64 // XXX should be 4.
sergei 2018/02/13 09:06:39 it seems this comment is not finished.
hub 2018/02/13 14:46:29 Removed now.
65 EXPECT_EQ(map.size(), 4); 64 EXPECT_EQ(map.size(), 4);
66 65
67 entry = map.find(u"Foobar2"_str); 66 entry = map.find(u"Foobar2"_str);
68 EXPECT_FALSE(entry); 67 EXPECT_FALSE(entry);
69 68
70 int i = 0; 69 int i = 0;
71 for (const auto& e : map) 70 for (const auto& e : map)
72 { 71 {
73 EXPECT_FALSE(e.is_invalid()); 72 EXPECT_FALSE(e.is_invalid());
74 // entries that are deleted shouldn't be returned. 73 // entries that are deleted shouldn't be returned.
75 EXPECT_FALSE(e.is_deleted()); 74 EXPECT_FALSE(e.is_deleted());
76 i++; 75 i++;
77 } 76 }
78 77
79 EXPECT_EQ(i, 3); 78 EXPECT_EQ(i, 3);
80 // We did not return deleted entries (there is one). 79 // We did not return deleted entries (there is one).
81 // So size is different than actual count. 80 // So size is different than actual count.
82 EXPECT_NE(i, map.size()); 81 EXPECT_NE(i, map.size());
83 } 82 }
84 83
85 TEST(TestStringMap, stringMap) 84 TEST(TestStringMap, stringMap)
86 { 85 {
87 testStringMap<StringMap>(); 86 testStringMap<StringMap>();
88 } 87 }
89 88
90 TEST(TestStringMap, ownedStringMap) 89 TEST(TestStringMap, ownedStringMap)
91 { 90 {
92 testStringMap<OwnedStringMap>(); 91 testStringMap<OwnedStringMap>();
93 } 92 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld