summaryrefslogtreecommitdiff
path: root/test/WhiteBoxTests.cpp
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-10-21 16:57:23 -0400
committerJan Holesovsky <kendy@collabora.com>2018-12-07 12:39:27 +0100
commit33aff0ce61329e53ac244f9ff3bdf4e154f87694 (patch)
treeae083758698c9868e0d375a8cbb2415d963a64f0 /test/WhiteBoxTests.cpp
parentfeb36a4a05ada6c61d946f16741876c5101ba5bc (diff)
wsd: utility to parse integer lists
A quite common logic that is best moved to a utility and optimized for best performance. Includes unit-tests. Change-Id: Id63a388690c17355eb2fac529070c38e9b082fd0
Diffstat (limited to 'test/WhiteBoxTests.cpp')
-rw-r--r--test/WhiteBoxTests.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index 482a76e18..79e81f07e 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -374,6 +374,26 @@ void WhiteBoxTests::testTokenizer()
CPPUNIT_ASSERT_EQUAL(std::string("ABC"), tokens[0]);
CPPUNIT_ASSERT_EQUAL(std::string("DEF"), tokens[1]);
CPPUNIT_ASSERT_EQUAL(std::string("XYZ"), tokens[2]);
+
+ // Integer lists.
+ std::vector<int> ints;
+
+ ints = LOOLProtocol::tokenizeInts(std::string("-1"));
+ CPPUNIT_ASSERT_EQUAL(1UL, ints.size());
+ CPPUNIT_ASSERT_EQUAL(-1, ints[0]);
+
+ ints = LOOLProtocol::tokenizeInts(std::string("1,2,3,4"));
+ CPPUNIT_ASSERT_EQUAL(4UL, ints.size());
+ CPPUNIT_ASSERT_EQUAL(1, ints[0]);
+ CPPUNIT_ASSERT_EQUAL(2, ints[1]);
+ CPPUNIT_ASSERT_EQUAL(3, ints[2]);
+ CPPUNIT_ASSERT_EQUAL(4, ints[3]);
+
+ ints = LOOLProtocol::tokenizeInts("");
+ CPPUNIT_ASSERT_EQUAL(0UL, ints.size());
+
+ ints = LOOLProtocol::tokenizeInts(std::string(",,,"));
+ CPPUNIT_ASSERT_EQUAL(0UL, ints.size());
}
void WhiteBoxTests::testReplace()