[libc-commits] [PATCH] D73668: [libc] Add [EXPECT|ASSERT]_[TRUE|FALSE] unittest macros.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jan 30 12:10:32 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f658920863b: [libc] Add [EXPECT|ASSERT]_[TRUE|FALSE] unittest macros. (authored by sivachandra).
Changed prior to commit:
https://reviews.llvm.org/D73668?vs=241530&id=241539#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73668/new/
https://reviews.llvm.org/D73668
Files:
libc/utils/CPP/TypeTraits.h
libc/utils/UnitTest/Test.cpp
libc/utils/UnitTest/Test.h
Index: libc/utils/UnitTest/Test.h
===================================================================
--- libc/utils/UnitTest/Test.h
+++ libc/utils/UnitTest/Test.h
@@ -63,9 +63,8 @@
// is the result of the |Cond| operation on |LHS| and |RHS|. Though not bad,
// |Cond| on mismatched |LHS| and |RHS| types can potentially succeed because
// of type promotion.
- template <
- typename ValType,
- cpp::EnableIfType<cpp::IsIntegralNotBool<ValType>::Value, ValType> = 0>
+ template <typename ValType,
+ cpp::EnableIfType<cpp::IsIntegral<ValType>::Value, ValType> = 0>
static bool test(RunContext &Ctx, TestCondition Cond, ValType LHS,
ValType RHS, const char *LHSStr, const char *RHSStr,
const char *File, unsigned long Line) {
@@ -176,3 +175,15 @@
#define ASSERT_STRNE(LHS, RHS) \
if (!EXPECT_STRNE(LHS, RHS)) \
return
+
+#define EXPECT_TRUE(VAL) EXPECT_EQ((VAL), true)
+
+#define ASSERT_TRUE(VAL) \
+ if (!EXPECT_TRUE(VAL)) \
+ return
+
+#define EXPECT_FALSE(VAL) EXPECT_EQ((VAL), false)
+
+#define ASSERT_FALSE(VAL) \
+ if (!EXPECT_FALSE(VAL)) \
+ return
Index: libc/utils/UnitTest/Test.cpp
===================================================================
--- libc/utils/UnitTest/Test.cpp
+++ libc/utils/UnitTest/Test.cpp
@@ -204,6 +204,11 @@
const char *RHSStr, const char *File,
unsigned long Line);
+template bool Test::test<bool, 0>(RunContext &Ctx, TestCondition Cond, bool LHS,
+ bool RHS, const char *LHSStr,
+ const char *RHSStr, const char *File,
+ unsigned long Line);
+
template bool Test::test<unsigned long long, 0>(
RunContext &Ctx, TestCondition Cond, unsigned long long LHS,
unsigned long long RHS, const char *LHSStr, const char *RHSStr,
Index: libc/utils/CPP/TypeTraits.h
===================================================================
--- libc/utils/CPP/TypeTraits.h
+++ libc/utils/CPP/TypeTraits.h
@@ -37,9 +37,6 @@
template <> struct IsIntegral<unsigned long long> : public TrueValue {};
template <> struct IsIntegral<bool> : public TrueValue {};
-template <typename Type> struct IsIntegralNotBool : public IsIntegral<Type> {};
-template <> struct IsIntegralNotBool<bool> : public FalseValue {};
-
template <typename T> struct IsPointerType : public FalseValue {};
template <typename T> struct IsPointerType<T *> : public TrueValue {};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73668.241539.patch
Type: text/x-patch
Size: 2866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200130/b1f4ad5d/attachment.bin>
More information about the libc-commits
mailing list