Add unit test for menu item origin

This commit is contained in:
Jan 2023-12-25 19:52:20 +01:00
parent f5c987ce59
commit 1b5d6f7439
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C

View File

@ -190,6 +190,37 @@ namespace test::parsing::menu::sequence::item
REQUIRE(item->m_rect.verticalAlign == 2);
}
TEST_CASE("ItemScopeSequences: Can specify origin", "[parsing][sequence][menu]")
{
ItemSequenceTestsHelper helper(FeatureLevel::IW4, false);
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Identifier(pos, new std::string("origin")),
SimpleParserValue::FloatingPoint(pos, 4.20),
SimpleParserValue::Character(pos, '('),
SimpleParserValue::FloatingPoint(pos, 11.37),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::FloatingPoint(pos, 2.0),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::EndOfFile(pos),
});
const auto result = helper.PerformTest();
REQUIRE(result);
REQUIRE(helper.m_consumed_token_count == 7);
const auto* item = helper.m_state->m_current_item;
REQUIRE(item);
REQUIRE_THAT(item->m_rect.x, WithinRel(4.20));
REQUIRE_THAT(item->m_rect.y, WithinRel(13.37));
REQUIRE_THAT(item->m_rect.w, WithinRel(0.0));
REQUIRE_THAT(item->m_rect.h, WithinRel(0.0));
REQUIRE(item->m_rect.horizontalAlign == 0);
REQUIRE(item->m_rect.verticalAlign == 0);
}
TEST_CASE("ItemScopeSequences: Simple dvarStrList works", "[parsing][sequence][menu]")
{
ItemSequenceTestsHelper helper(FeatureLevel::IW4, false);