Skip to content

Commit

Permalink
Add meta context tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 19, 2024
1 parent 8f3e414 commit 1d798ef
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target_sources(tactile-core-test
"src/map/map_test.cpp"
"src/meta/attribute_type_test.cpp"
"src/meta/color_test.cpp"
"src/meta/meta_test.cpp"
"src/model/settings_test.cpp"
"src/numeric/random_test.cpp"
"src/platform/bits_test.cpp"
Expand Down
41 changes: 41 additions & 0 deletions source/core/test/src/meta/meta_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#include "tactile/core/meta/meta.hpp"

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "tactile/base/test_util/ir_presets.hpp"
#include "tactile/core/entity/registry.hpp"
#include "tactile/core/test/ir_comparison.hpp"

namespace tactile::test {

// tactile::is_meta
TEST(Meta, IsMeta)
{
Registry registry {};

const auto meta_id = registry.make_entity();
registry.add<CMeta>(meta_id);

EXPECT_FALSE(is_meta(registry, kInvalidEntity));
EXPECT_FALSE(is_meta(registry, registry.make_entity()));
EXPECT_TRUE(is_meta(registry, meta_id));
}

// tactile::convert_ir_metadata
TEST(Meta, ConvertIrMetadata)
{
Registry registry {};

const auto meta_id = registry.make_entity();
registry.add<CMeta>(meta_id);

const auto ir_metadata = make_complex_ir_metadata("Meta");
convert_ir_metadata(registry, meta_id, ir_metadata);

compare_meta(registry, meta_id, ir_metadata);
}

} // namespace tactile::test

0 comments on commit 1d798ef

Please sign in to comment.