Browse Source

Port the mg_get_cookie test

Matt Clarkson 10 years ago
parent
commit
ac48a01b93
1 changed files with 13 additions and 1 deletions
  1. 13 1
      test/public.c

+ 13 - 1
test/public.c

@@ -32,7 +32,19 @@
 
 
 START_TEST (test_mg_get_cookie)
 START_TEST (test_mg_get_cookie)
 {
 {
-  fail_if(0, "s not null after free");
+  char buf[20];
+
+  ck_assert_int_eq(-2, mg_get_cookie("", "foo", NULL, sizeof(buf)));
+  ck_assert_int_eq(-2, mg_get_cookie("", "foo", buf, 0));
+  ck_assert_int_eq(-1, mg_get_cookie("", "foo", buf, sizeof(buf)));
+  ck_assert_int_eq(-1, mg_get_cookie("", NULL, buf, sizeof(buf)));
+  ck_assert_int_eq(1, mg_get_cookie("a=1; b=2; c; d", "a", buf, sizeof(buf)));
+  ck_assert_str_eq("1", buf);
+  ck_assert_int_eq(1, mg_get_cookie("a=1; b=2; c; d", "b", buf, sizeof(buf)));
+  ck_assert_str_eq("2", buf);
+  ck_assert_int_eq(3, mg_get_cookie("a=1; b=123", "b", buf, sizeof(buf)));
+  ck_assert_str_eq("123", buf);
+  ck_assert_int_eq(-1, mg_get_cookie("a=1; b=2; c; d", "c", buf, sizeof(buf)));
 }
 }
 END_TEST
 END_TEST