uuid4r 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/uuid4r.c +66 -66
- data/test/test_uuid.rb +1 -1
- metadata +32 -44
- data/test/test_uuid.rb~ +0 -120
data/ext/uuid4r.c
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
/*
|
1
|
+
/*
|
2
2
|
* COPYRIGHT AND LICENSE
|
3
|
-
*
|
3
|
+
*
|
4
4
|
* Copyright (C) 2006 Daigo Moriwaki <daigo@debian.org>
|
5
|
-
*
|
5
|
+
*
|
6
6
|
* Permission to use, copy, modify, and distribute this software for
|
7
7
|
* any purpose with or without fee is hereby granted, provided that
|
8
8
|
* the above copyright notice and this permission notice appear in all
|
9
9
|
* copies.
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
12
12
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
13
13
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -22,9 +22,9 @@
|
|
22
22
|
* SUCH DAMAGE.
|
23
23
|
*
|
24
24
|
*/
|
25
|
-
|
26
|
-
#include "ruby.h"
|
25
|
+
|
27
26
|
#include "uuid.h"
|
27
|
+
#include "ruby.h"
|
28
28
|
|
29
29
|
VALUE rb_cUUID4R;
|
30
30
|
VALUE rb_cUUID4RCommon;
|
@@ -41,7 +41,7 @@ rb2uuid_fmt(symbol)
|
|
41
41
|
{
|
42
42
|
ID fmt;
|
43
43
|
uuid_fmt_t result;
|
44
|
-
|
44
|
+
|
45
45
|
fmt = rb_to_id(symbol);
|
46
46
|
if (fmt == id_fmt_bin)
|
47
47
|
result = UUID_FMT_BIN;
|
@@ -67,7 +67,7 @@ export(uuid, fmt)
|
|
67
67
|
|
68
68
|
str = NULL;
|
69
69
|
ptr = NULL;
|
70
|
-
|
70
|
+
|
71
71
|
/* dispatch into format-specific functions */
|
72
72
|
switch (fmt) {
|
73
73
|
case UUID_FMT_BIN:
|
@@ -75,7 +75,7 @@ export(uuid, fmt)
|
|
75
75
|
result = rb_str_new(ptr, UUID_LEN_BIN);
|
76
76
|
free(ptr);
|
77
77
|
break;
|
78
|
-
case UUID_FMT_STR:
|
78
|
+
case UUID_FMT_STR:
|
79
79
|
rc = uuid_export(uuid, fmt, (void **)&str, NULL);
|
80
80
|
result = rb_str_new2(str);
|
81
81
|
free(str);
|
@@ -88,7 +88,7 @@ export(uuid, fmt)
|
|
88
88
|
default:
|
89
89
|
rb_raise(rb_eArgError, "wrong argument");
|
90
90
|
}
|
91
|
-
|
91
|
+
|
92
92
|
return result;
|
93
93
|
}
|
94
94
|
|
@@ -101,7 +101,7 @@ uuid4r_free(uuid)
|
|
101
101
|
{
|
102
102
|
uuid_destroy(uuid);
|
103
103
|
}
|
104
|
-
|
104
|
+
|
105
105
|
static VALUE
|
106
106
|
uuid4r_alloc(klass)
|
107
107
|
VALUE klass;
|
@@ -124,7 +124,7 @@ uuid4r_compare(lhs, rhs)
|
|
124
124
|
const uuid_t *uuid_lhs;
|
125
125
|
const uuid_t *uuid_rhs;
|
126
126
|
int value;
|
127
|
-
|
127
|
+
|
128
128
|
Data_Get_Struct(lhs, uuid_t, uuid_lhs);
|
129
129
|
Data_Get_Struct(rhs, uuid_t, uuid_rhs);
|
130
130
|
uuid_compare(uuid_lhs, uuid_rhs, &value);
|
@@ -141,15 +141,15 @@ uuid4r_export(argc, argv, self)
|
|
141
141
|
VALUE format;
|
142
142
|
uuid_fmt_t fmt;
|
143
143
|
uuid_t *uuid;
|
144
|
-
|
144
|
+
|
145
145
|
if ( rb_scan_args(argc, argv, "01", &format) == 1)
|
146
146
|
fmt = rb2uuid_fmt(format);
|
147
147
|
else
|
148
148
|
fmt = UUID_FMT_STR;
|
149
149
|
|
150
150
|
Data_Get_Struct(self, uuid_t, uuid);
|
151
|
-
|
152
|
-
return export(uuid, fmt);
|
151
|
+
|
152
|
+
return export(uuid, fmt);
|
153
153
|
}
|
154
154
|
|
155
155
|
VALUE
|
@@ -158,12 +158,12 @@ uuid4r_import(self, format, str)
|
|
158
158
|
{
|
159
159
|
uuid_fmt_t fmt;
|
160
160
|
uuid_t *uuid;
|
161
|
-
|
161
|
+
|
162
162
|
uuid_create(&uuid);
|
163
163
|
fmt = rb2uuid_fmt(format);
|
164
164
|
StringValue(str);
|
165
165
|
uuid_import(uuid, fmt, RSTRING_PTR(str), RSTRING_LEN(str));
|
166
|
-
|
166
|
+
|
167
167
|
return Data_Wrap_Struct(rb_cUUID4RCommon, 0, uuid4r_free, uuid);
|
168
168
|
}
|
169
169
|
|
@@ -174,10 +174,10 @@ uuid4rv1_initialize(self)
|
|
174
174
|
VALUE self;
|
175
175
|
{
|
176
176
|
uuid_t *uuid;
|
177
|
-
|
177
|
+
|
178
178
|
Data_Get_Struct(self, uuid_t, uuid);
|
179
|
-
uuid_make(uuid, UUID_MAKE_V1);
|
180
|
-
|
179
|
+
uuid_make(uuid, UUID_MAKE_V1);
|
180
|
+
|
181
181
|
return self;
|
182
182
|
}
|
183
183
|
|
@@ -192,16 +192,16 @@ uuid4rv3_initialize(self, namespace, namespace_str)
|
|
192
192
|
uuid_t *uuid;
|
193
193
|
uuid_t *uuid_ns;
|
194
194
|
char *uuid_ns_str;
|
195
|
-
|
195
|
+
|
196
196
|
uuid_ns = NULL;
|
197
197
|
uuid_ns_str = NULL;
|
198
198
|
uuid_create(&uuid_ns);
|
199
|
-
uuid_load(uuid_ns, StringValueCStr(namespace));
|
199
|
+
uuid_load(uuid_ns, StringValueCStr(namespace));
|
200
200
|
uuid_ns_str = StringValueCStr(namespace_str);
|
201
|
-
|
201
|
+
|
202
202
|
Data_Get_Struct(self, uuid_t, uuid);
|
203
|
-
uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
|
204
|
-
|
203
|
+
uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
|
204
|
+
|
205
205
|
return self;
|
206
206
|
}
|
207
207
|
|
@@ -212,10 +212,10 @@ uuid4rv4_initialize(self)
|
|
212
212
|
VALUE self;
|
213
213
|
{
|
214
214
|
uuid_t *uuid;
|
215
|
-
|
215
|
+
|
216
216
|
Data_Get_Struct(self, uuid_t, uuid);
|
217
|
-
uuid_make(uuid, UUID_MAKE_V4);
|
218
|
-
|
217
|
+
uuid_make(uuid, UUID_MAKE_V4);
|
218
|
+
|
219
219
|
return self;
|
220
220
|
}
|
221
221
|
|
@@ -230,16 +230,16 @@ uuid4rv5_initialize(self, namespace, namespace_str)
|
|
230
230
|
uuid_t *uuid;
|
231
231
|
uuid_t *uuid_ns;
|
232
232
|
char *uuid_ns_str;
|
233
|
-
|
233
|
+
|
234
234
|
uuid_ns = NULL;
|
235
235
|
uuid_ns_str = NULL;
|
236
236
|
uuid_create(&uuid_ns);
|
237
|
-
uuid_load(uuid_ns, StringValueCStr(namespace));
|
237
|
+
uuid_load(uuid_ns, StringValueCStr(namespace));
|
238
238
|
uuid_ns_str = StringValueCStr(namespace_str);
|
239
|
-
|
239
|
+
|
240
240
|
Data_Get_Struct(self, uuid_t, uuid);
|
241
|
-
uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
|
242
|
-
|
241
|
+
uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
|
242
|
+
|
243
243
|
return self;
|
244
244
|
}
|
245
245
|
|
@@ -251,9 +251,9 @@ uuid4rv5_initialize(self, namespace, namespace_str)
|
|
251
251
|
* UUID4R::uuid(3, namespace, namespace_str, format = :str) => uuid
|
252
252
|
* UUID4R::uuid(4, format = :str) => uuid
|
253
253
|
* UUID4R::uuid(5, namespace, namespace_str, format = :str) => uuid
|
254
|
-
*
|
254
|
+
*
|
255
255
|
* Generates a DCE 1.1 with a specified version: 1, 3, 4 or 5.
|
256
|
-
* Returns an uuid as a specified format (:str, :bin, :txt).
|
256
|
+
* Returns an uuid as a specified format (:str, :bin, :txt).
|
257
257
|
*/
|
258
258
|
VALUE
|
259
259
|
uuid4r_uuid(argc, argv, self)
|
@@ -274,42 +274,42 @@ uuid4r_uuid(argc, argv, self)
|
|
274
274
|
|
275
275
|
uuid_ns = NULL;
|
276
276
|
uuid_ns_str = NULL;
|
277
|
-
|
277
|
+
|
278
278
|
switch (argc) {
|
279
279
|
case 1:
|
280
280
|
rb_scan_args(argc, argv, "11", &version, &format);
|
281
281
|
fmt = UUID_FMT_STR;
|
282
282
|
break;
|
283
283
|
case 2:
|
284
|
-
rb_scan_args(argc, argv, "11", &version, &format);
|
285
|
-
fmt = rb2uuid_fmt(format);
|
284
|
+
rb_scan_args(argc, argv, "11", &version, &format);
|
285
|
+
fmt = rb2uuid_fmt(format);
|
286
286
|
break;
|
287
287
|
case 3:
|
288
288
|
rb_scan_args(argc, argv, "31", &version, &namespace, &namespace_str, &format);
|
289
289
|
fmt = UUID_FMT_STR;
|
290
290
|
break;
|
291
291
|
case 4:
|
292
|
-
rb_scan_args(argc, argv, "31", &version, &namespace, &namespace_str, &format);
|
293
|
-
fmt = rb2uuid_fmt(format);
|
292
|
+
rb_scan_args(argc, argv, "31", &version, &namespace, &namespace_str, &format);
|
293
|
+
fmt = rb2uuid_fmt(format);
|
294
294
|
break;
|
295
295
|
default:
|
296
296
|
rb_raise(rb_eArgError, "wrong argument");
|
297
297
|
break;
|
298
298
|
}
|
299
|
-
|
299
|
+
|
300
300
|
switch (NUM2INT(version)) {
|
301
301
|
case 1: mode = UUID_MAKE_V1; break;
|
302
302
|
case 4: mode = UUID_MAKE_V4; break;
|
303
303
|
case 3:
|
304
304
|
mode = UUID_MAKE_V3;
|
305
305
|
uuid_create(&uuid_ns);
|
306
|
-
uuid_load(uuid_ns, StringValueCStr(namespace));
|
306
|
+
uuid_load(uuid_ns, StringValueCStr(namespace));
|
307
307
|
uuid_ns_str = StringValueCStr(namespace_str);
|
308
308
|
break;
|
309
|
-
case 5:
|
309
|
+
case 5:
|
310
310
|
mode = UUID_MAKE_V5;
|
311
311
|
uuid_create(&uuid_ns);
|
312
|
-
uuid_load(uuid_ns, StringValueCStr(namespace));
|
312
|
+
uuid_load(uuid_ns, StringValueCStr(namespace));
|
313
313
|
uuid_ns_str = StringValueCStr(namespace_str);
|
314
314
|
break;
|
315
315
|
}
|
@@ -326,9 +326,9 @@ uuid4r_uuid(argc, argv, self)
|
|
326
326
|
/**
|
327
327
|
* call-seq:
|
328
328
|
* UUID4R::uuid_v1(format = :str) => uuid
|
329
|
-
*
|
329
|
+
*
|
330
330
|
* Generates a DCE 1.1 v1 UUID from system environment.
|
331
|
-
* Returns an uuid as a specified format (:str, :bin, :txt).
|
331
|
+
* Returns an uuid as a specified format (:str, :bin, :txt).
|
332
332
|
*/
|
333
333
|
VALUE
|
334
334
|
uuid4r_uuid_v1(argc, argv, self)
|
@@ -337,19 +337,19 @@ uuid4r_uuid_v1(argc, argv, self)
|
|
337
337
|
VALUE self;
|
338
338
|
{
|
339
339
|
VALUE rest;
|
340
|
-
|
340
|
+
|
341
341
|
if ( rb_scan_args(argc, argv, "01", &rest) == 1)
|
342
342
|
return rb_funcall(self, rb_intern("uuid"), 2, INT2NUM(1), rest);
|
343
343
|
else
|
344
|
-
return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(1));
|
344
|
+
return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(1));
|
345
345
|
}
|
346
346
|
|
347
347
|
/**
|
348
348
|
* call-seq:
|
349
349
|
* UUID4R::uuid_v4(format = :str) => uuid
|
350
|
-
*
|
350
|
+
*
|
351
351
|
* Generates a DCE 1.1 v4 UUID based a random number.
|
352
|
-
* Returns an uuid as a specified format (:str, :bin, :txt).
|
352
|
+
* Returns an uuid as a specified format (:str, :bin, :txt).
|
353
353
|
*/
|
354
354
|
VALUE
|
355
355
|
uuid4r_uuid_v4(argc, argv, self)
|
@@ -358,19 +358,19 @@ uuid4r_uuid_v4(argc, argv, self)
|
|
358
358
|
VALUE self;
|
359
359
|
{
|
360
360
|
VALUE rest;
|
361
|
-
|
361
|
+
|
362
362
|
if ( rb_scan_args(argc, argv, "01", &rest) == 1)
|
363
363
|
return rb_funcall(self, rb_intern("uuid"), 2, INT2NUM(4), rest);
|
364
364
|
else
|
365
|
-
return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(4));
|
365
|
+
return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(4));
|
366
366
|
}
|
367
367
|
|
368
368
|
/**
|
369
369
|
* call-seq:
|
370
370
|
* UUID4R::uuid_v3(namespace, namespace_str, format = :str) => uuid
|
371
|
-
*
|
371
|
+
*
|
372
372
|
* Generates a DCE 1.1 v3 UUID with a name based with MD5.
|
373
|
-
* Returns an uuid as a specified format (:str, :bin, :txt).
|
373
|
+
* Returns an uuid as a specified format (:str, :bin, :txt).
|
374
374
|
*/
|
375
375
|
VALUE
|
376
376
|
uuid4r_uuid_v3(argc, argv, self)
|
@@ -380,21 +380,21 @@ uuid4r_uuid_v3(argc, argv, self)
|
|
380
380
|
{
|
381
381
|
VALUE namespace, namespace_str;
|
382
382
|
VALUE rest;
|
383
|
-
|
383
|
+
|
384
384
|
if ( rb_scan_args(argc, argv, "21", &namespace, &namespace_str, &rest) == 3)
|
385
|
-
return rb_funcall(self, rb_intern("uuid"), 4,
|
385
|
+
return rb_funcall(self, rb_intern("uuid"), 4,
|
386
386
|
INT2NUM(3), namespace, namespace_str, rest);
|
387
387
|
else
|
388
|
-
return rb_funcall(self, rb_intern("uuid"), 3,
|
389
|
-
INT2NUM(3), namespace, namespace_str);
|
388
|
+
return rb_funcall(self, rb_intern("uuid"), 3,
|
389
|
+
INT2NUM(3), namespace, namespace_str);
|
390
390
|
}
|
391
391
|
|
392
392
|
/**
|
393
393
|
* call-seq:
|
394
394
|
* UUID4R::uuid_v5(namespace, namespace_str, format = :str) => uuid
|
395
|
-
*
|
395
|
+
*
|
396
396
|
* Generates a DCE 1.1 v5 UUID with a name based with SHA-1.
|
397
|
-
* Returns an uuid as a specified format (:str, :bin, :txt).
|
397
|
+
* Returns an uuid as a specified format (:str, :bin, :txt).
|
398
398
|
*/
|
399
399
|
VALUE
|
400
400
|
uuid4r_uuid_v5(argc, argv, self)
|
@@ -404,13 +404,13 @@ uuid4r_uuid_v5(argc, argv, self)
|
|
404
404
|
{
|
405
405
|
VALUE namespace, namespace_str;
|
406
406
|
VALUE rest;
|
407
|
-
|
407
|
+
|
408
408
|
if ( rb_scan_args(argc, argv, "21", &namespace, &namespace_str, &rest) == 3)
|
409
|
-
return rb_funcall(self, rb_intern("uuid"), 4,
|
409
|
+
return rb_funcall(self, rb_intern("uuid"), 4,
|
410
410
|
INT2NUM(5), namespace, namespace_str, rest);
|
411
411
|
else
|
412
|
-
return rb_funcall(self, rb_intern("uuid"), 3,
|
413
|
-
INT2NUM(5), namespace, namespace_str);
|
412
|
+
return rb_funcall(self, rb_intern("uuid"), 3,
|
413
|
+
INT2NUM(5), namespace, namespace_str);
|
414
414
|
}
|
415
415
|
|
416
416
|
|
@@ -429,14 +429,14 @@ void Init_uuid4r (void) {
|
|
429
429
|
rb_define_module_function(rb_cUUID4R, "uuid_v4", uuid4r_uuid_v4, -1);
|
430
430
|
rb_define_module_function(rb_cUUID4R, "uuid_v5", uuid4r_uuid_v5, -1);
|
431
431
|
rb_define_module_function(rb_cUUID4R, "import", uuid4r_import, 2);
|
432
|
-
|
432
|
+
|
433
433
|
/* ------ UUID4RCommon ------ */
|
434
434
|
rb_cUUID4RCommon = rb_define_class_under(rb_cUUID4R, "UUID4RCommon", rb_cObject);
|
435
435
|
rb_define_alloc_func(rb_cUUID4RCommon, uuid4r_alloc);
|
436
436
|
rb_define_method(rb_cUUID4RCommon, "export", uuid4r_export, -1);
|
437
437
|
rb_define_method(rb_cUUID4RCommon, "compare", uuid4r_compare, 1);
|
438
438
|
rb_define_alias(rb_cUUID4RCommon, "<=>", "compare");
|
439
|
-
|
439
|
+
|
440
440
|
/* ------ UUID4Rv1 ------ */
|
441
441
|
rb_cUUID4Rv1 = rb_define_class_under(rb_cUUID4R, "UUID4Rv1", rb_cUUID4RCommon);
|
442
442
|
rb_define_alloc_func(rb_cUUID4Rv1, uuid4r_alloc);
|
data/test/test_uuid.rb
CHANGED
metadata
CHANGED
@@ -1,78 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid4r
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 2
|
10
|
-
version: 0.1.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Daigo Moriwaki
|
14
9
|
- Stefan Kaes
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
date: 2011-05-15 00:00:00 +02:00
|
20
|
-
default_executable:
|
13
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
21
14
|
dependencies: []
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
description: |2
|
16
|
+
This library generates and parses Universally Unique Identifier (UUID),
|
17
|
+
based on OSSP uuid C library. So, libossp-uuid library is pre-required.
|
18
|
+
OSSP uuid (http://www.ossp.org/pkg/lib/uuid/) is a ISO-C:1999 application
|
19
|
+
programming interface (API) for the generation of DCE 1.1, ISO/IEC
|
20
|
+
11578:1996 and RFC 4122 compliant UUID. It supports DCE 1.1 variant UUIDs
|
21
|
+
of version 1 (time and node based), version 3 (name based, MD5), version 4
|
22
|
+
(random number based) and version 5 (name based, SHA-1).
|
23
|
+
email:
|
25
24
|
- daigo@debian.org
|
26
25
|
- skaes@railsexpress.de
|
27
26
|
executables: []
|
28
|
-
|
29
|
-
extensions:
|
27
|
+
extensions:
|
30
28
|
- ext/extconf.rb
|
31
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
32
30
|
- README
|
33
|
-
files:
|
31
|
+
files:
|
34
32
|
- ext/extconf.rb
|
35
33
|
- ext/uuid4r.c
|
36
34
|
- test/test_uuid.rb
|
37
|
-
- test/test_uuid.rb~
|
38
35
|
- README
|
39
|
-
has_rdoc: true
|
40
36
|
homepage: http://uuid4r.rubyforge.org
|
41
37
|
licenses: []
|
42
|
-
|
43
38
|
post_install_message:
|
44
|
-
rdoc_options:
|
39
|
+
rdoc_options:
|
45
40
|
- --title
|
46
41
|
- UUID4R
|
47
42
|
- --main
|
48
43
|
- README
|
49
44
|
- --line-numbers
|
50
|
-
require_paths:
|
45
|
+
require_paths:
|
51
46
|
- .
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
48
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
61
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
54
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
segments:
|
68
|
-
- 0
|
69
|
-
version: "0"
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
70
59
|
requirements: []
|
71
|
-
|
72
60
|
rubyforge_project: uuid4r
|
73
|
-
rubygems_version: 1.
|
61
|
+
rubygems_version: 1.8.23
|
74
62
|
signing_key:
|
75
63
|
specification_version: 3
|
76
64
|
summary: This generates and parses UUID, based on OSSP uuid C library.
|
77
|
-
test_files:
|
65
|
+
test_files:
|
78
66
|
- test/test_uuid.rb
|
data/test/test_uuid.rb~
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require './uuid4r.so'
|
3
|
-
|
4
|
-
class UUIDTest < Test::Unit::TestCase
|
5
|
-
def test_uuid_v1_default
|
6
|
-
assert_kind_of(String, UUID4R::uuid_v1)
|
7
|
-
assert_kind_of(String, UUID4R::uuid(1))
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_uuid_v4_default
|
11
|
-
assert_kind_of(String, UUID4R::uuid_v4)
|
12
|
-
assert_kind_of(String, UUID4R::uuid(4))
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_uuid_v1_str
|
16
|
-
assert_kind_of(String, UUID4R::uuid_v1(:str))
|
17
|
-
assert(UUID4R::uuid_v1(:str).length > 0)
|
18
|
-
assert_not_equal(UUID4R::uuid_v1(:str), UUID4R::uuid_v1(:str))
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_uuid_v1_bin
|
22
|
-
assert_kind_of(String, UUID4R::uuid_v1(:bin))
|
23
|
-
assert_equal(16, UUID4R::uuid_v1(:bin).length)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_uuid_v1_txt
|
27
|
-
assert_kind_of(String, UUID4R::uuid_v1(:txt))
|
28
|
-
assert(/^variant:/ =~ UUID4R::uuid_v1(:txt))
|
29
|
-
assert(/^version:/ =~ UUID4R::uuid_v1(:txt))
|
30
|
-
assert(/^content:/ =~ UUID4R::uuid_v1(:txt))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_uuid_v3_str
|
34
|
-
a = UUID4R::uuid(3, "ns:URL", "www.sgtpepper.net", :str)
|
35
|
-
b = UUID4R::uuid(3, "ns:URL", "www.sgtpepper.net", :str)
|
36
|
-
c = UUID4R::uuid_v3("ns:URL", "www.sgtpepper.net", :str)
|
37
|
-
d = UUID4R::uuid_v3("ns:URL", "www.sgtpepper.net")
|
38
|
-
assert_kind_of(String, a)
|
39
|
-
assert(a.length > 0)
|
40
|
-
assert_equal(a, b)
|
41
|
-
assert_equal(a, c)
|
42
|
-
assert_equal(a, d)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_uuid_v5_str
|
46
|
-
a = UUID4R::uuid(5, "ns:URL", "www.sgtpepper.net", :str)
|
47
|
-
b = UUID4R::uuid(5, "ns:URL", "www.sgtpepper.net", :str)
|
48
|
-
c = UUID4R::uuid_v5("ns:URL", "www.sgtpepper.net", :str)
|
49
|
-
d = UUID4R::uuid_v5("ns:URL", "www.sgtpepper.net")
|
50
|
-
assert_kind_of(String, a)
|
51
|
-
assert(a.length > 0)
|
52
|
-
assert_equal(a, b)
|
53
|
-
assert_equal(a, c)
|
54
|
-
assert_equal(a, d)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_import
|
58
|
-
uuid = UUID4R::import(:str, "266eb9ae-ea6e-11da-8113-0030134d803d")
|
59
|
-
assert_kind_of(UUID4R::UUID4RCommon, uuid)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
class UUID4Rv1Test < Test::Unit::TestCase
|
65
|
-
def setup
|
66
|
-
@uuid = UUID4R::UUID4Rv1.new
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_export_str
|
70
|
-
assert_kind_of(String, @uuid.export(:str))
|
71
|
-
assert_equal(@uuid.export, @uuid.export(:str))
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_compare
|
75
|
-
uuid2 = UUID4R::UUID4Rv1.new
|
76
|
-
assert(@uuid.compare(uuid2) < 0)
|
77
|
-
assert(@uuid.compare(@uuid) == 0)
|
78
|
-
assert(uuid2.compare(@uuid) > 0)
|
79
|
-
assert_equal(-1, @uuid <=> uuid2)
|
80
|
-
assert_equal( 0, @uuid <=> @uuid)
|
81
|
-
assert_equal( 1, uuid2 <=> @uuid)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
class UUID4Rv4Test < Test::Unit::TestCase
|
87
|
-
def setup
|
88
|
-
@uuid = UUID4R::UUID4Rv4.new
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_export_str
|
92
|
-
assert_kind_of(String, @uuid.export(:str))
|
93
|
-
assert_equal(@uuid.export, @uuid.export(:str))
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
class UUID4Rv3Test < Test::Unit::TestCase
|
99
|
-
def setup
|
100
|
-
@uuid = UUID4R::UUID4Rv3.new("ns:URL", "www.sgtpepper.net")
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_export_str
|
104
|
-
assert_kind_of(String, @uuid.export(:str))
|
105
|
-
assert_equal(@uuid.export, @uuid.export(:str))
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
class UUID4Rv5Test < Test::Unit::TestCase
|
111
|
-
def setup
|
112
|
-
@uuid = UUID4R::UUID4Rv5.new("ns:URL", "www.sgtpepper.net")
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_export_str
|
116
|
-
assert_kind_of(String, @uuid.export(:str))
|
117
|
-
assert_equal(@uuid.export, @uuid.export(:str))
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|