Added test case for common::id_t
This commit is contained in:
@@ -84,6 +84,7 @@ if(APPLE)
|
|||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
set(TEST_NAMES
|
set(TEST_NAMES
|
||||||
|
test_types
|
||||||
test_util
|
test_util
|
||||||
test_model
|
test_model
|
||||||
test_cases
|
test_cases
|
||||||
|
|||||||
43
tests/test_types.cc
Normal file
43
tests/test_types.cc
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @file tests/test_types.cc
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
|
||||||
|
#include "common/types.h"
|
||||||
|
|
||||||
|
#include "doctest/doctest.h"
|
||||||
|
|
||||||
|
TEST_CASE("Test common::id_t")
|
||||||
|
{
|
||||||
|
using namespace clanguml;
|
||||||
|
|
||||||
|
common::id_t empty{};
|
||||||
|
|
||||||
|
REQUIRE(empty.is_global());
|
||||||
|
REQUIRE_EQ(empty.value(), 0);
|
||||||
|
|
||||||
|
common::id_t local_id{(int64_t)100};
|
||||||
|
REQUIRE_EQ(local_id.ast_local_value(), 100);
|
||||||
|
REQUIRE_EQ(local_id.value(), 100);
|
||||||
|
REQUIRE(!local_id.is_global());
|
||||||
|
|
||||||
|
common::id_t global_id{(uint64_t)100};
|
||||||
|
REQUIRE_EQ(global_id.value(), 100);
|
||||||
|
REQUIRE(global_id.is_global());
|
||||||
|
|
||||||
|
REQUIRE(local_id != global_id);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user