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

Side by Side Diff: test/plugin/UtilTest.cpp

Issue 5733210436665344: Issue #1234 - Remove local CString variable from TraverseDocument() (Closed)
Patch Set: Created May 20, 2015, 8:25 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
« src/plugin/PluginUtil.h ('K') | « src/plugin/PluginUtil.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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 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 #include <gtest/gtest.h>
18 #include "../../src/plugin/PluginUtil.h"
19
20 namespace
21 {
22 template<class CharT, size_t M, size_t N>
23 bool BeginsWithForTesting(const CharT(&s)[M], const CharT(&beginning)[N])
24 {
25 return BeginsWith(std::basic_string<CharT>(s), beginning);
26 }
27 }
28
29 TEST(BeginsWith, EmptyIsEmpty)
30 {
31 ASSERT_TRUE(BeginsWithForTesting(L"", L""));
32 }
33
34 TEST(BeginsWith, EmptyAlwaysBegins)
35 {
36 ASSERT_TRUE(BeginsWithForTesting(L"foo", L""));
37 }
38
39 TEST(BeginsWith, EmptyNeverHasABeginning)
40 {
41 ASSERT_FALSE(BeginsWithForTesting(L"", L"foo"));
42 }
43
44 TEST(BeginsWith, PartGood)
45 {
46 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"f"));
47 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"fo"));
48 }
49
50 TEST(BeginsWith, AllGood)
51 {
52 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"foo"));
53 }
54
55 TEST(BeginsWith, PartBad)
56 {
57 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"b"));
58 }
59
60 TEST(BeginsWith, AllBad)
61 {
62 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"bar"));
63 }
64
65 TEST(BeginsWith, ExtraBad)
66 {
67 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"foobar"));
68 }
69
70 TEST(BeginsWith, LongerBad)
71 {
72 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"barfoo"));
73 }
OLDNEW
« src/plugin/PluginUtil.h ('K') | « src/plugin/PluginUtil.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld