Fawkes API Fawkes Development Version
test_uuid.cpp
1/***************************************************************************
2 * test_uuid.cpp -
3 *
4 * Created: Tue 17 Nov 2020 15:09:33 CET 15:09
5 * Copyright 2020 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#include <utils/uuid.h>
22
23#include <catch2/catch.hpp>
24
25using fawkes::Uuid;
26
27TEST_CASE("Generate UUID", "[uuid]")
28{
29 Uuid uuid1;
30 REQUIRE(uuid1.get_string() != "");
31}
32
33TEST_CASE("UUIDs are unique", "[uuid]")
34{
35 Uuid uuid1;
36 Uuid uuid2;
37 REQUIRE(uuid1 != uuid2);
38}
39
40TEST_CASE("Copy constructor", "[uuid]")
41{
42 Uuid uuid1;
43 Uuid uuid2(uuid1);
44 REQUIRE(uuid1 == uuid2);
45}
46
47TEST_CASE("Move constructor", "[uuid]")
48{
49 Uuid uuid1;
50 std::string uuid_string = uuid1.get_string();
51 Uuid uuid2{std::move(uuid1)};
52 REQUIRE(uuid2.get_string() == uuid_string);
53}
54
55TEST_CASE("Create from string", "[uuid]")
56{
57 Uuid uuid1;
58 Uuid uuid2{uuid1.get_string().c_str()};
59 REQUIRE(uuid1 == uuid2);
60}
61
62TEST_CASE("Copy assignment", "[uuid]")
63{
64 Uuid uuid1;
65 Uuid uuid2;
66 uuid2 = uuid1;
67 REQUIRE(uuid1 == uuid2);
68}
69
70TEST_CASE("Move assignment", "[uuid]")
71{
72 Uuid uuid1;
73 Uuid uuid2;
74 std::string uuid_string = uuid1.get_string();
75 uuid2 = std::move(uuid1);
76 REQUIRE(uuid2.get_string() == uuid_string);
77}
A convenience class for universally unique identifiers (UUIDs).
Definition: uuid.h:29
std::string get_string() const
Get the string representation of the Uuid.
Definition: uuid.cpp:107