source: project/release/4/uuid-ossp/trunk/tests/run.scm @ 21918

Last change on this file since 21918 was 21918, checked in by Kon Lovett, 9 years ago

Expanded the "common API" w/ uuid-lib. Rmvd uuid=, etc. (were dep in 1.3), Added "single integer value' external form support; could break on some systems with older OSSP library. Added uuid-load! Better error kinds. More comments.

Still needs the uuid-ossp-fix cut-out BS to deal with the system header conflict.

File size: 2.7 KB
Line 
1;;;; uuid-lib-test.scm  -*- Hen -*-
2
3(use test)
4(use uuid-ossp)
5
6;Assumes the underlying library works so just the Scheme wrapper tested
7
8(test-group "Common API"
9
10  (test-assert "uuid? <null>" (uuid? (make-uuid)))
11  (test-assert "uuid? V1" (uuid? (make-uuid 'V1)))
12  (test-assert "uuid? V4" (uuid? (make-uuid 'V4)))
13  (test-assert "uuid? time" (uuid? (make-uuid 'time)))
14  (test-assert "uuid? random" (uuid? (make-uuid 'random)))
15
16  (test-assert "uuid-null? 1" (not (uuid-null? (make-uuid 'V1))))
17  (test-assert "uuid-null? 2" (uuid-null? (make-uuid)))
18
19  (test-assert "uuid-clear!" (uuid-null? (uuid-clear! (make-uuid 'V4))))
20
21  (let* ((tuuid (make-uuid 'V4))
22         (cuuid (uuid-copy tuuid)) )
23    (test-assert "uuid-copy =" (uuid=? tuuid cuuid))
24    (test-assert "uuid-copy !eq" (not (eq? tuuid cuuid))) )
25
26  (test-assert "A uuid is = & <= & >= to itself"
27    (let ((tuuid (make-uuid 'random)))
28      (and (uuid=? tuuid tuuid) (uuid<=? tuuid tuuid) (uuid>=? tuuid tuuid))))
29
30  (test-assert "A !null uuid is \"unique\"" (not (uuid=? (make-uuid 'V1) (make-uuid 'V1))))
31  (test-assert "A null uuid is not \"unique\"" (uuid=? (make-uuid) (make-uuid)))
32
33  (test-assert "External form of uuid"
34    (let ((tuuid (make-uuid 'V1)))
35      (uuid=? tuuid (string->uuid (uuid->string tuuid)))))
36)
37
38(test-group "Specific API"
39
40  (test-assert "uuid? V1-MC" (uuid? (make-uuid 'V1-MC)))
41  (test-assert "uuid? V3 \"ns:URL\"" (uuid? (make-uuid 'V3 "ns:URL" "foobarbaz")))
42  (test-assert "uuid? V5 \"ns:X500\"" (uuid? (make-uuid 'V5 "ns:X500" "foobarbaz")))
43   
44  (test-assert "uuid-load" (uuid-nil? (uuid-load)))
45  (let ((ns-url (uuid-load "ns:URL")))
46    (test-assert "uuid-load \"ns:URL\" 1" (uuid? ns-url))
47    (test-assert "uuid-load \"ns:URL\" 2" (not (uuid-nil? ns-url)))
48    (test-assert "uuid? V3 url-uuid" (uuid? (make-uuid 'V3 ns-url "foobarbaz"))) )
49
50  (let* ((t1 (make-uuid))
51         (t2 (uuid-load! t1 "ns:OID")) )
52    (test-assert "uuid-load! overwrites 1" (not (uuid-nil? t1)))
53    (test-assert "uuid-load! returns uuid" (eq? t1 t2)) )
54
55  (let ((t1 (make-uuid 'V3 "ns:URL" "foobarbaz")))
56    (test-assert "Export" (string? (uuid-export t1)))
57    (test-assert "Export binary" (string? (uuid-export-binary t1)))
58    (test-assert "Export siv" (string? (uuid-export-siv t1)))
59    (test-assert "Export text" (string? (uuid-export-text t1))) )
60
61    (let ((t1 (make-uuid 'V3 "ns:URL" "foobarbaz")))
62      (test-assert "Import" (uuid=? t1 (uuid-import (uuid-export t1))))
63      (test-assert "Import binary"
64                   (uuid=? t1 (uuid-import-binary (uuid-export-binary t1))))
65      (test-assert "Import siv"
66                   (uuid=? t1 (uuid-import-siv (uuid-export-siv t1)))) )
67
68  (test-assert "uuid-version is number" (number? (uuid-version)))
69
70)
71
Note: See TracBrowser for help on using the repository browser.