;;;; uuid-lib-test.scm -*- Hen -*- (use test) (use uuid-ossp) ;Assumes the underlying library works so just the Scheme wrapper tested (test-group "Common API" (test-assert "uuid? " (uuid? (make-uuid))) (test-assert "uuid? V1" (uuid? (make-uuid 'V1))) (test-assert "uuid? V4" (uuid? (make-uuid 'V4))) (test-assert "uuid? time" (uuid? (make-uuid 'time))) (test-assert "uuid? random" (uuid? (make-uuid 'random))) (test-assert "uuid-null? 1" (not (uuid-null? (make-uuid 'V1)))) (test-assert "uuid-null? 2" (uuid-null? (make-uuid))) (test-assert "uuid-clear!" (uuid-null? (uuid-clear! (make-uuid 'V4)))) (let* ((tuuid (make-uuid 'V4)) (cuuid (uuid-copy tuuid)) ) (test-assert "uuid-copy =" (uuid=? tuuid cuuid)) (test-assert "uuid-copy !eq" (not (eq? tuuid cuuid))) ) (test-assert "A uuid is = & <= & >= to itself" (let ((tuuid (make-uuid 'random))) (and (uuid=? tuuid tuuid) (uuid<=? tuuid tuuid) (uuid>=? tuuid tuuid)))) (test-assert "A !null uuid is \"unique\"" (not (uuid=? (make-uuid 'V1) (make-uuid 'V1)))) (test-assert "A null uuid is not \"unique\"" (uuid=? (make-uuid) (make-uuid))) (test-assert "External form of uuid" (let ((tuuid (make-uuid 'V1))) (uuid=? tuuid (string->uuid (uuid->string tuuid))))) ) (test-group "Specific API" (test-assert "uuid? V1-MC" (uuid? (make-uuid 'V1-MC))) (test-assert "uuid? V3 \"ns:URL\"" (uuid? (make-uuid 'V3 "ns:URL" "foobarbaz"))) (test-assert "uuid? V5 \"ns:X500\"" (uuid? (make-uuid 'V5 "ns:X500" "foobarbaz"))) (test-assert "uuid-load" (uuid-nil? (uuid-load))) (let ((ns-url (uuid-load "ns:URL"))) (test-assert "uuid-load \"ns:URL\" 1" (uuid? ns-url)) (test-assert "uuid-load \"ns:URL\" 2" (not (uuid-nil? ns-url))) (test-assert "uuid? V3 url-uuid" (uuid? (make-uuid 'V3 ns-url "foobarbaz"))) ) (let* ((t1 (make-uuid)) (t2 (uuid-load! t1 "ns:OID")) ) (test-assert "uuid-load! overwrites 1" (not (uuid-nil? t1))) (test-assert "uuid-load! returns uuid" (eq? t1 t2)) ) (let ((t1 (make-uuid 'V3 "ns:URL" "foobarbaz"))) (test-assert "Export" (string? (uuid-export t1))) (test-assert "Export binary" (string? (uuid-export-binary t1))) (test-assert "Export siv" (string? (uuid-export-siv t1))) (test-assert "Export text" (string? (uuid-export-text t1))) ) (let ((t1 (make-uuid 'V3 "ns:URL" "foobarbaz"))) (test-assert "Import" (uuid=? t1 (uuid-import (uuid-export t1)))) (test-assert "Import binary" (uuid=? t1 (uuid-import-binary (uuid-export-binary t1)))) (test-assert "Import siv" (uuid=? t1 (uuid-import-siv (uuid-export-siv t1)))) ) (test-assert "uuid-version is number" (number? (uuid-version))) ) (test-exit)