[libcxx-commits] [libcxx] [libc++][format] Improves tests. (PR #76291)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Dec 23 07:16:53 PST 2023


https://github.com/mordante created https://github.com/llvm/llvm-project/pull/76291

Tests the returned type. This was first done for the vector<bool> formatters. This adds it to the other formatters where it wasn't done yet.

>From 875c359e9b0e540dbbeb3840dc35a734173db705 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Sat, 23 Dec 2023 11:43:17 +0100
Subject: [PATCH] [libc++][format] Improves tests.

Tests the returned type. This was first done for the vector<bool>
formatters. This adds it to the other formatters where it wasn't done
yet.
---
 .../format.formatter.spec/formatter.bool.pass.cpp               | 2 +-
 .../format.formatter.spec/formatter.c_string.pass.cpp           | 2 +-
 .../format.formatter.spec/formatter.char.pass.cpp               | 2 +-
 .../format.formatter.spec/formatter.char_array.pass.cpp         | 2 +-
 .../format.formatter.spec/formatter.floating_point.pass.cpp     | 2 +-
 .../format.formatter.spec/formatter.handle.pass.cpp             | 2 +-
 .../format.formatter.spec/formatter.pointer.pass.cpp            | 2 +-
 .../format.formatter.spec/formatter.signed_integral.pass.cpp    | 2 +-
 .../format.formatter.spec/formatter.string.pass.cpp             | 2 +-
 .../format.formatter.spec/formatter.unsigned_integral.pass.cpp  | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp
index d326b2b2f85ad5..efea2889ce3b5a 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp
@@ -37,7 +37,7 @@ void test(StringT expected, StringViewT fmt, bool arg, std::size_t offset) {
   std::formatter<bool, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp
index 6d7fd1b2ad8758..f363bc3032003c 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp
@@ -37,7 +37,7 @@ void test(StringT expected, StringViewT fmt, const CharT* a, std::size_t offset)
   std::formatter<T, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp
index 0b74ebba6e7df8..554def930020a9 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp
@@ -38,7 +38,7 @@ void test(StringT expected, StringViewT fmt, ArgumentT arg, std::size_t offset)
   std::formatter<ArgumentT, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
index 7c1e1c076bfbfd..295ba7f67bbc5b 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp
@@ -50,7 +50,7 @@ struct Tester {
     std::formatter<Str, CharT> formatter;
     static_assert(std::semiregular<decltype(formatter)>);
 
-    auto it = formatter.parse(parse_ctx);
+    std::same_as<typename std::basic_string_view<CharT>::iterator> auto it = formatter.parse(parse_ctx);
     assert(it == fmt.end() - offset);
 
     std::basic_string<CharT> result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
index 2df78344772911..206b0214cf5fd7 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
@@ -48,7 +48,7 @@ void test(std::basic_string_view<CharT> fmt, ArithmeticT arg, std::basic_string<
   std::formatter<ArithmeticT, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename std::basic_string_view<CharT>::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   std::basic_string<CharT> result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp
index 8fb4ebe57cdb78..e2b3d6b3d23701 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp
@@ -42,7 +42,7 @@ void test(std::string expected, std::string_view fmt, color arg, std::size_t off
   std::formatter<color, char> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename std::string_view::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   std::string result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp
index ff5bfe0fb472a2..aa10f34c95b796 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp
@@ -43,7 +43,7 @@ void test(StringT expected, StringViewT fmt, PointerT arg, std::size_t offset) {
   std::formatter<PointerT, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp
index 6f827ef5983278..e5db5dac0c569d 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp
@@ -45,7 +45,7 @@ void test(StringT expected, StringViewT fmt, ArithmeticT arg, std::size_t offset
   std::formatter<ArithmeticT, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp
index e99deb2db55300..73df7464dcb7a7 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp
@@ -45,7 +45,7 @@ void test(StringT expected, StringViewT fmt, StringT a, std::size_t offset) {
   std::formatter<T, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;
diff --git a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp
index 2a412eaa368a3f..eb70115bf5de59 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp
@@ -45,7 +45,7 @@ void test(StringT expected, StringViewT fmt, ArithmeticT arg, std::size_t offset
   std::formatter<ArithmeticT, CharT> formatter;
   static_assert(std::semiregular<decltype(formatter)>);
 
-  auto it = formatter.parse(parse_ctx);
+  std::same_as<typename StringViewT::iterator> auto it = formatter.parse(parse_ctx);
   assert(it == fmt.end() - offset);
 
   StringT result;



More information about the libcxx-commits mailing list