Skip to content

Commit 2ea8fec

Browse files
committed
[libc++] Improve tests for std::quoted
Instead of using ad-hoc mechanisms to disable the tests in C++ < 14, use UNSUPPORTED markup.
1 parent be66987 commit 2ea8fec

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

libcxx/test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
template <class CharT, class Traits>
2323
bool is_skipws ( const std::basic_istream<CharT, Traits>& is ) {
2424
return ( is.flags() & std::ios_base::skipws ) != 0;
25-
}
25+
}
2626

2727
template <class CharT, class Traits = std::char_traits<CharT>>
2828
void both_ways ( const CharT *p ) {
@@ -34,7 +34,7 @@ void both_ways ( const CharT *p ) {
3434
((void)skippingws); // Prevent unused warning
3535
ss << q;
3636
ss >> q;
37-
}
37+
}
3838

3939
template <class CharT, class Traits = std::char_traits<CharT>>
4040
void round_trip ( const CharT *p ) {
@@ -46,7 +46,7 @@ void round_trip ( const CharT *p ) {
4646
ss >> std::quoted(s);
4747
assert ( s == p );
4848
assert ( skippingws == is_skipws ( ss ));
49-
}
49+
}
5050

5151

5252
template <class CharT, class Traits = std::char_traits<CharT>>
@@ -60,7 +60,7 @@ void round_trip_ws ( const CharT *p ) {
6060
ss >> std::quoted(s);
6161
assert ( s == p );
6262
assert ( skippingws == is_skipws ( ss ));
63-
}
63+
}
6464

6565
template <class CharT, class Traits = std::char_traits<CharT>>
6666
void round_trip_d ( const CharT *p, char delim ) {
@@ -71,7 +71,7 @@ void round_trip_d ( const CharT *p, char delim ) {
7171
std::basic_string<CharT, Traits> s;
7272
ss >> std::quoted(s, d);
7373
assert ( s == p );
74-
}
74+
}
7575

7676
template <class CharT, class Traits = std::char_traits<CharT>>
7777
void round_trip_e ( const CharT *p, char escape ) {
@@ -82,7 +82,7 @@ void round_trip_e ( const CharT *p, char escape ) {
8282
std::basic_string<CharT, Traits> s;
8383
ss >> std::quoted(s, CharT('"'), e );
8484
assert ( s == p );
85-
}
85+
}
8686

8787

8888
template <class CharT, class Traits = std::char_traits<CharT>>

libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.compile.fail.cpp renamed to libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_char.verify.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// quoted
1212

13+
// UNSUPPORTED: c++03, c++11
14+
1315
#include <iomanip>
1416
#include <sstream>
1517
#include <string>
@@ -19,21 +21,13 @@
1921

2022
// Test that mismatches between strings and wide streams are diagnosed
2123

22-
#if TEST_STD_VER > 11
23-
2424
void round_trip ( const char *p ) {
2525
std::wstringstream ss;
26-
ss << std::quoted(p);
26+
ss << std::quoted(p); // expected-error {{invalid operands to binary expression}}
2727
std::string s;
28-
ss >> std::quoted(s);
29-
}
30-
31-
28+
ss >> std::quoted(s); // expected-error {{invalid operands to binary expression}}
29+
}
3230

33-
int main(int, char**)
34-
{
35-
round_trip ( "Hi Mom" );
31+
int main(int, char**) {
32+
round_trip("Hi Mom");
3633
}
37-
#else
38-
#error
39-
#endif

libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.compile.fail.cpp renamed to libcxx/test/std/input.output/iostream.format/quoted.manip/quoted_traits.verify.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,29 @@
1010

1111
// quoted
1212

13+
// UNSUPPORTED: c++03, c++11
14+
1315
#include <iomanip>
1416
#include <sstream>
1517
#include <string>
1618
#include <cassert>
1719

1820
#include "test_macros.h"
1921

20-
#if TEST_STD_VER > 11
21-
2222
// Test that mismatches in the traits between the quoted object and the dest string are diagnosed.
2323

2424
template <class charT>
25-
struct test_traits
26-
{
27-
typedef charT char_type;
25+
struct test_traits {
26+
typedef charT char_type;
2827
};
2928

3029
void round_trip ( const char *p ) {
3130
std::stringstream ss;
3231
ss << std::quoted(p);
3332
std::basic_string<char, test_traits<char>> s;
34-
ss >> std::quoted(s);
35-
}
36-
37-
33+
ss >> std::quoted(s); // expected-error {{invalid operands to binary expression}}
34+
}
3835

39-
int main(int, char**)
40-
{
41-
round_trip ( "Hi Mom" );
36+
int main(int, char**) {
37+
round_trip("Hi Mom");
4238
}
43-
#else
44-
#error
45-
#endif

0 commit comments

Comments
 (0)