From e01cf1cc6d5d6379252309ffad6c816ea18b5d0a Mon Sep 17 00:00:00 2001 From: Dan Lentz Date: Tue, 15 Oct 2024 10:43:23 -0400 Subject: [PATCH] update all test ns to reference clj-uuid.core --- test/clj_uuid/api_test.clj | 4 ++-- test/clj_uuid/bitmop_test.clj | 21 ++++++++------------- test/clj_uuid/clock_test.clj | 18 +++++++++--------- test/clj_uuid/node_test.clj | 16 ++++++++-------- test/clj_uuid/v1_test.clj | 18 +++++++++--------- test/clj_uuid/v3_test.clj | 21 ++++++++++----------- test/clj_uuid/v4_test.clj | 15 +++++++-------- test/clj_uuid/v5_test.clj | 27 +++++++++++---------------- test/clj_uuid/v6_test.clj | 18 +++++++++--------- test/clj_uuid/v7_test.clj | 16 ++++++++-------- test/clj_uuid/v8_test.clj | 15 +++++++-------- 11 files changed, 88 insertions(+), 101 deletions(-) diff --git a/test/clj_uuid/api_test.clj b/test/clj_uuid/api_test.clj index df7b382..a59fc14 100644 --- a/test/clj_uuid/api_test.clj +++ b/test/clj_uuid/api_test.clj @@ -1,7 +1,7 @@ (ns clj-uuid.api-test (:refer-clojure :exclude [uuid? max]) - (:require [clojure.test :refer :all] - [clj-uuid :refer :all :exclude [= > <]]) + (:require [clj-uuid.core :refer :all :exclude [= > <]] + [clojure.test :refer :all]) (:import (java.lang IllegalArgumentException))) diff --git a/test/clj_uuid/bitmop_test.clj b/test/clj_uuid/bitmop_test.clj index 875ecf2..e559061 100644 --- a/test/clj_uuid/bitmop_test.clj +++ b/test/clj_uuid/bitmop_test.clj @@ -1,10 +1,8 @@ (ns clj-uuid.bitmop-test (:require - [clojure.test :refer :all] - [clj-uuid.bitmop :refer :all])) + [clj-uuid.bitmop :refer :all] + [clojure.test :refer :all])) - - (deftest check-bit-mask-operators (testing "bit-mask construction..." (is (= (mask 0 0) 0)) @@ -46,7 +44,7 @@ (is (= 32 (mask-width (mask 32 0)))) (is (= 31 (mask-width (mask 31 32)))) (is (= 62 (mask-width (mask 62 0)))) - (is (= 48 (mask-width (mask 48 15)))) + (is (= 48 (mask-width (mask 48 15)))) (is (= 64 (mask-width (mask 64 0)))) (is (= 60 (mask-width (mask 60 4)))) (is (= 31 (mask-width (mask 31 33)))) @@ -77,7 +75,7 @@ (for [i (range 0 61)] (is (= 15 (ldb (mask 4 i) (mask 64 0)))))) (testing "dpb..." - (map #(is (= 0x3 %)) + (map #(is (= 0x3 %)) (for [i (range 8)] (ldb (mask 4 (* i 4)) (dpb (mask 4 (* i 4)) (mask 64 0) 0x3)))) @@ -124,17 +122,17 @@ (is (= (ub4 -1) 15)) (is (= (ub4 16) 0)) (is (= (ub4 15) 15)) - (is (= (ub4 7) 7)) + (is (= (ub4 7) 7)) (is (= (ub56 0x80) 128)) (is (= (class (ub56 0x80)) Long)))) (deftest check-byte-reassembly-roundtrip - (testing "dissasemble/reassemble-bytes..." + (testing "dissasemble/reassemble-bytes..." (dotimes [_ 256] (let [bytes (for [i (range 8)] - (sb8 (rand-int (mask 8 0))))] + (sb8 (rand-int (mask 8 0))))] (is (= (seq (long->bytes (assemble-bytes bytes))) bytes)))))) @@ -142,7 +140,7 @@ (testing "octet-hex mapping..." (is (= (octet-hex 0xff) "FF")) (is (= (octet-hex 0x00) "00")) - (is (= (octet-hex 0x7a) "7A")) + (is (= (octet-hex 0x7a) "7A")) (is (= (octet-hex 15) "0F")) (is (= (octet-hex 45) "2D")) (is (= (octet-hex 250) "FA")) @@ -160,6 +158,3 @@ (is (= (hex 255) "00000000000000FF")) (is (= (hex 65536) "0000000000010000")) (is (= (hex -1) "FFFFFFFFFFFFFFFF")))) - - - diff --git a/test/clj_uuid/clock_test.clj b/test/clj_uuid/clock_test.clj index 77a3b3d..57104ad 100644 --- a/test/clj_uuid/clock_test.clj +++ b/test/clj_uuid/clock_test.clj @@ -1,7 +1,7 @@ (ns clj-uuid.clock-test - (:require [clojure.test :refer :all] - [clojure.set] - [clj-uuid.clock :refer :all])) + (:require [clj-uuid.clock :as clock] + [clojure.set :as set] + [clojure.test :refer :all])) (deftest check-single-threaded (let [iterations 1000000 @@ -9,11 +9,11 @@ check #(mapv (fn [_] (%)) (range iterations))] (testing "monotonic-time..." (dotimes [_ groups] - (let [result (check monotonic-time)] + (let [result (check clock/monotonic-time)] (is (= (count result) (count (set result))))))) (testing "monotonic-unix-time-and-random-counter..." (dotimes [_ groups] - (let [result (check monotonic-unix-time-and-random-counter)] + (let [result (check clock/monotonic-unix-time-and-random-counter)] (is (= (count result) (count (set result))))))))) (deftest check-multi-threaded-monotonic-time @@ -22,13 +22,13 @@ agents (mapv agent (repeat concur nil)) working (mapv #(send-off % (fn [state] - (repeatedly extent monotonic-time))) + (repeatedly extent clock/monotonic-time))) agents) _ (apply await working) answers (mapv deref working)] (testing (str "concurrent timestamp uniqueness (" concur " threads)...") (is (= (* concur extent) - (count (apply clojure.set/union (map set answers)))))) + (count (apply set/union (map set answers)))))) (testing (str "concurrent monotonic increasing (" concur " threads)...") (is (every? identity (map #(apply < %) answers))))))) @@ -40,14 +40,14 @@ working (mapv #(send-off % (fn [state] (repeatedly extent - monotonic-unix-time-and-random-counter))) + clock/monotonic-unix-time-and-random-counter))) agents) _ (apply await working) answers (mapv deref working)] (testing (str "concurrent timestamp uniqueness (" concur " threads)...") (is (= (* concur extent) - (count (apply clojure.set/union (map set answers)))))) + (count (apply set/union (map set answers)))))) (testing (str "concurrent monotonic increasing (" concur " threads)...") (doseq [answer answers] (let [[time counter] (first answer)] diff --git a/test/clj_uuid/node_test.clj b/test/clj_uuid/node_test.clj index eb3fa64..ffa36d5 100644 --- a/test/clj_uuid/node_test.clj +++ b/test/clj_uuid/node_test.clj @@ -1,13 +1,13 @@ (ns clj-uuid.node-test - (:require [clojure.test :refer :all] - [clj-uuid.node :refer :all])) + (:require [clj-uuid.node :as node] + [clojure.test :refer :all])) (deftest check-node-id (testing "existance and type of node id...") - (is (= (node-id) (node-id))) - (is (coll? (node-id))) - (is (= 6 (count (node-id)))) - (is (every? number? (node-id))) - (is (= 1 (bit-and 0x01 @+node-id+))) - (is (instance? Long @+node-id+))) + (is (= (node/node-id) (node/node-id))) + (is (coll? (node/node-id))) + (is (= 6 (count (node/node-id)))) + (is (every? number? (node/node-id))) + (is (= 1 (bit-and 0x01 @node/+node-id+))) + (is (instance? Long @node/+node-id+))) diff --git a/test/clj_uuid/v1_test.clj b/test/clj_uuid/v1_test.clj index af36685..391a093 100644 --- a/test/clj_uuid/v1_test.clj +++ b/test/clj_uuid/v1_test.clj @@ -1,16 +1,16 @@ (ns clj-uuid.v1-test "Time based UUIDs tests" - (:require [clojure.test :refer :all] - [clojure.set] - [clj-uuid :as uuid :refer [v1 get-timestamp]] - [clj-uuid.clock :as clock])) + (:require [clj-uuid.clock :as clock] + [clj-uuid.core :as uuid] + [clojure.set :as set] + [clojure.test :refer :all])) (deftest check-v1-single-threaded (let [iterations 1000000 groups 10] (testing "single-thread v1 uuid uniqueness..." (dotimes [_ groups] - (let [result (repeatedly iterations v1)] + (let [result (repeatedly iterations uuid/v1)] (is (= (count result) (count (set result))))))))) (deftest check-v1-concurrency @@ -19,19 +19,19 @@ agents (map agent (repeat concur nil)) working (map #(send-off % (fn [state] - (repeatedly extent v1))) + (repeatedly extent uuid/v1))) agents) _ (apply await working) answers (map deref working)] (testing (str "concurrent v1 uuid uniqueness (" concur " threads)...") (is (= (* concur extent) - (count (apply clojure.set/union (map set answers)))))) + (count (apply set/union (map set answers)))))) (testing (str "concurrent v1 monotonic increasing (" concur " threads)...") (is (every? identity - (map #(apply < (map get-timestamp %)) answers))))))) + (map #(apply < (map uuid/get-timestamp %)) answers))))))) (deftest check-get-timestamp (let [time (clock/monotonic-time)] (with-redefs [clock/monotonic-time (constantly time)] - (is (= time (uuid/get-timestamp (v1))) + (is (= time (uuid/get-timestamp (uuid/v1))) "Timestamp should be retrievable from v1 UUID")))) diff --git a/test/clj_uuid/v3_test.clj b/test/clj_uuid/v3_test.clj index 0601ce2..67345ac 100644 --- a/test/clj_uuid/v3_test.clj +++ b/test/clj_uuid/v3_test.clj @@ -1,25 +1,24 @@ (ns clj-uuid.v3-test - (:refer-clojure :exclude [uuid? max]) - (:require [clojure.test :refer :all] - [clj-uuid :refer :all :exclude [> < =]])) + (:require [clj-uuid.core :as uuid] + [clojure.test :refer :all])) (deftest check-v3-special-cases (testing "v3 special case correctness..." (is (= - (v3 +null+ "") + (uuid/v3 uuid/+null+ "") #uuid "4ae71336-e44b-39bf-b9d2-752e234818a5")) (is (= - (v3 +namespace-x500+ "") + (uuid/v3 uuid/+namespace-x500+ "") #uuid "7AAF118C-F174-3EBA-9EC5-680CD791A020")) (is (= - (v3 +namespace-oid+ "") + (uuid/v3 uuid/+namespace-oid+ "") #uuid "596B79DC-00DD-3991-A72F-D3696C38C64F")) (is (= - (v3 +namespace-dns+ "") + (uuid/v3 uuid/+namespace-dns+ "") #uuid "C87EE674-4DDC-3EFE-A74E-DFE25DA5D7B3")) (is (= - (v3 +namespace-url+ "") + (uuid/v3 uuid/+namespace-url+ "") #uuid "14CDB9B4-DE01-3FAA-AFF5-65BC2F771745")))) @@ -125,7 +124,7 @@ (deftest check-v3-null-ns-cases (testing "v3 null-ns case-based correctness..." (doseq [case +v3-null-ns-cases+] - (is (= (second case) (v3 +null+ (first case))))))) + (is (= (second case) (uuid/v3 uuid/+null+ (first case))))))) (def +v3-dns-ns-cases+ @@ -230,7 +229,7 @@ (deftest check-v3-dns-ns-cases (testing "v3 dns-ns case-based correctness..." (doseq [case +v3-dns-ns-cases+] - (is (= (second case) (v3 +namespace-dns+ (first case))))))) + (is (= (second case) (uuid/v3 uuid/+namespace-dns+ (first case))))))) (def +v3-oid-ns-cases+ @@ -335,4 +334,4 @@ (deftest check-v3-oid-ns-cases (testing "v3 oid-ns case-based correctness..." (doseq [case +v3-oid-ns-cases+] - (is (= (second case) (v3 +namespace-oid+ (first case))))))) + (is (= (second case) (uuid/v3 uuid/+namespace-oid+ (first case))))))) diff --git a/test/clj_uuid/v4_test.clj b/test/clj_uuid/v4_test.clj index e527310..ade0a13 100644 --- a/test/clj_uuid/v4_test.clj +++ b/test/clj_uuid/v4_test.clj @@ -1,13 +1,12 @@ (ns clj-uuid.v4-test "Custom UUIDs tests" - (:refer-clojure :exclude [uuid? max]) - (:require [clojure.test :refer :all] - [clj-uuid :refer :all :exclude [> < =]])) + (:require [clj-uuid.core :as uuid] + [clojure.test :refer :all])) (deftest check-v4-special-cases (testing "v4 special case correctness..." - (is (= (v4 0 0) #uuid "00000000-0000-4000-8000-000000000000")) - (is (= (v4 0 1) #uuid "00000000-0000-4000-8000-000000000001")) - (is (= (v4 0 -1) #uuid "00000000-0000-4000-bfff-ffffffffffff")) - (is (= (v4 -1 0) #uuid "ffffffff-ffff-4fff-8000-000000000000")) - (is (= (v4 -1 -1) #uuid "ffffffff-ffff-4fff-bfff-ffffffffffff")))) + (is (= (uuid/v4 0 0) #uuid "00000000-0000-4000-8000-000000000000")) + (is (= (uuid/v4 0 1) #uuid "00000000-0000-4000-8000-000000000001")) + (is (= (uuid/v4 0 -1) #uuid "00000000-0000-4000-bfff-ffffffffffff")) + (is (= (uuid/v4 -1 0) #uuid "ffffffff-ffff-4fff-8000-000000000000")) + (is (= (uuid/v4 -1 -1) #uuid "ffffffff-ffff-4fff-bfff-ffffffffffff")))) diff --git a/test/clj_uuid/v5_test.clj b/test/clj_uuid/v5_test.clj index 153fb82..ae0180a 100644 --- a/test/clj_uuid/v5_test.clj +++ b/test/clj_uuid/v5_test.clj @@ -1,26 +1,23 @@ (ns clj-uuid.v5-test - (:refer-clojure :exclude [uuid? max]) - (:require [clojure.test :refer :all] - [clj-uuid :refer :all :exclude [> < =]])) - - + (:require [clj-uuid.core :as uuid] + [clojure.test :refer :all])) (deftest check-v5-special-cases (testing "v5 special case correctness..." (is (= - (v5 +null+ "") + (uuid/v5 uuid/+null+ "") #uuid "E129F27C-5103-5C5C-844B-CDF0A15E160D")) (is (= - (v5 +namespace-x500+ "") + (uuid/v5 uuid/+namespace-x500+ "") #uuid "B4BDF874-8C03-5BD8-8FD7-5E409DFD82C0")) (is (= - (v5 +namespace-oid+ "") + (uuid/v5 uuid/+namespace-oid+ "") #uuid "0A68EB57-C88A-5F34-9E9D-27F85E68AF4F")) (is (= - (v5 +namespace-dns+ "") + (uuid/v5 uuid/+namespace-dns+ "") #uuid "4EBD0208-8328-5D69-8C44-EC50939C0967")) (is (= - (v5 +namespace-url+ "") + (uuid/v5 uuid/+namespace-url+ "") #uuid "1B4DB7EB-4057-5DDF-91E0-36DEC72071F5")))) (def +v5-null-ns-cases+ @@ -118,15 +115,13 @@ ("{|}~ !\"#$%&'()*+,-./012345" #uuid "37CDD9D8-A94F-5BB5-AA57-97A92ACA22FC") ("|}~ !\"#$%&'()*+,-./0123456" #uuid "BB23D8C2-29F0-5EC5-BF50-B7092FA62204") ("}~ !\"#$%&'()*+,-./01234567" #uuid "AD3AD027-A2ED-5F09-B581-78AD87D86A7C") - ("~ !\"#$%&'()*+,-./012345678" #uuid "093B7461-98EF-55DC-8616-890210247499") - )) + ("~ !\"#$%&'()*+,-./012345678" #uuid "093B7461-98EF-55DC-8616-890210247499"))) (deftest check-v5-null-ns-cases (testing "v5 null-ns case-based correctness..." (doseq [case +v5-null-ns-cases+] - (is (= (second case) (v5 +null+ (first case))))))) - + (is (= (second case) (uuid/v5 uuid/+null+ (first case))))))) (def +v5-dns-ns-cases+ @@ -231,7 +226,7 @@ (deftest check-v5-dns-ns-cases (testing "v5 dns-ns case-based correctness..." (doseq [case +v5-dns-ns-cases+] - (is (= (second case) (v5 +namespace-dns+ (first case))))))) + (is (= (second case) (uuid/v5 uuid/+namespace-dns+ (first case))))))) (def +v5-oid-ns-cases+ @@ -336,4 +331,4 @@ (deftest check-v5-oid-ns-cases (testing "v5 oid-ns case-based correctness..." (doseq [case +v5-oid-ns-cases+] - (is (= (second case) (v5 +namespace-oid+ (first case))))))) + (is (= (second case) (uuid/v5 uuid/+namespace-oid+ (first case))))))) diff --git a/test/clj_uuid/v6_test.clj b/test/clj_uuid/v6_test.clj index 85bb308..132b938 100644 --- a/test/clj_uuid/v6_test.clj +++ b/test/clj_uuid/v6_test.clj @@ -1,16 +1,16 @@ (ns clj-uuid.v6-test - "Time based UUIDs tests" - (:require [clojure.test :refer :all] - [clojure.set] - [clj-uuid :as uuid :refer [v6 get-timestamp]] - [clj-uuid.clock :as clock])) + "Time based UUID tests" + (:require [clj-uuid.clock :as clock] + [clj-uuid.core :as uuid] + [clojure.set :as set] + [clojure.test :refer :all])) (deftest check-v6-single-threaded (let [iterations 1000000 groups 10] (testing "single-thread v6 uuid uniqueness..." (dotimes [_ groups] - (let [result (repeatedly iterations v6)] + (let [result (repeatedly iterations uuid/v6)] (is (= (count result) (count (set result))))))))) (deftest check-v6-concurrency @@ -19,13 +19,13 @@ agents (map agent (repeat concur nil)) working (map #(send-off % (fn [state] - (repeatedly extent v6))) + (repeatedly extent uuid/v6))) agents) _ (apply await working) answers (map deref working)] (testing (str "concurrent v6 uuid uniqueness (" concur " threads)...") (is (= (* concur extent) - (count (apply clojure.set/union (map set answers)))))) + (count (apply set/union (map set answers)))))) (testing (str "concurrent v6 monotonic increasing (" concur " threads)...") (is (every? identity (map (partial apply uuid/<) answers))))))) @@ -33,5 +33,5 @@ (dotimes [_ 1000000] (let [time (clock/monotonic-time)] (with-redefs [clock/monotonic-time (constantly time)] - (is (= time (uuid/get-timestamp (v6))) + (is (= time (uuid/get-timestamp (uuid/v6))) "Timestamp should be retrievable from v6 UUID"))))) diff --git a/test/clj_uuid/v7_test.clj b/test/clj_uuid/v7_test.clj index 286fd71..914916d 100644 --- a/test/clj_uuid/v7_test.clj +++ b/test/clj_uuid/v7_test.clj @@ -1,15 +1,15 @@ (ns clj-uuid.v7-test - (:require [clojure.test :refer :all] - [clojure.set] - [clj-uuid :as uuid :refer [v7]] - [clj-uuid.clock :as clock])) + (:require [clj-uuid.clock :as clock] + [clj-uuid.core :as uuid] + [clojure.set :as set] + [clojure.test :refer :all])) (deftest check-v7-single-threaded (let [iterations 1000000 groups 10] (testing "single-thread v7 uuid uniqueness..." (dotimes [_ groups] - (let [result (repeatedly iterations v7)] + (let [result (repeatedly iterations uuid/v7)] (is (= (count result) (count (set result))))))))) (deftest check-v7-concurrency @@ -18,13 +18,13 @@ agents (map agent (repeat concur nil)) working (map #(send-off % (fn [state] - (repeatedly extent v7))) + (repeatedly extent uuid/v7))) agents) _ (apply await working) answers (map deref working)] (testing (str "concurrent v7 uuid uniqueness (" concur " threads)...") (is (= (* concur extent) - (count (apply clojure.set/union (map set answers)))))) + (count (apply set/union (map set answers)))))) (testing (str "concurrent v7 monotonic increasing (" concur " threads)...") (is (every? identity @@ -34,5 +34,5 @@ (dotimes [_ 1000000] (let [time (first (clock/monotonic-unix-time-and-random-counter))] (with-redefs [clock/monotonic-unix-time-and-random-counter (constantly [time (rand-int 4095)])] - (is (= time (uuid/get-timestamp (v7))) + (is (= time (uuid/get-timestamp (uuid/v7))) "Timestamp should be retrievable from v7 UUID"))))) diff --git a/test/clj_uuid/v8_test.clj b/test/clj_uuid/v8_test.clj index 6fe3fd7..77f5994 100644 --- a/test/clj_uuid/v8_test.clj +++ b/test/clj_uuid/v8_test.clj @@ -1,13 +1,12 @@ (ns clj-uuid.v8-test "Custom UUIDs tests" - (:refer-clojure :exclude [uuid? max]) - (:require [clojure.test :refer :all] - [clj-uuid :refer :all :exclude [> < =]])) + (:require [clj-uuid.core :as uuid] + [clojure.test :refer :all])) (deftest check-v8-special-cases (testing "v8 custom UUID" - (is (= (v8 0 0) #uuid "00000000-0000-8000-8000-000000000000")) - (is (= (v8 0 1) #uuid "00000000-0000-8000-8000-000000000001")) - (is (= (v8 0 -1) #uuid "00000000-0000-8000-bfff-ffffffffffff")) - (is (= (v8 -1 0) #uuid "ffffffff-ffff-8fff-8000-000000000000")) - (is (= (v8 -1 -1) #uuid "ffffffff-ffff-8fff-bfff-ffffffffffff")))) + (is (= (uuid/v8 0 0) #uuid "00000000-0000-8000-8000-000000000000")) + (is (= (uuid/v8 0 1) #uuid "00000000-0000-8000-8000-000000000001")) + (is (= (uuid/v8 0 -1) #uuid "00000000-0000-8000-bfff-ffffffffffff")) + (is (= (uuid/v8 -1 0) #uuid "ffffffff-ffff-8fff-8000-000000000000")) + (is (= (uuid/v8 -1 -1) #uuid "ffffffff-ffff-8fff-bfff-ffffffffffff"))))