aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/guid_test.erl29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/guid_test.erl b/test/guid_test.erl
new file mode 100644
index 0000000..d98c853
--- /dev/null
+++ b/test/guid_test.erl
@@ -0,0 +1,29 @@
+-module(guid_test).
+-include_lib("eunit/include/eunit.hrl").
+
+% Test descriptions
+v4_test_() ->
+ [{"A v4 uuid must have version 4",
+ check_v4_version()},
+ {"A uuid must be 16 bytes",
+ check_v4_length()}
+ ].
+
+text_test_() ->
+ [{"The text representation must be 38 characters long",
+ check_v4_string_length()}
+ ].
+
+% Tests
+check_v4_version() ->
+ Uuid = guid:v4(),
+ [?_assertEqual(guid:version(Uuid), 4)].
+
+
+check_v4_length() ->
+ Uuid = guid:v4(),
+ [?_assertEqual(byte_size(Uuid), 16)].
+
+check_v4_string_length() ->
+ String = guid:v4string(),
+ [?_assertEqual(length(String), 36)].