3 * Copyright (C) 2013-2015, 2017 Red Hat, Inc.
5 * This is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #undef G_DISABLE_ASSERT
28 test_guuid_string (void)
30 g_assert_false (g_uuid_string_is_valid ("00010203-0405-0607-0809"));
31 g_assert_false (g_uuid_string_is_valid ("zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"));
32 g_assert_false (g_uuid_string_is_valid ("000102030405060708090a0b0c0d0e0f"));
33 g_assert_false (g_uuid_string_is_valid ("{urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6}"));
34 g_assert_false (g_uuid_string_is_valid ("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"));
36 g_assert_true (g_uuid_string_is_valid ("00010203-0405-0607-0809-0a0b0c0d0e0f"));
37 g_assert_true (g_uuid_string_is_valid ("7d444840-9dc0-11d1-b245-5ffdce74fad2"));
38 g_assert_true (g_uuid_string_is_valid ("e902893a-9d22-3c7e-a7b8-d6e313b71d9f"));
39 g_assert_true (g_uuid_string_is_valid ("6ba7b810-9dad-11d1-80b4-00c04fd430c8"));
43 test_guuid_random (void)
47 str1
= g_uuid_string_random ();
48 g_assert_cmpuint (strlen (str1
), ==, 36);
49 g_assert_true (g_uuid_string_is_valid (str1
));
51 str2
= g_uuid_string_random ();
52 g_assert_cmpuint (strlen (str2
), ==, 36);
53 g_assert_true (g_uuid_string_is_valid (str2
));
54 g_assert_cmpstr (str1
, !=, str2
);
61 main (int argc
, char **argv
)
63 g_test_init (&argc
, &argv
, NULL
);
64 g_test_bug_base ("http://bugzilla.gnome.org/");
67 g_test_add_func ("/uuid/string", test_guuid_string
);
68 g_test_add_func ("/uuid/random", test_guuid_random
);