summaryrefslogtreecommitdiffstats
path: root/3rdparty/bx/tests/string_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bx/tests/string_test.cpp')
-rw-r--r--3rdparty/bx/tests/string_test.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/3rdparty/bx/tests/string_test.cpp b/3rdparty/bx/tests/string_test.cpp
index 3d98e38b2e8..ed83e86cc4d 100644
--- a/3rdparty/bx/tests/string_test.cpp
+++ b/3rdparty/bx/tests/string_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2016 Branimir Karadzic. All rights reserved.
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
@@ -19,6 +19,27 @@ TEST_CASE("strnlen", "")
REQUIRE(4 == bx::strnlen(test, UINT32_MAX) );
}
+TEST_CASE("strlncpy", "")
+{
+ char dst[128];
+ size_t num;
+
+ num = bx::strlncpy(dst, 1, "blah");
+ REQUIRE(num == 0);
+
+ num = bx::strlncpy(dst, 3, "blah", 3);
+ REQUIRE(0 == strcmp(dst, "bl") );
+ REQUIRE(num == 2);
+
+ num = bx::strlncpy(dst, sizeof(dst), "blah", 3);
+ REQUIRE(0 == strcmp(dst, "bla") );
+ REQUIRE(num == 3);
+
+ num = bx::strlncpy(dst, sizeof(dst), "blah");
+ REQUIRE(0 == strcmp(dst, "blah") );
+ REQUIRE(num == 4);
+}
+
TEST_CASE("StringView", "")
{
bx::StringView sv("test");
@@ -32,10 +53,21 @@ TEST_CASE("StringView", "")
String st(sv);
REQUIRE(4 == st.getLength() );
+ st.append("test");
+ REQUIRE(8 == st.getLength() );
+
+ st.append("test", 2);
+ REQUIRE(10 == st.getLength() );
+
+ REQUIRE(0 == strcmp(st.getPtr(), "testtestte") );
+
st.clear();
REQUIRE(0 == st.getLength() );
REQUIRE(4 == sv.getLength() );
+ st.append("test");
+ REQUIRE(4 == st.getLength() );
+
sv.clear();
REQUIRE(0 == sv.getLength() );
}