[libcxx-commits] [libcxx] 2ea8fec - [libc++] Improve tests for std::quoted
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 5 16:07:16 PDT 2020
Author: Louis Dionne
Date: 2020-10-05T19:07:03-04:00
New Revision: 2ea8fec2cd566be77c9412aacb8e546bd0c36612
URL: https://github.com/llvm/llvm-project/commit/2ea8fec2cd566be77c9412aacb8e546bd0c36612
DIFF: https://github.com/llvm/llvm-project/commit/2ea8fec2cd566be77c9412aacb8e546bd0c36612.diff
LOG: [libc++] Improve tests for std::quoted
Instead of using ad-hoc mechanisms to disable the tests in C++ < 14, use
UNSUPPORTED markup.
Added:
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.verify.cpp
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp
Modified:
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
Removed:
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.compile.fail.cpp
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.compile.fail.cpp
################################################################################
diff --git a/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp b/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
index 6ad0ec11808c..854e271fcabb 100644
--- a/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
@@ -22,7 +22,7 @@
template <class CharT, class Traits>
bool is_skipws ( const std::basic_istream<CharT, Traits>& is ) {
return ( is.flags() & std::ios_base::skipws ) != 0;
- }
+}
template <class CharT, class Traits = std::char_traits<CharT>>
void both_ways ( const CharT *p ) {
@@ -34,7 +34,7 @@ void both_ways ( const CharT *p ) {
((void)skippingws); // Prevent unused warning
ss << q;
ss >> q;
- }
+}
template <class CharT, class Traits = std::char_traits<CharT>>
void round_trip ( const CharT *p ) {
@@ -46,7 +46,7 @@ void round_trip ( const CharT *p ) {
ss >> std::quoted(s);
assert ( s == p );
assert ( skippingws == is_skipws ( ss ));
- }
+}
template <class CharT, class Traits = std::char_traits<CharT>>
@@ -60,7 +60,7 @@ void round_trip_ws ( const CharT *p ) {
ss >> std::quoted(s);
assert ( s == p );
assert ( skippingws == is_skipws ( ss ));
- }
+}
template <class CharT, class Traits = std::char_traits<CharT>>
void round_trip_d ( const CharT *p, char delim ) {
@@ -71,7 +71,7 @@ void round_trip_d ( const CharT *p, char delim ) {
std::basic_string<CharT, Traits> s;
ss >> std::quoted(s, d);
assert ( s == p );
- }
+}
template <class CharT, class Traits = std::char_traits<CharT>>
void round_trip_e ( const CharT *p, char escape ) {
@@ -82,7 +82,7 @@ void round_trip_e ( const CharT *p, char escape ) {
std::basic_string<CharT, Traits> s;
ss >> std::quoted(s, CharT('"'), e );
assert ( s == p );
- }
+}
template <class CharT, class Traits = std::char_traits<CharT>>
diff --git a/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.compile.fail.cpp b/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.verify.cpp
similarity index 72%
rename from libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.compile.fail.cpp
rename to libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.verify.cpp
index 4b343013e258..9340edbf80a3 100644
--- a/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.compile.fail.cpp
+++ b/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.verify.cpp
@@ -10,6 +10,8 @@
// quoted
+// UNSUPPORTED: c++03, c++11
+
#include <iomanip>
#include <sstream>
#include <string>
@@ -19,21 +21,13 @@
// Test that mismatches between strings and wide streams are diagnosed
-#if TEST_STD_VER > 11
-
void round_trip ( const char *p ) {
std::wstringstream ss;
- ss << std::quoted(p);
+ ss << std::quoted(p); // expected-error {{invalid operands to binary expression}}
std::string s;
- ss >> std::quoted(s);
- }
-
-
+ ss >> std::quoted(s); // expected-error {{invalid operands to binary expression}}
+}
-int main(int, char**)
-{
- round_trip ( "Hi Mom" );
+int main(int, char**) {
+ round_trip("Hi Mom");
}
-#else
-#error
-#endif
diff --git a/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.compile.fail.cpp b/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp
similarity index 77%
rename from libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.compile.fail.cpp
rename to libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp
index b19eea376d82..5a92485ced56 100644
--- a/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.compile.fail.cpp
+++ b/libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp
@@ -10,6 +10,8 @@
// quoted
+// UNSUPPORTED: c++03, c++11
+
#include <iomanip>
#include <sstream>
#include <string>
@@ -17,29 +19,20 @@
#include "test_macros.h"
-#if TEST_STD_VER > 11
-
// Test that mismatches in the traits between the quoted object and the dest string are diagnosed.
template <class charT>
-struct test_traits
-{
- typedef charT char_type;
+struct test_traits {
+ typedef charT char_type;
};
void round_trip ( const char *p ) {
std::stringstream ss;
ss << std::quoted(p);
std::basic_string<char, test_traits<char>> s;
- ss >> std::quoted(s);
- }
-
-
+ ss >> std::quoted(s); // expected-error {{invalid operands to binary expression}}
+}
-int main(int, char**)
-{
- round_trip ( "Hi Mom" );
+int main(int, char**) {
+ round_trip("Hi Mom");
}
-#else
-#error
-#endif
More information about the libcxx-commits
mailing list