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

Unified Diff: test/UtilTest.cpp

Issue 4628980216889344: Issue #1234 - Add unit tests for TrimString (Closed)
Patch Set: Created Jan. 14, 2015, 1:46 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
« no previous file with comments | « adblockplus.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/UtilTest.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/UtilTest.cpp
@@ -0,0 +1,102 @@
+/*
+ * This file is part of Adblock Plus <http://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/shared/Utils.h"
+
+namespace
+{
+ void TrimTestBody(std::wstring input, std::wstring expected)
+ {
+ std::wstring trimmed = TrimString(input);
+ ASSERT_EQ(expected, trimmed);
+ }
+}
+
+TEST(TrimTest, Trim00)
+{
+ TrimTestBody(L"", L"");
+}
+
+TEST(TrimTest, Trim01)
+{
+ TrimTestBody(L" ", L"");
+}
+
+TEST(TrimTest, Trim02)
+{
+ TrimTestBody(L"\n", L"");
+}
+
+TEST(TrimTest, Trim03)
+{
+ TrimTestBody(L"\r", L"");
+}
+
+TEST(TrimTest, Trim04)
+{
+ TrimTestBody(L"\t", L"");
+}
+
+TEST(TrimTest, Trim05)
+{
+ TrimTestBody(L"foo", L"foo");
+}
+
+TEST(TrimTest, Trim06)
+{
+ TrimTestBody(L" foo", L"foo");
+}
+
+TEST(TrimTest, Trim07)
+{
+ TrimTestBody(L"\r\nfoo", L"foo");
+}
+
+TEST(TrimTest, Trim08)
+{
+ TrimTestBody(L"\tfoo", L"foo");
+}
+
+TEST(TrimTest, Trim09)
+{
+ TrimTestBody(L"foo ", L"foo");
+}
+
+TEST(TrimTest, Trim10)
+{
+ TrimTestBody(L"foo\r\n", L"foo");
+}
+
+TEST(TrimTest, Trim11)
+{
+ TrimTestBody(L"foo\t", L"foo");
+}
+
+TEST(TrimTest, Trim12)
+{
+ TrimTestBody(L"foo bar", L"foo bar");
+}
+
+TEST(TrimTest, Trim13)
+{
+ TrimTestBody(L"foo bar \r\n", L"foo bar");
+}
+
+TEST(TrimTest, Trim14)
+{
+ TrimTestBody(L" foo bar \r\n", L"foo bar");
+}
« no previous file with comments | « adblockplus.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld