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

Unified Diff: test/plugin/UtilTest.cpp

Issue 5733210436665344: Issue #1234 - Remove local CString variable from TraverseDocument() (Closed)
Patch Set: Created Oct. 9, 2015, 3:48 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/plugin/PluginUtil.h ('K') | « src/plugin/PluginUtil.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/plugin/UtilTest.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/plugin/UtilTest.cpp
@@ -0,0 +1,73 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <gtest/gtest.h>
+#include "../../src/plugin/PluginUtil.h"
+
+namespace
+{
+ template<class CharT, size_t M, size_t N>
+ bool BeginsWithForTesting(const CharT(&s)[M], const CharT(&beginning)[N])
+ {
+ return BeginsWith(std::basic_string<CharT>(s), beginning);
+ }
+}
+
+TEST(BeginsWith, EmptyIsEmpty)
+{
+ ASSERT_TRUE(BeginsWithForTesting(L"", L""));
+}
+
+TEST(BeginsWith, EmptyAlwaysBegins)
+{
+ ASSERT_TRUE(BeginsWithForTesting(L"foo", L""));
+}
+
+TEST(BeginsWith, EmptyNeverHasABeginning)
+{
+ ASSERT_FALSE(BeginsWithForTesting(L"", L"foo"));
+}
+
+TEST(BeginsWith, PartGood)
+{
+ ASSERT_TRUE(BeginsWithForTesting(L"foo", L"f"));
+ ASSERT_TRUE(BeginsWithForTesting(L"foo", L"fo"));
+}
+
+TEST(BeginsWith, AllGood)
+{
+ ASSERT_TRUE(BeginsWithForTesting(L"foo", L"foo"));
+}
+
+TEST(BeginsWith, PartBad)
+{
+ ASSERT_FALSE(BeginsWithForTesting(L"foo", L"b"));
+}
+
+TEST(BeginsWith, AllBad)
+{
+ ASSERT_FALSE(BeginsWithForTesting(L"foo", L"bar"));
+}
+
+TEST(BeginsWith, ExtraBad)
+{
+ ASSERT_FALSE(BeginsWithForTesting(L"foo", L"foobar"));
+}
+
+TEST(BeginsWith, LongerBad)
+{
+ ASSERT_FALSE(BeginsWithForTesting(L"foo", L"barfoo"));
+}
« 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