Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Aug 4, 2024
1 parent 6bee81a commit 838f556
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 41 deletions.
6 changes: 2 additions & 4 deletions Source/UEST/Private/UEST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ bool FUESTTestBase::RunTest(const FString& Parameters)
Method->Execute();
}
}
else
{
DoTest(Parameters);
}

// TODO: Should we mark test class without test methods as failed?

return true;
}
Expand Down
74 changes: 37 additions & 37 deletions Source/UEST/Public/UEST.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ namespace UEST
{
M Matcher;

// TODO: Rethink signature. Maybe (P... Args) with MoveTemp? Or (P&&... Args) With Forward?
explicit Passthrough(const P&... Args)
: Matcher{Args...}
explicit Passthrough(P... Args)
: Matcher{MoveTemp(Args)...}
{
}

Expand Down Expand Up @@ -117,10 +116,10 @@ namespace UEST
// TODO: Add requires
struct EqualTo final : IMatcher<T>
{
const T& Expected;
const T Expected;

explicit EqualTo(const T& Expected)
: Expected(Expected)
explicit EqualTo(T Expected)
: Expected(MoveTemp(Expected))
{
}

Expand All @@ -139,10 +138,10 @@ namespace UEST
// TODO: Add requires
struct LessThan final : IMatcher<T>
{
const T& Expected;
const T Expected;

explicit LessThan(const T& Expected)
: Expected{Expected}
explicit LessThan(T Expected)
: Expected{MoveTemp(Expected)}
{
}

Expand All @@ -161,10 +160,10 @@ namespace UEST
// TODO: Add requires
struct LessThanOrEqualTo final : IMatcher<T>
{
const T& Expected;
const T Expected;

explicit LessThanOrEqualTo(const T& Expected)
: Expected{Expected}
explicit LessThanOrEqualTo(T Expected)
: Expected{MoveTemp(Expected)}
{
}

Expand All @@ -183,10 +182,10 @@ namespace UEST
// TODO: Add requires
struct GreaterThan final : IMatcher<T>
{
const T& Expected;
const T Expected;

explicit GreaterThan(const T& Expected)
: Expected{Expected}
explicit GreaterThan(T Expected)
: Expected{MoveTemp(Expected)}
{
}

Expand All @@ -205,10 +204,10 @@ namespace UEST
// TODO: Add requires
struct GreaterThanOrEqualTo final : IMatcher<T>
{
const T& Expected;
const T Expected;

explicit GreaterThanOrEqualTo(const T& Expected)
: Expected{Expected}
explicit GreaterThanOrEqualTo(T Expected)
: Expected{MoveTemp(Expected)}
{
}

Expand All @@ -227,12 +226,12 @@ namespace UEST
// TODO: Add requires
struct InRange final : IMatcher<T>
{
const T& From;
const T& To;
const T From;
const T To;

explicit InRange(const T& From, const T& To)
: From{From}
, To{To}
explicit InRange(T From, T To)
: From{MoveTemp(From)}
, To{MoveTemp(To)}
{
}

Expand All @@ -259,8 +258,8 @@ namespace UEST
{
M Nested;

explicit Not(const P&... Args)
: Nested{Args...}
explicit Not(P... Args)
: Nested{MoveTemp(Args)...}
{
}

Expand Down Expand Up @@ -308,11 +307,11 @@ namespace Is
template<typename T>
using AtLeast = GreaterThanOrEqualTo<T>;

const auto Zero = EqualTo<double>(0.);
const auto Zero = EqualTo<int64>(0);

const auto Positive = GreaterThan<double>(0.);
const auto Positive = GreaterThan<int64>(0);

const auto Negative = LessThan<double>(0.);
const auto Negative = LessThan<int64>(0);

template<typename T>
using InRange = UEST::Passthrough<UEST::Matchers::InRange<T>, T, T>;
Expand Down Expand Up @@ -361,11 +360,11 @@ namespace Is
template<typename T>
using GreaterThanOrEqualTo = UEST::Passthrough<UEST::Matchers::LessThan<T>, T>;

const auto Zero = EqualTo<double>(0.);
const auto Zero = EqualTo<int64>(0);

const auto Positive = GreaterThan<double>(0.);
const auto Positive = GreaterThan<int64>(0);

const auto Negative = LessThan<double>(0.);
const auto Negative = LessThan<int64>(0);

template<typename T>
using InRange = UEST::Passthrough<UEST::Matchers::Not<UEST::Matchers::InRange<T>, T, T>, T, T>;
Expand All @@ -377,7 +376,7 @@ namespace Is
do \
{ \
const auto& MatcherInstance = Matcher.operator()<decltype(Value)>(); \
if (!ensureAlwaysMsgf(MatcherInstance.Matches(Value), TEXT("%s must %s"), *CQTestConvert::ToString(Value), *MatcherInstance.Describe())) \
if (!ensureAlwaysMsgf(MatcherInstance.Matches(Value), TEXT("%s: %s must %s"), TEXT(#Value), *CQTestConvert::ToString(Value), *MatcherInstance.Describe())) \
{ \
return; \
} \
Expand All @@ -396,10 +395,6 @@ class UEST_API FUESTTestBase : public FAutomationTestBase

virtual bool RunTest(const FString& Parameters) override;

virtual void DoTest(const FString& Parameters)
{
}

public:
// TODO: Can we do this without delegates, just using method pointers?
TMap<FString, FSimpleDelegate> TestMethods;
Expand Down Expand Up @@ -481,7 +476,12 @@ struct TUESTInstantiator
#define TEST_WITH_BASE(BaseClass, ...) \
TEST_CLASS_WITH_BASE(BaseClass, __VA_ARGS__) \
{ \
virtual void DoTest(const FString& Parameters) override; \
virtual bool RunTest(const FString& Parameters) override \
{ \
DoTest(Parameters); \
return true; \
} \
void DoTest(const FString& Parameters); \
}; \
void BOOST_PP_CAT(BOOST_PP_CAT(F, UEST_CLASS_NAME(__VA_ARGS__)), Impl)::DoTest(const FString& Parameters)

Expand Down

0 comments on commit 838f556

Please sign in to comment.