aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/test_serd.c32
-rw-r--r--test/test_string.c64
-rw-r--r--wscript2
3 files changed, 66 insertions, 32 deletions
diff --git a/test/test_serd.c b/test/test_serd.c
index 34661fd5..533eeec7 100644
--- a/test/test_serd.c
+++ b/test/test_serd.c
@@ -255,36 +255,6 @@ test_blob_to_node(void)
}
static void
-test_strlen(void)
-{
- const uint8_t str[] = { '"', '5', 0xE2, 0x82, 0xAC, '"', '\n', 0 };
-
- size_t n_bytes = 0;
- SerdNodeFlags flags = 0;
- size_t len = serd_strlen(str, &n_bytes, &flags);
- assert(len == 5 && n_bytes == 7 &&
- flags == (SERD_HAS_QUOTE | SERD_HAS_NEWLINE));
- len = serd_strlen(str, NULL, &flags);
- assert(len == 5);
-
- assert(serd_strlen(str, &n_bytes, NULL) == 5);
-}
-
-static void
-test_strerror(void)
-{
- const uint8_t* msg = serd_strerror(SERD_SUCCESS);
- assert(!strcmp((const char*)msg, "Success"));
- for (int i = SERD_FAILURE; i <= SERD_ERR_INTERNAL; ++i) {
- msg = serd_strerror((SerdStatus)i);
- assert(strcmp((const char*)msg, "Success"));
- }
-
- msg = serd_strerror((SerdStatus)-1);
- assert(!strcmp((const char*)msg, "Unknown error"));
-}
-
-static void
test_node_equals(void)
{
const uint8_t replacement_char_str[] = { 0xEF, 0xBF, 0xBD, 0 };
@@ -512,8 +482,6 @@ main(void)
test_double_to_node();
test_integer_to_node();
test_blob_to_node();
- test_strlen();
- test_strerror();
test_node_equals();
test_node_from_string();
test_node_from_substring();
diff --git a/test/test_string.c b/test/test_string.c
new file mode 100644
index 00000000..1e11f5b4
--- /dev/null
+++ b/test/test_string.c
@@ -0,0 +1,64 @@
+/*
+ Copyright 2011-2020 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#undef NDEBUG
+
+#include "serd/serd.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+static void
+test_strlen(void)
+{
+ const uint8_t str[] = { '"', '5', 0xE2, 0x82, 0xAC, '"', '\n', 0 };
+
+ size_t n_bytes = 0;
+ SerdNodeFlags flags = 0;
+ size_t len = serd_strlen(str, &n_bytes, &flags);
+ assert(len == 5 && n_bytes == 7 &&
+ flags == (SERD_HAS_QUOTE | SERD_HAS_NEWLINE));
+ len = serd_strlen(str, NULL, &flags);
+ assert(len == 5);
+
+ assert(serd_strlen(str, &n_bytes, NULL) == 5);
+}
+
+static void
+test_strerror(void)
+{
+ const uint8_t* msg = serd_strerror(SERD_SUCCESS);
+ assert(!strcmp((const char*)msg, "Success"));
+ for (int i = SERD_FAILURE; i <= SERD_ERR_INTERNAL; ++i) {
+ msg = serd_strerror((SerdStatus)i);
+ assert(strcmp((const char*)msg, "Success"));
+ }
+
+ msg = serd_strerror((SerdStatus)-1);
+ assert(!strcmp((const char*)msg, "Unknown error"));
+}
+
+int
+main(void)
+{
+ test_strlen();
+ test_strerror();
+
+ printf("Success\n");
+ return 0;
+}
diff --git a/wscript b/wscript
index 953d1652..1e12cf7f 100644
--- a/wscript
+++ b/wscript
@@ -215,6 +215,7 @@ def build(bld):
('test_free_null', 'test/test_free_null.c'),
('test_read_chunk', 'test/test_read_chunk.c'),
('test_serd', 'test/test_serd.c'),
+ ('test_string', 'test/test_string.c'),
('test_uri', 'test/test_uri.c')]:
bld(features = 'c cprogram',
source = prog[1],
@@ -542,6 +543,7 @@ def test(tst):
check(['./test_free_null'])
check(['./test_read_chunk'])
check(['./test_serd'])
+ check(['./test_string'])
check(['./test_uri'])
def test_syntax_io(check, in_name, check_name, lang):