Updated MSpec source to 46e80081.
[rbx.git] / shotgun / external_libs / libmquark / tester.c
blob48f5a53022857d67d1ea8c091b1a06f649eba50d
1 #include "quark.h"
2 #include <assert.h>
3 #include <stdlib.h>
4 #include <string.h>
6 int main(int argc, char ** argv)
8 /* by default, 0 <-> NULL */
9 assert(quark_from_string(NULL) == 0);
10 assert(quark_to_string(0) == NULL);
12 /* strings are internalized, setting the same value multiple times
13 * will give the same quark */
14 const char * foo = "foo";
15 assert(quark_from_string(foo) == 1);
16 assert(quark_from_string(foo) == 1);
18 /* this is a copy of the string, unless the quark_from_static_string
19 * is used */
20 assert(quark_to_string(1) != foo);
21 const char *bar = "bar";
22 assert(quark_from_static_string(bar) == 2);
23 assert(quark_to_string(2) == bar);
25 /* this is the same for the same string content at a different address */
26 char * foo2 = strdup(foo);
27 assert(quark_from_string(foo2) == 1);
28 assert(quark_to_string(1) != foo2);
29 free(foo2);
31 return 0;