Organize spec helper files
This commit is contained in:
parent
9e2dc14182
commit
84b8addb63
4 changed files with 43 additions and 33 deletions
38
spec/helpers/equals_pointer.h
Normal file
38
spec/helpers/equals_pointer.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef tree_sitter_equals_pointer_h
|
||||
#define tree_sitter_equals_pointer_h
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace snowhouse {
|
||||
using namespace std;
|
||||
|
||||
template<typename ExpectedType>
|
||||
struct EqualsPointerConstraint : Expression<EqualsPointerConstraint<ExpectedType>>
|
||||
{
|
||||
EqualsPointerConstraint(const ExpectedType& expected) : expected(expected) {}
|
||||
|
||||
template<typename ActualType>
|
||||
bool operator()(const ActualType& actual) const {
|
||||
return *expected == *actual;
|
||||
}
|
||||
|
||||
ExpectedType expected;
|
||||
};
|
||||
|
||||
template<typename ExpectedType>
|
||||
struct Stringizer<EqualsPointerConstraint<ExpectedType>>
|
||||
{
|
||||
static string ToString(const EqualsPointerConstraint<ExpectedType>& constraint) {
|
||||
ostringstream builder;
|
||||
builder << "pointer to " << snowhouse::Stringize(constraint.expected);
|
||||
return builder.str();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ExpectedType>
|
||||
inline EqualsPointerConstraint<ExpectedType> EqualsPointer(const ExpectedType& expected) {
|
||||
return EqualsPointerConstraint<ExpectedType>(expected);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue