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) Lumiera.org
5  2007, 2008 Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
30 #include "lib/luid.h"
31 
32 #include <nobug.h>
33 
34 
35 int
36 main (int argc, char** argv)
37 {
38  NOBUG_INIT;
39 
40  if (argc == 1)
41  return 0;
42 
43  if (!strcmp(argv[1], "luidgen_2"))
44  {
45  lumiera_uid luid1;
46  lumiera_uid luid2;
47 
48  lumiera_uid_gen (&luid1);
49  lumiera_uid_gen (&luid2);
50 
51  printf ("%d\n", lumiera_uid_eq (&luid2, &luid1));
52  }
53  else if (!strcmp(argv[1], "luidgen_copy"))
54  {
55  lumiera_uid luid1;
56  lumiera_uid luid2;
57 
58  lumiera_uid_gen (&luid1);
59 
60  lumiera_uid_copy (&luid2, &luid1);
61 
62  printf ("%d\n", lumiera_uid_eq (&luid2, &luid1));
63  }
64  else if (!strcmp(argv[1], "ptrs"))
65  {
66  lumiera_uid luid;
67 
68  lumiera_uid_set_ptr (&luid, &luid);
69 
70  printf ("%d\n", lumiera_uid_ptr_get (&luid) == &luid);
71  }
72  else
73  return 1;
74 
75  return 0;
76 }
77 
78 /*
79 // Local Variables:
80 // mode: C
81 // c-file-style: "gnu"
82 // indent-tabs-mode: nil
83 // End:
84 */
int main(int argc, const char *argv[])
run all tests or any single test specified in the first command line argument.
Definition: testrunner.cpp:47
void * lumiera_uid_ptr_get(const lumiera_uid *luid)
Retrieve a generic pointer stored in a luid.
Definition: luid.c:50
Lumiera unique object identifier.
void lumiera_uid_gen(lumiera_uid *luid)
Generate a new luid.
Definition: luid.c:57
void lumiera_uid_copy(lumiera_uid *dest, lumiera_uid *src)
Copy an luid.
Definition: luid.c:99
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid&#39;s for equality.
Definition: luid.c:106
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
Definition: hash-value.h:45
void lumiera_uid_set_ptr(lumiera_uid *luid, void *ptr)
Store a generic pointer in a luid.
Definition: luid.c:42