aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-13 11:26:48 +0100
committerDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-13 11:26:48 +0100
commit1e8fa138696f28cf712d50d85b91afce1faec655 (patch)
tree74f33703c9ec2e26ce3359b536529fe488ba3265 /tests
parentc9a5143b2aa9b92d1fbff4c804f058cf0e84f953 (diff)
downloadunja-1e8fa138696f28cf712d50d85b91afce1faec655.tar.gz
unja-1e8fa138696f28cf712d50d85b91afce1faec655.zip
add whitespace control for statements
Diffstat (limited to 'tests')
-rw-r--r--tests/test_hashmap.c11
-rw-r--r--tests/test_template.c10
2 files changed, 13 insertions, 8 deletions
diff --git a/tests/test_hashmap.c b/tests/test_hashmap.c
index d78f768..b9e1cfd 100644
--- a/tests/test_hashmap.c
+++ b/tests/test_hashmap.c
@@ -6,26 +6,21 @@ START_TESTS
TEST(hashmap) {
struct hashmap *hm = hashmap_new();
assert(hashmap_get(hm, "foo") == NULL, "expected NULL");
-
hashmap_insert(hm, "foo", "bar");
char *value = hashmap_get(hm, "foo");
- assert(value != NULL, "expected value, got NULL");
- assert(strcmp(value, "bar") == 0, "expected %s, got %s", "bar", value);
-
+ assert_str(value, "bar");
hashmap_free(hm);
}
TEST(dot_notation) {
-
struct hashmap *user = hashmap_new();
hashmap_insert(user, "name", "Danny");
struct hashmap *hm = hashmap_new();
hashmap_insert(hm, "user", user);
+ assert(hashmap_resolve(hm, "user") == user, "expected user hashmap, got something else");
char *value = (char *) hashmap_resolve(hm, "user.name");
- assert(value != NULL, "expected value, got NULL");
- assert(strcmp(value, "Danny") == 0, "expected %s, got %s", "Danny", value);
-
+ assert_str(value, "Danny");
hashmap_free(hm);
}
diff --git a/tests/test_template.c b/tests/test_template.c
index d9f74ac..90190cc 100644
--- a/tests/test_template.c
+++ b/tests/test_template.c
@@ -20,6 +20,16 @@ TEST(var) {
free(output);
}
+TEST(var_whitespace) {
+ char *input = "Hello \n{{-name -}}\n.";
+ struct hashmap *ctx = hashmap_new();
+ hashmap_insert(ctx, "name", "world");
+ char *output = template(input, ctx);
+ assert_str(output, "Helloworld.");
+ hashmap_free(ctx);
+ free(output);
+}
+
TEST(multiline) {
char *input = "Hello {{name}}.\nL2";
struct hashmap *ctx = hashmap_new();