nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit dd13cae30c54a25c54b66ea7310e1b3f29b27f7f
parent 0d20c8e6a50acfdd177288370d1d3e4c2caef673
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue, 25 Feb 2020 21:05:53 -0500

nserver/tests: Update protocol_tests.c.

* nserver/tests/protocol_tests.c (test_sscreate)
(test_sssample, test_ssmean, test_ssdump): Add delete flag test.

Diffstat:
nserver/tests/protocol_tests.c | 42++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/nserver/tests/protocol_tests.c b/nserver/tests/protocol_tests.c @@ -17,6 +17,13 @@ char *test_sscreate() rc = sscreate("/crimson/sky"); mu_assert(rc == 0, "sscreate failed 3"); + // delete. check. + rc = ssdelete("/crimson/sky"); + mu_assert(rc == 0, "ssdelete failed 0"); + + rc = sscreate("/crimson/sky"); + mu_assert(rc == 2, "sscreate failed 4"); + return NULL; } @@ -51,6 +58,21 @@ char *test_sssample() mean = sssample("/crimson", 10); mu_assert(mean == 15.20, "sssample failed 8"); + // delete check. + int rc = ssdelete("/crimson/sky"); + mu_assert(rc == 0, "ssdeleted failed 0"); + + mean = sssample("/crimson/sky", 71); + mu_assert(mean == -1, "sssample failed 9"); + + rc = sscreate("/crimson/sky"); + mu_assert(rc == 2, "sscreate failed 1"); + + mean = sssample("/crimson/sky", 71); + mu_assert(mean == 71.0, "sssample failed 9"); + + + return NULL; } @@ -59,7 +81,7 @@ char *test_ssmean() double m = 0; m = ssmean("/crimson"); - mu_assert(m == 15.20, "ssmean failed 0"); + mu_assert(m == 24.50, "ssmean failed 0"); m = ssmean("/vermilion"); mu_assert(m == 17, "ssmean failed 1"); @@ -67,6 +89,16 @@ char *test_ssmean() m = ssmean("/ruby"); mu_assert(m == -1, "ssmean failed 2"); + m = ssmean("/crimson/sky"); + mu_assert(m == 71.0, "ssmean failed 3"); + + // delete check. + int rc = ssdelete("/crimson/sky"); + mu_assert(rc == 0, "ssdeleted failed 0"); + + m = ssmean("/crimson/sky"); + mu_assert(m == -1, "ssmean failed 4"); + return NULL; } @@ -92,8 +124,8 @@ char *test_ssdump() mu_assert(dstr == NULL, "ssdump failed 2"); debug("DUMP: %s", dstr); - // clean up. - free(dstr); + dstr = ssdump("/crimson/sky"); + mu_assert(dstr == NULL, "ssdump failed 2"); return NULL; } @@ -102,9 +134,7 @@ char *test_sslist() { char *ks = sslist(); mu_assert(ks != NULL, "sslist failed"); - mu_assert(strlen(ks) == 33, "length check failed"); - - debug("KEYS:\n%s", ks); + mu_assert(strlen(ks) == 20, "length check failed"); return NULL; }