Skip to content

Commit

Permalink
feat: add component like error test
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Sep 28, 2023
1 parent 13705b3 commit 66726d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/errors/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@ecsact_interpret//bazel:copts.bzl", "copts")

# buildifier: keep sorted
_TESTS = [
"invalid_notify_settings",
"no_capabilities",
"no_package_statement_first",
"unknown_association_field",
"unknown_component_notify_settings",
]

[cc_test(
Expand Down
10 changes: 10 additions & 0 deletions test/errors/unknown_component_notify_settings.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "gtest/gtest.h"
#include "ecsact/interpret/eval.h"

#include "test_lib.hh"

TEST(UnknownComponentNotifySettings, UnknownComponentNotifySettings) {
auto errs = ecsact_interpret_test_files({"errors/unknown_component_notify_settings.ecsact"});
ASSERT_EQ(errs.size(), 1);
ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_UNKNOWN_COMPONENT_LIKE_TYPE);
}
13 changes: 13 additions & 0 deletions test/errors/unknown_component_notify_settings.ecsact
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package error.unknown_notify_settings;

component ExampleComponent {
i32 num;
}

system UnknownComponentNotifySettings {
readwrite ExampleComponent;

notify {
always NonExistentComponent;
}
}
2 changes: 1 addition & 1 deletion test/test_lib.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "ecsact/interpret/eval.hh"
#include "bazel_sundry/runfiles.hh"

auto ecsact_interpret_test_files(std::vector<std::string> relative_file_paths)
inline auto ecsact_interpret_test_files(std::vector<std::string> relative_file_paths)
-> std::vector<ecsact::parse_eval_error> {
auto runfiles = bazel_sundry::CreateDefaultRunfiles();
[&] { ASSERT_TRUE(runfiles); }();
Expand Down

0 comments on commit 66726d0

Please sign in to comment.