diff options
author | Corentin Noël <corentin.noel@collabora.com> | 2019-11-22 10:47:55 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-11-22 11:20:57 +0100 |
commit | 62ed202e2d7cd244e2c0a4189d9a2bdc838e6943 (patch) | |
tree | d5660161e45ed2f30886c54f2413bd95a840bb1b /test | |
parent | ed2c34296baa16e6d84ae01cef750a239e0bed0f (diff) |
Fix issues with size_t and ssize_t on 32bits machines
Change-Id: I3859e12e234b0fec6b94736cacc7874cd8809476
Reviewed-on: https://gerrit.libreoffice.org/83449
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/TileQueueTests.cpp | 38 | ||||
-rw-r--r-- | test/WhiteBoxTests.cpp | 58 | ||||
-rw-r--r-- | test/helpers.hpp | 2 |
3 files changed, 49 insertions, 49 deletions
diff --git a/test/TileQueueTests.cpp b/test/TileQueueTests.cpp index 209c5ffa9..1804ee8bf 100644 --- a/test/TileQueueTests.cpp +++ b/test/TileQueueTests.cpp @@ -280,7 +280,7 @@ void TileQueueTests::testSenderQueue() // Empty queue CPPUNIT_ASSERT_EQUAL(false, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); const std::vector<std::string> messages = { @@ -294,21 +294,21 @@ void TileQueueTests::testSenderQueue() queue.enqueue(std::make_shared<Message>(msg, Message::Dir::Out)); } - CPPUNIT_ASSERT_EQUAL(3UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), queue.size()); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(2UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), queue.size()); CPPUNIT_ASSERT_EQUAL(messages[0], std::string(item->data().data(), item->data().size())); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(1UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), queue.size()); CPPUNIT_ASSERT_EQUAL(messages[1], std::string(item->data().data(), item->data().size())); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); CPPUNIT_ASSERT_EQUAL(messages[2], std::string(item->data().data(), item->data().size())); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); } void TileQueueTests::testSenderQueueTileDeduplication() @@ -319,7 +319,7 @@ void TileQueueTests::testSenderQueueTileDeduplication() // Empty queue CPPUNIT_ASSERT_EQUAL(false, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); const std::vector<std::string> part_messages = { @@ -333,12 +333,12 @@ void TileQueueTests::testSenderQueueTileDeduplication() queue.enqueue(std::make_shared<Message>(msg, Message::Dir::Out)); } - CPPUNIT_ASSERT_EQUAL(3UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), queue.size()); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); const std::vector<std::string> dup_messages = { @@ -352,13 +352,13 @@ void TileQueueTests::testSenderQueueTileDeduplication() queue.enqueue(std::make_shared<Message>(msg, Message::Dir::Out)); } - CPPUNIT_ASSERT_EQUAL(1UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), queue.size()); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); // The last one should persist. CPPUNIT_ASSERT_EQUAL(dup_messages[2], std::string(item->data().data(), item->data().size())); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); } void TileQueueTests::testInvalidateViewCursorDeduplication() @@ -369,7 +369,7 @@ void TileQueueTests::testInvalidateViewCursorDeduplication() // Empty queue CPPUNIT_ASSERT_EQUAL(false, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); const std::vector<std::string> view_messages = { @@ -383,21 +383,21 @@ void TileQueueTests::testInvalidateViewCursorDeduplication() queue.enqueue(std::make_shared<Message>(msg, Message::Dir::Out)); } - CPPUNIT_ASSERT_EQUAL(3UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), queue.size()); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(2UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), queue.size()); CPPUNIT_ASSERT_EQUAL(view_messages[0], std::string(item->data().data(), item->data().size())); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(1UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), queue.size()); CPPUNIT_ASSERT_EQUAL(view_messages[1], std::string(item->data().data(), item->data().size())); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); CPPUNIT_ASSERT_EQUAL(view_messages[2], std::string(item->data().data(), item->data().size())); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); const std::vector<std::string> dup_messages = { @@ -411,13 +411,13 @@ void TileQueueTests::testInvalidateViewCursorDeduplication() queue.enqueue(std::make_shared<Message>(msg, Message::Dir::Out)); } - CPPUNIT_ASSERT_EQUAL(1UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), queue.size()); CPPUNIT_ASSERT_EQUAL(true, queue.dequeue(item)); // The last one should persist. CPPUNIT_ASSERT_EQUAL(dup_messages[2], std::string(item->data().data(), item->data().size())); - CPPUNIT_ASSERT_EQUAL(0UL, queue.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), queue.size()); } void TileQueueTests::testCallbackInvalidation() diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp index db892fdb5..fac27ece7 100644 --- a/test/WhiteBoxTests.cpp +++ b/test/WhiteBoxTests.cpp @@ -99,53 +99,53 @@ void WhiteBoxTests::testLOOLProtocolFunctions() CPPUNIT_ASSERT(LOOLProtocol::getTokenKeywordFromMessage(message, "mumble", map, mumble)); CPPUNIT_ASSERT_EQUAL(2, mumble); - CPPUNIT_ASSERT_EQUAL(1UL, Util::trimmed("A").size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trimmed("A").size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), Util::trimmed("A")); - CPPUNIT_ASSERT_EQUAL(1UL, Util::trimmed(" X").size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trimmed(" X").size()); CPPUNIT_ASSERT_EQUAL(std::string("X"), Util::trimmed(" X")); - CPPUNIT_ASSERT_EQUAL(1UL, Util::trimmed("Y ").size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trimmed("Y ").size()); CPPUNIT_ASSERT_EQUAL(std::string("Y"), Util::trimmed("Y ")); - CPPUNIT_ASSERT_EQUAL(1UL, Util::trimmed(" Z ").size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trimmed(" Z ").size()); CPPUNIT_ASSERT_EQUAL(std::string("Z"), Util::trimmed(" Z ")); - CPPUNIT_ASSERT_EQUAL(0UL, Util::trimmed(" ").size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), Util::trimmed(" ").size()); CPPUNIT_ASSERT_EQUAL(std::string(""), Util::trimmed(" ")); - CPPUNIT_ASSERT_EQUAL(0UL, Util::trimmed(" ").size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), Util::trimmed(" ").size()); CPPUNIT_ASSERT_EQUAL(std::string(""), Util::trimmed(" ")); std::string s; s = "A"; - CPPUNIT_ASSERT_EQUAL(1UL, Util::trim(s).size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trim(s).size()); s = "A"; CPPUNIT_ASSERT_EQUAL(std::string("A"), Util::trim(s)); s = " X"; - CPPUNIT_ASSERT_EQUAL(1UL, Util::trim(s).size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trim(s).size()); s = " X"; CPPUNIT_ASSERT_EQUAL(std::string("X"), Util::trim(s)); s = "Y "; - CPPUNIT_ASSERT_EQUAL(1UL, Util::trim(s).size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trim(s).size()); s = "Y "; CPPUNIT_ASSERT_EQUAL(std::string("Y"), Util::trim(s)); s = " Z "; - CPPUNIT_ASSERT_EQUAL(1UL, Util::trim(s).size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), Util::trim(s).size()); s = " Z "; CPPUNIT_ASSERT_EQUAL(std::string("Z"), Util::trim(s)); s = " "; - CPPUNIT_ASSERT_EQUAL(0UL, Util::trim(s).size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), Util::trim(s).size()); s = " "; CPPUNIT_ASSERT_EQUAL(std::string(""), Util::trim(s)); s = " "; - CPPUNIT_ASSERT_EQUAL(0UL, Util::trim(s).size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), Util::trim(s).size()); s = " "; CPPUNIT_ASSERT_EQUAL(std::string(""), Util::trim(s)); } @@ -219,7 +219,7 @@ void WhiteBoxTests::testSplitting() CPPUNIT_ASSERT_EQUAL(std::string("aa"), first); CPPUNIT_ASSERT_EQUAL(std::string(".bb"), second); - CPPUNIT_ASSERT_EQUAL(5UL, Util::getLastDelimiterPosition("aa.bb.cc", 8, '.')); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), Util::getLastDelimiterPosition("aa.bb.cc", 8, '.')); // Split last, remove delim. std::tie(first, second) = Util::splitLast(std::string("aa.bb.cc"), '.', true); @@ -312,51 +312,51 @@ void WhiteBoxTests::testTokenizer() std::vector<std::string> tokens; tokens = LOOLProtocol::tokenize(""); - CPPUNIT_ASSERT_EQUAL(0UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), tokens.size()); tokens = LOOLProtocol::tokenize(" "); - CPPUNIT_ASSERT_EQUAL(0UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), tokens.size()); tokens = LOOLProtocol::tokenize("A"); - CPPUNIT_ASSERT_EQUAL(1UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); tokens = LOOLProtocol::tokenize(" A"); - CPPUNIT_ASSERT_EQUAL(1UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); tokens = LOOLProtocol::tokenize("A "); - CPPUNIT_ASSERT_EQUAL(1UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); tokens = LOOLProtocol::tokenize(" A "); - CPPUNIT_ASSERT_EQUAL(1UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); tokens = LOOLProtocol::tokenize(" A Z "); - CPPUNIT_ASSERT_EQUAL(2UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); CPPUNIT_ASSERT_EQUAL(std::string("Z"), tokens[1]); tokens = LOOLProtocol::tokenize("\n"); - CPPUNIT_ASSERT_EQUAL(0UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), tokens.size()); tokens = LOOLProtocol::tokenize(" A \nZ "); - CPPUNIT_ASSERT_EQUAL(1UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); tokens = LOOLProtocol::tokenize(" A Z\n "); - CPPUNIT_ASSERT_EQUAL(2UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); CPPUNIT_ASSERT_EQUAL(std::string("Z"), tokens[1]); tokens = LOOLProtocol::tokenize(" A Z \n "); - CPPUNIT_ASSERT_EQUAL(2UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("A"), tokens[0]); CPPUNIT_ASSERT_EQUAL(std::string("Z"), tokens[1]); tokens = LOOLProtocol::tokenize("tile nviewid=0 part=0 width=256 height=256 tileposx=0 tileposy=0 tilewidth=3840 tileheight=3840 ver=-1"); - CPPUNIT_ASSERT_EQUAL(10UL, tokens.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(10), tokens.size()); CPPUNIT_ASSERT_EQUAL(std::string("tile"), tokens[0]); CPPUNIT_ASSERT_EQUAL(std::string("nviewid=0"), tokens[1]); CPPUNIT_ASSERT_EQUAL(std::string("part=0"), tokens[2]); @@ -382,21 +382,21 @@ void WhiteBoxTests::testTokenizer() std::vector<int> ints; ints = LOOLProtocol::tokenizeInts(std::string("-1")); - CPPUNIT_ASSERT_EQUAL(1UL, ints.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), 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(static_cast<size_t>(4), 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()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), ints.size()); ints = LOOLProtocol::tokenizeInts(std::string(",,,")); - CPPUNIT_ASSERT_EQUAL(0UL, ints.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), ints.size()); } void WhiteBoxTests::testReplace() diff --git a/test/helpers.hpp b/test/helpers.hpp index fd8e6973a..f09de8bbb 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -49,7 +49,7 @@ } #endif #define TST_LOG_NAME_BEGIN(NAME, X) do { \ - char t[64]; Poco::DateTime time; snprintf(t, sizeof(t), "%.2u:%.2u:%.2u.%.6u (@%lums) ", \ + char t[64]; Poco::DateTime time; snprintf(t, sizeof(t), "%.2u:%.2u:%.2u.%.6u (@%zums) ", \ time.hour(), time.minute(), time.second(), time.millisecond() * 1000 + time.microsecond(), helpers::timeSinceTestStartMs()); \ std::ostringstream str; str << NAME << t << X; tstLog(str); } while (false) #define TST_LOG_BEGIN(X) TST_LOG_NAME_BEGIN(testname, X) |