From 66726d08683dade09da62f5bbff83a27c662bd36 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Thu, 28 Sep 2023 09:40:44 -0700 Subject: [PATCH] feat: add component like error test --- test/errors/BUILD.bazel | 2 ++ test/errors/unknown_component_notify_settings.cc | 10 ++++++++++ .../errors/unknown_component_notify_settings.ecsact | 13 +++++++++++++ test/test_lib.hh | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/errors/unknown_component_notify_settings.cc create mode 100644 test/errors/unknown_component_notify_settings.ecsact diff --git a/test/errors/BUILD.bazel b/test/errors/BUILD.bazel index 765eeb8..5debf3a 100644 --- a/test/errors/BUILD.bazel +++ b/test/errors/BUILD.bazel @@ -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( diff --git a/test/errors/unknown_component_notify_settings.cc b/test/errors/unknown_component_notify_settings.cc new file mode 100644 index 0000000..77f3dcb --- /dev/null +++ b/test/errors/unknown_component_notify_settings.cc @@ -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); +} diff --git a/test/errors/unknown_component_notify_settings.ecsact b/test/errors/unknown_component_notify_settings.ecsact new file mode 100644 index 0000000..e938028 --- /dev/null +++ b/test/errors/unknown_component_notify_settings.ecsact @@ -0,0 +1,13 @@ +package error.unknown_notify_settings; + +component ExampleComponent { + i32 num; +} + +system UnknownComponentNotifySettings { + readwrite ExampleComponent; + + notify { + always NonExistentComponent; + } +} diff --git a/test/test_lib.hh b/test/test_lib.hh index 3f4fdd2..d3c7495 100644 --- a/test/test_lib.hh +++ b/test/test_lib.hh @@ -7,7 +7,7 @@ #include "ecsact/interpret/eval.hh" #include "bazel_sundry/runfiles.hh" -auto ecsact_interpret_test_files(std::vector relative_file_paths) +inline auto ecsact_interpret_test_files(std::vector relative_file_paths) -> std::vector { auto runfiles = bazel_sundry::CreateDefaultRunfiles(); [&] { ASSERT_TRUE(runfiles); }();