mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
Add base for menu parsing unit tests
This commit is contained in:
49
test/ParserTestUtils/Parsing/Mock/MockSequence.h
Normal file
49
test/ParserTestUtils/Parsing/Mock/MockSequence.h
Normal file
@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Sequence/AbstractSequence.h"
|
||||
|
||||
struct MockSequenceState
|
||||
{
|
||||
char m_dummy;
|
||||
};
|
||||
|
||||
template<typename TokenType>
|
||||
class MockSequence final : public AbstractSequence<TokenType, MockSequenceState>
|
||||
{
|
||||
public:
|
||||
typedef AbstractSequence<TokenType, MockSequenceState> parent_t;
|
||||
|
||||
private:
|
||||
using parent_t::AddMatchers;
|
||||
using parent_t::AddLabeledMatchers;
|
||||
|
||||
std::function<void(SequenceResult<TokenType>&)> m_handler;
|
||||
|
||||
protected:
|
||||
void ProcessMatch(MockSequenceState* state, SequenceResult<TokenType>& result) const override
|
||||
{
|
||||
if (m_handler)
|
||||
m_handler(result);
|
||||
}
|
||||
|
||||
public:
|
||||
void AddMockMatchers(std::initializer_list<Movable<std::unique_ptr<typename parent_t::matcher_t>>> matchers)
|
||||
{
|
||||
AddMatchers(matchers);
|
||||
}
|
||||
|
||||
void AddMockLabeledMatchers(std::initializer_list<Movable<std::unique_ptr<typename parent_t::matcher_t>>> matchers, const int label)
|
||||
{
|
||||
AddLabeledMatchers(matchers, label);
|
||||
}
|
||||
|
||||
void Handle(std::function<void(SequenceResult<TokenType>&)> handler)
|
||||
{
|
||||
m_handler = std::move(handler);
|
||||
}
|
||||
|
||||
IMatcherForLabelSupplier<TokenType>* GetLabelSupplier()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user