aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-09-30 17:31:10 +0200
committerDavid Robillard <d@drobilla.net>2022-01-13 23:04:21 -0500
commit870eacef28930c9cc5d84fb7424f4519907ea877 (patch)
tree2b15d6c630dea76e1bcd2a7ea9364344244ac16e /test
parentfb98f65ba7cef9f3a66043d6f75cea0ccf6adb79 (diff)
downloadserd-870eacef28930c9cc5d84fb7424f4519907ea877.tar.gz
serd-870eacef28930c9cc5d84fb7424f4519907ea877.tar.bz2
serd-870eacef28930c9cc5d84fb7424f4519907ea877.zip
Add serd_env_copy() and serd_env_equals()
Diffstat (limited to 'test')
-rw-r--r--test/test_env.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test_env.c b/test/test_env.c
index efde32c5..f258beb6 100644
--- a/test/test_env.c
+++ b/test/test_env.c
@@ -21,6 +21,47 @@
#include <assert.h>
#include <string.h>
+static void
+test_copy(void)
+{
+ assert(!serd_env_copy(NULL));
+
+ SerdEnv* const env = serd_env_new(SERD_STRING("http://example.org/base/"));
+
+ serd_env_set_prefix(
+ env, SERD_STRING("eg"), SERD_STRING("http://example.org/"));
+
+ SerdEnv* const env_copy = serd_env_copy(env);
+
+ assert(serd_env_equals(env, env_copy));
+
+ serd_env_set_prefix(
+ env_copy, SERD_STRING("test"), SERD_STRING("http://example.org/test"));
+
+ assert(!serd_env_equals(env, env_copy));
+
+ serd_env_set_prefix(
+ env, SERD_STRING("test2"), SERD_STRING("http://example.org/test2"));
+
+ assert(!serd_env_equals(env, env_copy));
+
+ serd_env_free(env_copy);
+ serd_env_free(env);
+}
+
+static void
+test_comparison(void)
+{
+ SerdEnv* const env = serd_env_new(SERD_EMPTY_STRING());
+
+ assert(!serd_env_equals(env, NULL));
+ assert(!serd_env_equals(NULL, env));
+ assert(serd_env_equals(NULL, NULL));
+ assert(serd_env_equals(env, env));
+
+ serd_env_free(env);
+}
+
static SerdStatus
count_prefixes(void* handle, const SerdEvent* event)
{
@@ -126,6 +167,8 @@ test_env(void)
int
main(void)
{
+ test_copy();
+ test_comparison();
test_env();
return 0;
}