summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-04-13 19:20:33 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:43 (GMT)
commit68b51298da4fcfcdc3bb81a9abba6c56809ae1b7 (patch)
tree1a2e812ff6c54856f2a28b7ba208ca6bcb346579 /Swiften
parent509973e7e5978c2225fb89a10a1e2343fce21e7b (diff)
downloadswift-68b51298da4fcfcdc3bb81a9abba6c56809ae1b7.zip
swift-68b51298da4fcfcdc3bb81a9abba6c56809ae1b7.tar.bz2
Added ByteArray unit tests for null termination.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/UnitTest/ByteArrayTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/Swiften/Base/UnitTest/ByteArrayTest.cpp b/Swiften/Base/UnitTest/ByteArrayTest.cpp
index cb10dd4..b9797d2 100644
--- a/Swiften/Base/UnitTest/ByteArrayTest.cpp
+++ b/Swiften/Base/UnitTest/ByteArrayTest.cpp
@@ -14,6 +14,9 @@ using namespace Swift;
class ByteArrayTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ByteArrayTest);
CPPUNIT_TEST(testGetData_NoData);
+ CPPUNIT_TEST(testToString);
+ CPPUNIT_TEST(testToString_NullTerminated);
+ CPPUNIT_TEST(testToString_TwoNullTerminated);
CPPUNIT_TEST_SUITE_END();
public:
@@ -22,6 +25,24 @@ class ByteArrayTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(reinterpret_cast<const char*>(NULL), reinterpret_cast<const char*>(testling.getData()));
}
+
+ void testToString() {
+ ByteArray testling(ByteArray::create("abcde"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("abcde"), testling.toString());
+ }
+
+ void testToString_NullTerminated() {
+ ByteArray testling(ByteArray::create("abcde\0"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("abcde"), testling.toString());
+ }
+
+ void testToString_TwoNullTerminated() {
+ ByteArray testling(ByteArray::create("abcde\0\0"));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("abcde"), testling.toString());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ByteArrayTest);