forked from OSchip/llvm-project
[libc] Add support for enum in EXPECT_EQ
This commit is contained in:
parent
d3eadbe40d
commit
299baac64d
|
@ -15,7 +15,9 @@ namespace __llvm_libc {
|
||||||
namespace cpp {
|
namespace cpp {
|
||||||
|
|
||||||
template <bool B, typename T> struct EnableIf;
|
template <bool B, typename T> struct EnableIf;
|
||||||
template <typename T> struct EnableIf<true, T> { typedef T Type; };
|
template <typename T> struct EnableIf<true, T> {
|
||||||
|
typedef T Type;
|
||||||
|
};
|
||||||
|
|
||||||
template <bool B, typename T>
|
template <bool B, typename T>
|
||||||
using EnableIfType = typename EnableIf<B, T>::Type;
|
using EnableIfType = typename EnableIf<B, T>::Type;
|
||||||
|
@ -28,7 +30,9 @@ struct FalseValue {
|
||||||
static constexpr bool Value = false;
|
static constexpr bool Value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct TypeIdentity { typedef T Type; };
|
template <typename T> struct TypeIdentity {
|
||||||
|
typedef T Type;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T1, typename T2> struct IsSame : public FalseValue {};
|
template <typename T1, typename T2> struct IsSame : public FalseValue {};
|
||||||
template <typename T> struct IsSame<T, T> : public TrueValue {};
|
template <typename T> struct IsSame<T, T> : public TrueValue {};
|
||||||
|
@ -59,6 +63,10 @@ template <typename Type> struct IsIntegral {
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Type> struct IsEnum {
|
||||||
|
static constexpr bool Value = __is_enum(Type);
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T> struct IsPointerTypeNoCV : public FalseValue {};
|
template <typename T> struct IsPointerTypeNoCV : public FalseValue {};
|
||||||
template <typename T> struct IsPointerTypeNoCV<T *> : public TrueValue {};
|
template <typename T> struct IsPointerTypeNoCV<T *> : public TrueValue {};
|
||||||
template <typename T> struct IsPointerType {
|
template <typename T> struct IsPointerType {
|
||||||
|
|
|
@ -89,6 +89,14 @@ protected:
|
||||||
return internal::test(Ctx, Cond, LHS, RHS, LHSStr, RHSStr, File, Line);
|
return internal::test(Ctx, Cond, LHS, RHS, LHSStr, RHSStr, File, Line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename ValType,
|
||||||
|
cpp::EnableIfType<cpp::IsEnum<ValType>::Value, int> = 0>
|
||||||
|
bool test(TestCondition Cond, ValType LHS, ValType RHS, const char *LHSStr,
|
||||||
|
const char *RHSStr, const char *File, unsigned long Line) {
|
||||||
|
return internal::test(Ctx, Cond, (long long)LHS, (long long)RHS, LHSStr,
|
||||||
|
RHSStr, File, Line);
|
||||||
|
}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename ValType,
|
typename ValType,
|
||||||
cpp::EnableIfType<cpp::IsPointerType<ValType>::Value, ValType> = nullptr>
|
cpp::EnableIfType<cpp::IsPointerType<ValType>::Value, ValType> = nullptr>
|
||||||
|
|
Loading…
Reference in New Issue