aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_env.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-09-30 17:31:10 +0200
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commit0efd9229584397140c85d323c1abfd649d0b662e (patch)
treec298600b44339659586060fbb2fd79af7ce4b64a /test/test_env.c
parentebc3356419f3fa6a535ba326b7492e44a532b035 (diff)
downloadserd-0efd9229584397140c85d323c1abfd649d0b662e.tar.gz
serd-0efd9229584397140c85d323c1abfd649d0b662e.tar.bz2
serd-0efd9229584397140c85d323c1abfd649d0b662e.zip
Add serd_env_copy() and serd_env_equals()
Diffstat (limited to 'test/test_env.c')
-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 4f947246..69b69061 100644
--- a/test/test_env.c
+++ b/test/test_env.c
@@ -13,6 +13,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)
{
@@ -118,6 +159,8 @@ test_env(void)
int
main(void)
{
+ test_copy();
+ test_comparison();
test_env();
return 0;
}