From f297ebafdcdf5d5a8c3ef74c9906de67998e5aa7 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 14 Dec 2017 11:47:42 +0000 Subject: [PATCH] Test whitespace handling in std::complex extraction * testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc: Add tests using noskipws. From-SVN: r255632 --- libstdc++-v3/ChangeLog | 3 ++ .../inserters_extractors/char/dr2714.cc | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b20a277a085..e035302bed4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2017-12-14 Jonathan Wakely + * testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc: + Add tests using noskipws. + * testsuite/26_numerics/complex/dr2714.cc: Move to ... * testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc: ... Here. Remove duplicate header and dg-options. Check first invalid diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc index 17fb8a249d9..952c52f4a2b 100644 --- a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc +++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc @@ -145,10 +145,38 @@ test03() in.clear(); } +void +test04() +{ + // Test noskipws handling + std::istringstream in; + const char* bad_inputs[] = { + " 1", " (2)", "( 2)", "(2 )", "(2 ,3)", "(2,3 )", 0 + }; + const std::complex c0(-1, -1); + std::complex c; + for (int i = 0; bad_inputs[i]; ++i) + { + c = c0; + in.clear(); + in.str(bad_inputs[i]); + in >> std::noskipws >> c; + VERIFY( in.fail() ); + VERIFY( c == c0 ); + + in.clear(); + in.str(bad_inputs[i]); + in >> std::skipws >> c; + VERIFY( !in.fail() ); + VERIFY( c != c0 ); + } +} + int main() { test01(); test02(); test03(); + test04(); } -- 2.30.2