6
#include <emscripten.h>
8
int isUUID(char* p, int upper) {
11
if (!(isxdigit(*p1) || (*p1 == '-')) || (upper && islower(*p1)) || (!upper && isupper(*p1))) {
17
if ((p[8] == '-') && (p[13] == '-') && (p[18] == '-') && (p[23] == '-')) {
28
uuid_t empty_uuid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
31
assert(uuid_is_null(uuid) == 0);
32
assert(uuid_type(uuid) == UUID_TYPE_DCE_RANDOM);
33
assert(uuid_variant(uuid) == UUID_VARIANT_DCE);
35
char *generated = (char *)malloc(37*sizeof(char));
36
uuid_unparse(uuid, generated);
37
assert(isUUID(generated, 0) == 1); // Check it's a valid lower case UUID string.
38
printf("\nuuid = %s\n", generated);
40
assert(uuid_parse(generated, uuid1) == 0); // Check the generated UUID parses correctly into a compact UUID.
41
assert(uuid_compare(uuid1, uuid) == 0); // Compare the parsed UUID with the original.
43
uuid_unparse_lower(uuid, generated);
44
assert(isUUID(generated, 0) == 1); // Check it's a valid lower case UUID string.
45
printf("uuid = %s\n", generated);
47
uuid_unparse_upper(uuid, generated);
48
assert(isUUID(generated, 1) == 1); // Check it's a valid upper case UUID string.
49
printf("uuid = %s\n", generated);
52
uuid_copy(uuid2, uuid);
53
assert(uuid_compare(uuid2, uuid) == 0);
56
assert(uuid_compare(empty_uuid, uuid) == 0);
58
assert(uuid_is_null(uuid) == 1);
60
// The following lets the browser test exit cleanly.