Skip to content

[libc++][format] Improves tests. #76291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2024
Merged

Conversation

mordante
Copy link
Member

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

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.
@mordante mordante requested a review from a team as a code owner December 23, 2023 15:16
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Dec 23, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2023

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/76291.diff

10 Files Affected:

  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.c_string.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.char_array.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.handle.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.pointer.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.signed_integral.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.string.pass.cpp (+1-1)
  • (modified) libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.unsigned_integral.pass.cpp (+1-1)
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;

@mordante mordante merged commit 74fb205 into llvm:main Feb 2, 2024
@mordante mordante deleted the format_improves_test branch February 2, 2024 18:56
agozillon pushed a commit to agozillon/llvm-project that referenced this pull request Feb 5, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants