2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Lukasz Kostyra <l.kostyra@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
22 * @author Lukasz Kostyra (l.kostyra@samsung.com)
23 * @brief Unit tests of UID
29 #include "ipc/unique-id.hpp"
33 #include <uuid/uuid.h>
37 const std::string EMPTY_UUID = "00000000-0000-0000-0000-000000000000";
41 BOOST_AUTO_TEST_SUITE(UniqueIDSuite)
43 // constructor should provide empty timestamp and UUID
44 BOOST_AUTO_TEST_CASE(Constructor)
48 BOOST_CHECK_EQUAL(static_cast<std::int64_t>(uid.mTime.tv_sec), 0);
49 BOOST_CHECK_EQUAL(uid.mTime.tv_nsec, 0);
50 char uuid[37]; // 36 chars + terminating zero
51 ::uuid_unparse(uid.mUUID, uuid);
52 BOOST_CHECK(EMPTY_UUID.compare(uuid) == 0);
55 // generate one UID and compare with empty
56 BOOST_AUTO_TEST_CASE(Generate)
58 ipc::UniqueID uid, emptyuid;
61 BOOST_CHECK_NE(uid, emptyuid);
64 // generate two UIDs and compare them
65 BOOST_AUTO_TEST_CASE(DoubleGenerate)
67 ipc::UniqueID uid1, uid2;
71 BOOST_CHECK_NE(uid1, uid2);
74 // compare two empty UIDs
75 BOOST_AUTO_TEST_CASE(EmptyCompare)
77 ipc::UniqueID uid1, uid2;
79 BOOST_CHECK_EQUAL(uid1, uid2);
82 // pass empty UID to a stream
83 BOOST_AUTO_TEST_CASE(StreamOperator)
89 BOOST_CHECK_EQUAL(ss.str(), "0.0:" + EMPTY_UUID);
92 BOOST_AUTO_TEST_SUITE_END()