// Copyright (C) 2022 TiltedPhoques SRL. // For licensing information see LICENSE at the root of this distribution. #include #include #include #include namespace Console { namespace { class ConsoleRegistryTest : public ::testing::Test { public: void SetUp() override; void TearDown() override; private: }; void ConsoleRegistryTest::SetUp() { spdlog::stdout_color_mt("Test"); } void ConsoleRegistryTest::TearDown() { spdlog::drop("Test"); } TEST_F(ConsoleRegistryTest, RegisterCommand) { // "static" command static Command sc{ "test0", "desc", [&](ArgStack& stack) { EXPECT_EQ(stack.Pop(), 7); }}; // "static" setting static Setting ss{"test0", "", true, SettingsFlags::kLocked}; auto r{std::make_unique("Test")}; r->RegisterCommand( "name", "description", [&](ArgStack& stack) { EXPECT_TRUE(stack.Pop()); EXPECT_FALSE(stack.Pop()); }); ASSERT_TRUE(r->FindCommand("name")); r->TryExecuteCommand("/name true false"); r->TryExecuteCommand("/test0 7"); r->TryExecuteCommand("/test0 10 10 10"); r->TryExecuteCommand("/test0 true"); r->RegisterSetting("name", "desc", false); ASSERT_TRUE(r->FindSetting("name")); ASSERT_TRUE(r->FindSetting("test0")); // FAIL r->TryExecuteCommand("test0 7"); r->TryExecuteCommand("/test \xe2\x28\xa1"); r->Update(); } TEST_F(ConsoleRegistryTest, RegisterSetting) { // ConsoleRegistry r("Test"); // r.RegisterSetting("name", "desc", false); // ASSERT_TRUE(r.FindSetting("name")); } } // namespace } // namespace Console