summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorVinzenz Feenstra <evilissimo@gmail.com>2014-02-26 16:18:05 +0100
committerVinzenz Feenstra <evilissimo@gmail.com>2014-02-26 16:18:05 +0100
commit61789718733ea30c6b6844b1804920289dda3919 (patch)
treea192c33e6082511c42b4134cac52a8a9fe3cadea /bin
parentbfa38b51663d59cfaec7aa469565c09a4ec05275 (diff)
Adding unit tests for begins_with
Signed-off-by: Vinzenz Feenstra <evilissimo@gmail.com>
Diffstat (limited to 'bin')
-rw-r--r--bin/tests/test_string.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp
index 78fb9a9ddb..66238b066d 100644
--- a/bin/tests/test_string.cpp
+++ b/bin/tests/test_string.cpp
@@ -479,6 +479,36 @@ bool test_26() {
return captures.size();
};
+struct test_27_data {
+ char const * data;
+ char const * begin;
+ bool expected;
+};
+
+bool test_27() {
+
+ OS::get_singleton()->print("\n\nTest 26: begins_with\n");
+ test_27_data tc[] = {
+ {"res://foobar", "res://", true},
+ {"res", "res://", false},
+ {"abc", "abc", true}
+ };
+ size_t count = sizeof(tc) / sizeof(tc[0]);
+ bool state = true;
+ for (size_t i = 0;state && i < count; ++i) {
+ String s = tc[i].data;
+ state = s.begins_with(tc[i].begin) == tc[i].expected;
+ if (state) {
+ String sb = tc[i].begin;
+ state = s.begins_with(sb) == tc[i].expected;
+ }
+ if (!state) {
+ OS::get_singleton()->print("\n\t Failure on:\n\t\tstring: ", tc[i].data, "\n\t\tbegin: ", tc[i].begin, "\n\t\texpected: ", tc[i].expected ? "true" : "false", "\n");
+ }
+ };
+ return state;
+};
+
typedef bool (*TestFunc)(void);
TestFunc test_funcs[] = {
@@ -509,6 +539,7 @@ TestFunc test_funcs[] = {
test_24,
test_25,
test_26,
+ test_27,
0
};