[libc++] Remove uses of printf in some test support headers

In the test suite, we generally don't use printf or other reporting
utilities. It's not that it wouldn't be useful, it's just that some
platforms don't support IO.

Instead, we try to keep test cases small and self-contained so that
we can reasonably easily reproduce failures locally and debug them.
This patch removes printf in some of the last places in the test suite
that used it. The only remaining places are in a deque test and in the
filesystem tests. The filesystem tests are arguably fine to keep using
IO, since we're testing <filesystem>. The deque test will be handled
separately.

Differential Revision: https://reviews.llvm.org/D114282

GitOrigin-RevId: e7cee55c9d6b178baae3388ae2f620b44cf51e63
diff --git a/test/support/controlled_allocators.h b/test/support/controlled_allocators.h
index b00f7fd..fa9f04e 100644
--- a/test/support/controlled_allocators.h
+++ b/test/support/controlled_allocators.h
@@ -183,13 +183,18 @@
 
     template <class ...Args, class Alloc, class Tp>
     bool checkConstruct(Alloc const&, Tp *p) const {
-      auto expectAlloc = &makeTypeID<Alloc>();
-      auto expectTp = &makeTypeID<Tp>();
-      auto expectArgs = &makeArgumentID<Args...>();
-      return last_construct_pointer == p &&
-          COMPARE_TYPEID(last_construct_alloc, expectAlloc) &&
-          COMPARE_TYPEID(last_construct_type, expectTp) &&
-          COMPARE_TYPEID(last_construct_args, expectArgs);
+        auto expectAlloc = &makeTypeID<Alloc>();
+        auto expectTp = &makeTypeID<Tp>();
+        auto expectArgs = &makeArgumentID<Args...>();
+        if (last_construct_pointer != p)
+            return false;
+        if (last_construct_alloc != expectAlloc)
+            return false;
+        if (last_construct_type != expectTp)
+            return false;
+        if (last_construct_args != expectArgs)
+            return false;
+        return true;
     }
 
     template <class Alloc, class Tp>
diff --git a/test/support/type_id.h b/test/support/type_id.h
index 0450b88..c318194 100644
--- a/test/support/type_id.h
+++ b/test/support/type_id.h
@@ -8,9 +8,7 @@
 #ifndef SUPPORT_TYPE_ID_H
 #define SUPPORT_TYPE_ID_H
 
-#include <functional>
 #include <string>
-#include <cstdio>
 #include <cassert>
 
 #include "test_macros.h"
@@ -70,20 +68,4 @@
   return makeTypeIDImp<ArgumentListID<Args...>>();
 }
 
-
-// COMPARE_TYPEID(...) is a utility macro for generating diagnostics when
-// two typeid's are expected to be equal
-#define COMPARE_TYPEID(LHS, RHS) CompareTypeIDVerbose(#LHS, LHS, #RHS, RHS)
-
-inline bool CompareTypeIDVerbose(const char* LHSString, TypeID const* LHS,
-                                 const char* RHSString, TypeID const* RHS) {
-  if (*LHS == *RHS)
-    return true;
-  std::printf("TypeID's not equal:\n");
-  std::printf("%s: %s\n----------\n%s: %s\n",
-              LHSString, LHS->name().c_str(),
-              RHSString, RHS->name().c_str());
-  return false;
-}
-
 #endif // SUPPORT_TYPE_ID_H
diff --git a/test/support/uses_alloc_types.h b/test/support/uses_alloc_types.h
index c849bd5..9403572 100644
--- a/test/support/uses_alloc_types.h
+++ b/test/support/uses_alloc_types.h
@@ -10,7 +10,6 @@
 #define USES_ALLOC_TYPES_H
 
 #include <cassert>
-#include <cstdio>
 #include <cstdlib>
 #include <memory>
 
@@ -44,17 +43,6 @@
     }
 }
 
-#define COMPARE_ALLOC_TYPE(LHS, RHS) CompareVerbose(#LHS, LHS, #RHS, RHS)
-
-inline bool CompareVerbose(const char* LHSString, UsesAllocatorType LHS,
-                           const char* RHSString, UsesAllocatorType RHS) {
-    if (LHS == RHS)
-        return true;
-    std::printf("UsesAllocatorType's don't match:\n%s %s\n----------\n%s %s\n",
-                LHSString, toString(LHS), RHSString, toString(RHS));
-    return false;
-}
-
 template <class Alloc, std::size_t N>
 class UsesAllocatorV1;
     // Implements form (1) of uses-allocator construction from the specified
@@ -191,26 +179,36 @@
     template <class ...ArgTypes>
     bool checkConstruct(UsesAllocatorType expectType) const {
         auto expectArgs = &makeArgumentID<ArgTypes...>();
-        return COMPARE_ALLOC_TYPE(expectType, constructor_called) &&
-               COMPARE_TYPEID(args_id, expectArgs);
+        if (expectType != constructor_called)
+            return false;
+        if (args_id != expectArgs)
+            return false;
+        return true;
     }
 
     template <class ...ArgTypes>
     bool checkConstruct(UsesAllocatorType expectType,
                         CtorAlloc const& expectAlloc) const {
         auto ExpectID = &makeArgumentID<ArgTypes...>() ;
-        return COMPARE_ALLOC_TYPE(expectType, constructor_called) &&
-               COMPARE_TYPEID(args_id, ExpectID) &&
-               has_alloc() && expectAlloc == *get_alloc();
-
+        if (expectType != constructor_called)
+            return false;
+        if (args_id != ExpectID)
+            return false;
+        if (!has_alloc() || expectAlloc != *get_alloc())
+            return false;
+        return true;
     }
 
     bool checkConstructEquiv(UsesAllocatorTestBase& O) const {
         if (has_alloc() != O.has_alloc())
             return false;
-        return COMPARE_ALLOC_TYPE(constructor_called, O.constructor_called)
-            && COMPARE_TYPEID(args_id, O.args_id)
-            && (!has_alloc() || *get_alloc() == *O.get_alloc());
+        if (constructor_called != O.constructor_called)
+            return false;
+        if (args_id != O.args_id)
+            return false;
+        if (has_alloc() && *get_alloc() != *O.get_alloc())
+            return false;
+        return true;
     }
 
 protected: