-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing out capabilities count assignment (#229)
- Loading branch information
Showing
6 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "ecsact/runtime/meta.hh" | ||
#include "ecsact/runtime/dynamic.h" | ||
#include "test_lib.hh" | ||
|
||
using ecsact::meta::get_field_type; | ||
|
||
class AssocCapabilities : public testing::Test { | ||
public: | ||
ecsact_package_id pkg_id; | ||
|
||
protected: | ||
void SetUp() override { | ||
auto errs = ecsact_interpret_test_files({"assoc_capabilities.ecsact"}); | ||
ASSERT_EQ(errs.size(), 0) // | ||
<< "Expected no errors. Instead got: " << errs[0].error_message << "\n"; | ||
pkg_id = ecsact::meta::get_package_ids().at(0); | ||
} | ||
|
||
void TearDown() override { | ||
// ecsact_destroy_package(pkg_id); | ||
} | ||
}; | ||
|
||
TEST_F(AssocCapabilities, GeneralReads) { | ||
auto example_comp = get_component_by_name(pkg_id, "Example"); | ||
ASSERT_TRUE(example_comp); | ||
|
||
auto comp = get_component_by_name(pkg_id, "AssocComp"); | ||
ASSERT_TRUE(comp); | ||
|
||
auto sys = get_system_by_name(pkg_id, "ReadwriteSystem"); | ||
auto assoc_ids = ecsact::meta::system_assoc_ids(*sys); | ||
ASSERT_EQ(assoc_ids.size(), 1); | ||
|
||
auto caps = ecsact::meta::system_assoc_capabilities(*sys, assoc_ids.at(0)); | ||
ASSERT_EQ(caps.size(), 1); | ||
|
||
ASSERT_EQ( | ||
caps.at(0).first, | ||
ecsact_id_cast<ecsact_component_like_id>(*example_comp) | ||
); | ||
ASSERT_EQ(caps.at(0).second, ECSACT_SYS_CAP_READWRITE); | ||
} | ||
|
||
TEST_F(AssocCapabilities, RemovesExists) { | ||
auto example_comp = get_component_by_name(pkg_id, "Example"); | ||
ASSERT_TRUE(example_comp); | ||
|
||
auto tag_comp = get_component_by_name(pkg_id, "MyTag"); | ||
ASSERT_TRUE(tag_comp); | ||
|
||
auto comp = get_component_by_name(pkg_id, "AssocComp"); | ||
ASSERT_TRUE(comp); | ||
|
||
auto sys = get_system_by_name(pkg_id, "RemovesSystem"); | ||
auto assoc_ids = ecsact::meta::system_assoc_ids(*sys); | ||
ASSERT_EQ(assoc_ids.size(), 1); | ||
|
||
auto assoc_caps = | ||
ecsact::meta::system_assoc_capabilities(*sys, assoc_ids.at(0)); | ||
|
||
// order isn't guaranteed | ||
for(auto&& [comp_id, caps] : assoc_caps) { | ||
if(comp_id == ecsact_id_cast<ecsact_component_like_id>(*tag_comp)) { | ||
ASSERT_EQ(caps, ECSACT_SYS_CAP_INCLUDE); | ||
} else if(comp_id == | ||
ecsact_id_cast<ecsact_component_like_id>(*example_comp)) { | ||
ASSERT_EQ(caps, ECSACT_SYS_CAP_REMOVES); | ||
} else { | ||
ASSERT_TRUE(false) << "unknown comp id"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package eval.assoc_capabilities; | ||
|
||
component MyTag; | ||
component Example { i32 num; } | ||
component AssocComp { Example.num hello; } | ||
|
||
system ReadwriteSystem { | ||
readwrite AssocComp with hello { | ||
readwrite Example; | ||
} | ||
} | ||
|
||
system RemovesSystem { | ||
readwrite AssocComp with hello { | ||
include MyTag; | ||
removes Example; | ||
} | ||
} | ||
|