taskrambler  0.1.9
Web server and task management solution.
testers/uuid.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <uuid/uuid.h>
3 
4 #include "class.h"
5 #include "uuid.h"
6 
7 #include "commons.h"
8 #include "utils/memory.h"
9 
10 
11 #define UUID_NS "4f947b70-6f9f-43b6-8dc1-1321977c8240"
12 
13 
14 int
15 main(int argc, char * argv[])
16 {
17  int i;
18  Uuid dummy1 = new(Uuid);
19  Uuid dummy2 = uuidVersion1();
20 
21  for (i=0; i<10000; i++) {
22  UuidString uuid_str;
23 
24  Uuid nsid = uuidParse(UUID_NS);
25  Uuid ver1 = uuidVersion1();
26  Uuid ver3 = uuidVersion3("foo", 3, nsid);
27  Uuid ver5 = uuidVersion5("foo", 3, nsid);
28 
29  uuidUnparse(nsid, uuid_str);
30  printf("nsid: %s\n", uuid_str);
31 
32  uuidUnparse(ver1, uuid_str);
33  printf("nsid: %s\n", uuid_str);
34 
35  uuidUnparse(ver3, uuid_str);
36  printf("nsid: %s\n", uuid_str);
37 
38  uuidUnparse(ver5, uuid_str);
39  printf("nsid: %s\n", uuid_str);
40 
41  printf("equal | expected 0 : got %d\n", uuidCompare(ver5, ver5));
42  printf("not equal | expected !0 : got %d\n", uuidCompare(ver3, ver5));
43 
44  delete(ver5);
45  delete(ver3);
46  delete(ver1);
47  delete(nsid);
48  }
49 
50  printf("compare const with created: %d\n", uuidCompare(uuidZero, dummy1));
51  printf("compare const with created: %d\n", uuidCompare(uuidZero, dummy2));
52 
53  delete(dummy1);
54  delete(dummy2);
55  memCleanup();
56 
57  return 0;
58 }
59 
60 // vim: set et ts=4 sw=4:
int uuidCompare(Uuid, Uuid)
Definition: compare.c:30
Uuid uuidParse(const UuidString)
Definition: uuid/parse.c:30
void uuidUnparse(Uuid, UuidString)
Definition: unparse.c:30
Uuid uuidVersion3(const unsigned char *, size_t, Uuid)
Definition: version3.c:39
Uuid uuidVersion1()
Definition: version1.c:30
Uuid uuidVersion5(const unsigned char *, size_t, Uuid)
Definition: version5.c:39
Uuid uuidZero
#define UUID_NS
Definition: testers/uuid.c:11
char UuidString[37]
Definition: uuid.h:40
void memCleanup()
Definition: memory.c:862
int main(int argc, char *argv[])
Definition: testers/uuid.c:15