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: Removed unused comment. Created Feb. 13, 2018, 2:46 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());
30 30
31 auto key = u"Foobar"_str; 31 auto key = u"Foobar"_str;
32 EXPECT_EQ(key.length(), 6); 32 EXPECT_EQ(key.length(), 6);
33 EXPECT_EQ(map.size(), 0); 33 EXPECT_EQ(map.size(), 0);
34 34
35 map[u"Foobar"_str] = "one"; 35 map[u"Foobar"_str] = "one";
36 EXPECT_EQ(map.size(), 1); 36 EXPECT_EQ(map.size(), 1);
37 EXPECT_NE(map.begin(), map.end()); 37 EXPECT_NE(map.begin(), map.end());
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 rr map[u"Foobar2"_str] = "two"; 48 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 EXPECT_TRUE(map.erase(u"Foobar2"_str)); 58 EXPECT_TRUE(map.erase(u"Foobar2"_str));
(...skipping 24 matching lines...) Expand all
83 83
84 TEST(TestStringMap, stringMap) 84 TEST(TestStringMap, stringMap)
85 { 85 {
86 testStringMap<StringMap>(); 86 testStringMap<StringMap>();
87 } 87 }
88 88
89 TEST(TestStringMap, ownedStringMap) 89 TEST(TestStringMap, ownedStringMap)
90 { 90 {
91 testStringMap<OwnedStringMap>(); 91 testStringMap<OwnedStringMap>();
92 } 92 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld