You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
#include "translate/builtin_ctx.hpp"
|
|
|
|
#include "libshit/doctest.hpp"
|
|
|
|
namespace Libshit::Translate::Test
|
|
{
|
|
TEST_SUITE_BEGIN("Libshit::Translate::Builtin");
|
|
|
|
TEST_CASE("Builtin")
|
|
{
|
|
BuiltinContext ctx;
|
|
SUBCASE("normal check")
|
|
{
|
|
CHECK(ctx->menu->new_game()->ToString() == "New Game");
|
|
CHECK(ctx->test->fmt(1)->ToString() == "Delete 1 file?");
|
|
CHECK(ctx->test->fmt(5)->ToString() == "Delete 5 files?");
|
|
|
|
CHECK(ctx->test->macro()->ToString() == "Test defbar");
|
|
CHECK(ctx->test->types(3, "foo", 1.13)->ToString() == "3 foo 1.13");
|
|
|
|
CHECK(ctx->test->get_foo(ctx->test->foo())->ToString() == "Foo Case");
|
|
CHECK(ctx->test->get_asd(ctx->test->foo())->ToString() == "No Case");
|
|
|
|
CHECK(ctx->test->gender_format(ctx->test->gender())->ToString() == "c");
|
|
CHECK(ctx->test->gender_format("")->ToString() == "a");
|
|
|
|
// reflective inteface still works
|
|
CHECK(ctx["test"]["fmt"](4)->ToString() == "Delete 4 files?");
|
|
}
|
|
|
|
#if LIBSHIT_TRANSLATE_YAML
|
|
SUBCASE("load new yml")
|
|
{
|
|
std::stringstream ss{R"(
|
|
...
|
|
menu:
|
|
new_game: 新しいゲーム
|
|
load: ${foo nope}
|
|
)"};
|
|
ctx.Load(ss);
|
|
|
|
CHECK(ctx->menu->new_game()->ToString() == "新しいゲーム");
|
|
CHECK(ctx->menu->load()->ToString() == "defnope");
|
|
}
|
|
|
|
SUBCASE("load invalid yml")
|
|
{
|
|
std::stringstream ss{R"(
|
|
...
|
|
test:
|
|
types: $STRING $STRING
|
|
)"};
|
|
CHECK_THROWS(ctx.Load(ss));
|
|
}
|
|
#endif
|
|
}
|
|
|
|
TEST_SUITE_END();
|
|
}
|