aboutsummaryrefslogtreecommitdiff
path: root/test/guid_test.erl
blob: d98c853e55b7fbd6fb36b860972f4c2d1d2fb1f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)].