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. 5, 2015, 4:24 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,106 @@
+/*
+ * 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"
+
+//----------------------------------
+// Trim
+//----------------------------------
+namespace
+{
+ void TrimTest(std::wstring input, std::wstring expected)
+ {
+ std::wstring trimmed = TrimString(input);
+ ASSERT_EQ(expected, trimmed);
+ }
+}
+
+TEST(Trim, trim_00)
sergei 2015/01/05 16:51:03 We also usually add "Test" to the test case, thus
Eric 2015/01/05 17:18:25 We have, and it's entirely redundant to do so. It'
sergei 2015/01/05 21:13:53 Consistency
Oleksandr 2015/01/09 00:16:59 I agree with Sergei. Also, TEST(TrimTest, Trim00)
+{
+ TrimTest(L"", L"");
+}
+
+TEST(Trim, trim_01)
+{
+ TrimTest(L" ", L"");
+}
+
+TEST(Trim, trim_02)
+{
+ TrimTest(L"\n", L"");
+}
+
+TEST(Trim, trim_03)
+{
+ TrimTest(L"\r", L"");
+}
+
+TEST(Trim, trim_04)
+{
+ TrimTest(L"\t", L"");
+}
+
+TEST(Trim, trim_05)
+{
+ TrimTest(L"foo", L"foo");
+}
+
+TEST(Trim, trim_06)
+{
+ TrimTest(L" foo", L"foo");
+}
+
+TEST(Trim, trim_07)
+{
+ TrimTest(L"\r\nfoo", L"foo");
+}
+
+TEST(Trim, trim_08)
+{
+ TrimTest(L"\tfoo", L"foo");
+}
+
+TEST(Trim, trim_09)
+{
+ TrimTest(L"foo ", L"foo");
+}
+
+TEST(Trim, trim_10)
+{
+ TrimTest(L"foo\r\n", L"foo");
+}
+
+TEST(Trim, trim_11)
+{
+ TrimTest(L"foo\t", L"foo");
+}
+
+TEST(Trim, trim_12)
+{
+ TrimTest(L"foo bar", L"foo bar");
+}
+
+TEST(Trim, trim_13)
+{
+ TrimTest(L"foo bar \r\n", L"foo bar");
+}
+
+TEST(Trim, trim_14)
+{
+ TrimTest(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