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

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

Issue 29680720: Issue 6221 - Add native tests. (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Review comments addressed Created Jan. 29, 2018, 4:56 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
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 #include <string>
19 #include "gtest/gtest.h"
20 #include "compiled/StringMap.h"
21
22 template<template <typename T> class S>
23 void testStringMap()
24 {
25 S<std::string> map;
26 auto key = u"Foobar"_str;
27 EXPECT_EQ(key.length(), 6);
28 EXPECT_EQ(map.size(), 0);
29
30 map[u"Foobar"_str] = "one";
31 EXPECT_EQ(map.size(), 1);
32
33 map[u""_str] = "null";
34 EXPECT_EQ(map.size(), 2);
35
36 auto entry = map.find(u"Foobar"_str);
37 EXPECT_TRUE(entry);
38
39 entry = map.find(u"Foobar2"_str);
40 EXPECT_FALSE(entry);
41
42 map[u"Foobar2"_str] = "two";
43 entry = map.find(u"Foobar2"_str);
44 EXPECT_TRUE(entry);
45
46 map[u"Foobar3"_str] = "three";
47 entry = map.find(u"Foobar3"_str);
48 EXPECT_TRUE(entry);
49
50 EXPECT_EQ(map.size(), 4);
51
52 map.erase(u"Foobar2"_str);
53
54 // DISABLED. This should be true, but it isn't
55 //EXPECT_EQ(map.size(), 3);
56
57 entry = map.find(u"Foobar2"_str);
58 EXPECT_FALSE(entry);
59
60 int i = 0;
61 for (const auto& e : map)
62 {
63 EXPECT_FALSE(e.is_invalid());
64 // DISABLED entries that are deleted shouldn't be returned.
65 // See issue #6281
66 //EXPECT_FALSE(e.is_deleted());
67 i++;
68 }
69
70 EXPECT_EQ(i, 4); // SHOULD be 3. See issue #6281
71 EXPECT_EQ(i, map.size());
72 }
73
74 TEST(TestStringMap, stringMap)
75 {
76 testStringMap<StringMap>();
77 }
78
79 TEST(TestStringMap, ownedStringMap)
80 {
81 testStringMap<OwnedStringMap>();
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld