aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_env.c
diff options
context:
space:
mode:
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 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;
}