Exteor/test/Mock/mockTermContext.hpp

26 lines
695 B
C++
Raw Normal View History

2024-06-07 20:30:06 +03:00
#pragma once
#include "ccl/lang/LexicalTerm.h"
#include "ccl/lang/EntityTermContext.hpp"
class MockContext : public ccl::lang::EntityTermContext {
private:
std::unordered_map<std::string, ccl::lang::LexicalTerm> terms{};
public:
void Clear() noexcept { terms.clear(); }
void Insert(const std::string& entity, const ccl::lang::LexicalTerm& term) {
terms.emplace(std::pair{ entity , term });
}
bool Contains(const std::string& entity) const override {
return terms.count(entity) > 0;
}
const ccl::lang::LexicalTerm* At(const std::string& entity) const override {
if (!Contains(entity)) {
return nullptr;
} else {
return &terms.at(entity);
}
}
};