mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
34 lines
1.4 KiB
C++
34 lines
1.4 KiB
C++
#include "Parsing/Impl/PackDefinitionStreamProxy.h"
|
|
#include "Parsing/Mock/MockParserLineStream.h"
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/generators/catch_generators.hpp>
|
|
|
|
namespace test::parsing::impl::pack_definition_stream_proxy
|
|
{
|
|
void ExpectLine(IParserLineStream* stream, const int lineNumber, const std::string& value)
|
|
{
|
|
auto line = stream->NextLine();
|
|
REQUIRE(line.m_line_number == lineNumber);
|
|
REQUIRE(line.m_line == value);
|
|
}
|
|
|
|
TEST_CASE("PackDefinitionStreamProxy: Ensure simple pack directives are working", "[parsing][parsingstream]")
|
|
{
|
|
const std::vector<std::string> lines{"hello world", "#pragma pack(push, 32)", "hello galaxy", "#pragma pack(pop)", "hello universe"};
|
|
|
|
MockParserLineStream mockStream(lines);
|
|
PackDefinitionStreamProxy proxy(&mockStream);
|
|
|
|
REQUIRE(proxy.GetCurrentPack() == PackDefinitionStreamProxy::DEFAULT_PACK);
|
|
ExpectLine(&proxy, 1, "hello world");
|
|
REQUIRE(proxy.GetCurrentPack() == PackDefinitionStreamProxy::DEFAULT_PACK);
|
|
ExpectLine(&proxy, 3, "hello galaxy");
|
|
REQUIRE(proxy.GetCurrentPack() == 32);
|
|
ExpectLine(&proxy, 5, "hello universe");
|
|
REQUIRE(proxy.GetCurrentPack() == PackDefinitionStreamProxy::DEFAULT_PACK);
|
|
|
|
REQUIRE(proxy.Eof());
|
|
}
|
|
} // namespace test::parsing::impl::pack_definition_stream_proxy
|