Skip to content

Commit

Permalink
Add PassthroughNot
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Aug 3, 2024
1 parent 40cb356 commit 11622df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Source/UEST/Private/UESTTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ TEST(UEST, SimpleTest)
ASSERT_THAT(&v2, Is::Not::Null);

ASSERT_THAT(42, Is::EqualTo(42));
ASSERT_THAT(42, Is::Not::EqualTo(43));
// TODO: Need explicit <int> for now because of clang bug: https://github.com/llvm/llvm-project/issues/73093
ASSERT_THAT(42, Is::Not::EqualTo<int>(43));
}

TEST_CLASS(UEST, SimpleTestClass)
Expand Down
32 changes: 18 additions & 14 deletions Source/UEST/Public/UEST.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ namespace Matchers
return FString::Printf(TEXT("not %s"), *Nested.Describe());
}
};

template <typename T, typename M, typename... P>
// TODO: Add requires
struct PassthroughNot
{
NotMatcher<T, M> Matcher;

explicit PassthroughNot(P... Args)
: Matcher{NotMatcher<T, M>{Args...}}
{}

template<typename U>
auto operator()() const
{
return Matcher;
}
};
}

namespace Is
Expand Down Expand Up @@ -184,20 +201,7 @@ namespace Is
} False;

template<typename T>
struct EqualTo
{
T Expected;

EqualTo(T Expected)
: Expected(Expected)
{}

template<typename U>
auto operator()() const
{
return Matchers::NotMatcher<T, Matchers::EqualTo<T>>{Matchers::EqualTo<T>(Expected)};
}
};
using EqualTo = Matchers::PassthroughNot<T, Matchers::EqualTo<T>, T>;
}
}

Expand Down

0 comments on commit 11622df

Please sign in to comment.