Lumiera  0.pre.03
»edit your freedom«
test-luid.c
Go to the documentation of this file.
1 /*
2  TEST-LUID - test the Lumiera Uniform Identifier
3 
4  Copyright (C)
5  2007, 2008 Christian Thaeter <ct@pipapo.org>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
21 #include "lib/luid.h"
22 
23 #include <nobug.h>
24 
25 
26 int
27 main (int argc, char** argv)
28 {
29  NOBUG_INIT;
30 
31  if (argc == 1)
32  return 0;
33 
34  if (!strcmp(argv[1], "luidgen_2"))
35  {
36  lumiera_uid luid1;
37  lumiera_uid luid2;
38 
39  lumiera_uid_gen (&luid1);
40  lumiera_uid_gen (&luid2);
41 
42  printf ("%d\n", lumiera_uid_eq (&luid2, &luid1));
43  }
44  else if (!strcmp(argv[1], "luidgen_copy"))
45  {
46  lumiera_uid luid1;
47  lumiera_uid luid2;
48 
49  lumiera_uid_gen (&luid1);
50 
51  lumiera_uid_copy (&luid2, &luid1);
52 
53  printf ("%d\n", lumiera_uid_eq (&luid2, &luid1));
54  }
55  else if (!strcmp(argv[1], "ptrs"))
56  {
57  lumiera_uid luid;
58 
59  lumiera_uid_set_ptr (&luid, &luid);
60 
61  printf ("%d\n", lumiera_uid_ptr_get (&luid) == &luid);
62  }
63  else
64  return 1;
65 
66  return 0;
67 }
68 
69 /*
70 // Local Variables:
71 // mode: C
72 // c-file-style: "gnu"
73 // indent-tabs-mode: nil
74 // End:
75 */
int main(int argc, const char *argv[])
run all tests or any single test specified in the first command line argument.
Definition: testrunner.cpp:37
void * lumiera_uid_ptr_get(const lumiera_uid *luid)
Retrieve a generic pointer stored in a luid.
Definition: luid.c:41
Lumiera unique object identifier.
void lumiera_uid_gen(lumiera_uid *luid)
Generate a new luid.
Definition: luid.c:48
void lumiera_uid_copy(lumiera_uid *dest, lumiera_uid *src)
Copy an luid.
Definition: luid.c:90
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid&#39;s for equality.
Definition: luid.c:97
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
Definition: hash-value.h:40
void lumiera_uid_set_ptr(lumiera_uid *luid, void *ptr)
Store a generic pointer in a luid.
Definition: luid.c:33