[libc++] Improve tests for std::quoted
authorLouis Dionne <ldionne@apple.com>
Mon, 5 Oct 2020 22:50:37 +0000 (18:50 -0400)
committerLouis Dionne <ldionne@apple.com>
Mon, 5 Oct 2020 23:07:03 +0000 (19:07 -0400)
Instead of using ad-hoc mechanisms to disable the tests in C++ < 14, use
UNSUPPORTED markup.

libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.verify.cpp [moved from libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.compile.fail.cpp with 72% similarity]
libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp [moved from libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.compile.fail.cpp with 77% similarity]

index 6ad0ec1..854e271 100644 (file)
@@ -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>>
@@ -10,6 +10,8 @@
 
 // quoted
 
+// UNSUPPORTED: c++03, c++11
+
 #include <iomanip>
 #include <sstream>
 #include <string>
 
 //  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
@@ -10,6 +10,8 @@
 
 // quoted
 
+// UNSUPPORTED: c++03, c++11
+
 #include <iomanip>
 #include <sstream>
 #include <string>
 
 #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