From: Jonathan Wakely Date: Thu, 14 Dec 2017 11:28:41 +0000 (+0000) Subject: Improve std::complex test and move to sub-directory X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02aee327674dae6359d7b1e1a7434f039ba0c3d3;p=gcc.git Improve std::complex test and move to sub-directory * 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 character gets putback. Remove wchar_t test. From-SVN: r255630 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e4e435dccee..b20a277a085 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2017-12-14 Jonathan Wakely + + * 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 + character gets putback. Remove wchar_t test. + 2017-12-13 Jonathan Wakely PR libstdc++/59568 diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr2714.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr2714.cc deleted file mode 100644 index 6b35e8adcf9..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/complex/dr2714.cc +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (C) 2017 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++98" } - -#include -#include -#include -#include - -void -test01() -{ - std::istringstream in(" 1 (2) ( 2.0 , 0.5 ) "); - std::complex c1, c2, c3; - in >> c1 >> c2 >> c3; - VERIFY( in.good() ); - VERIFY( c1.real() == 1 && c1.imag() == 0 ); - VERIFY( c2.real() == 2 && c2.imag() == 0 ); - VERIFY( c3.real() == 2 && c3.imag() == 0.5 ); -} - -void -test02() -{ - std::wistringstream in(L" ( 2.0 , 0.5 ) "); - std::complex c; - in >> c; - VERIFY( in.good() ); - VERIFY( c.real() == 2.0 && c.imag() == 0.5 ); -} - -void -test03() -{ - std::istringstream in; - std::complex c(-1, -1); - const std::complex c0 = c; - - in.str("a"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - - in.str(" ( ) "); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == ')' ); - - in.str("(,"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == ',' ); - - in.str("(b)"); - in >> c; - VERIFY( in.fail() ); - - in.clear(); - VERIFY( in.get() == 'b' ); - in.str("( c)"); - - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == 'c' ); - - in.str("(99d"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == 'd' ); - - in.str("(99 e"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == 'e' ); - - in.str("(99, f"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == 'f' ); - - in.str("(99, 88g"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == 'g' ); - - in.str("(99, 88 h"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == 'h' ); - - in.str("(99, )"); - in >> c; - VERIFY( in.fail() ); - in.clear(); - VERIFY( in.get() == ')' ); - - VERIFY( c == c0 ); -} - -void -test04() -{ - // PR libstdc++/59568 - std::istringstream in; - std::complex c; - - in.str(""); - in >> c; - VERIFY( in.fail() ); - VERIFY( in.eof() ); - in.clear(); - - in.str(" "); - in >> c; - VERIFY( in.fail() ); - VERIFY( in.eof() ); - in.clear(); - - in.str("(99"); - in >> c; - VERIFY( in.fail() ); - VERIFY( in.eof() ); - in.clear(); - - in.str("(99,"); - in >> c; - VERIFY( in.fail() ); - VERIFY( in.eof() ); - in.clear(); - - in.str("(99,99"); - in >> c; - VERIFY( in.fail() ); - VERIFY( in.eof() ); - in.clear(); -} - -int -main() -{ - test01(); - test02(); - test03(); - test04(); -} 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 new file mode 100644 index 00000000000..17fb8a249d9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/dr2714.cc @@ -0,0 +1,154 @@ +// Copyright (C) 2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void +test01() +{ + std::istringstream in(" 1 (2) ( 2.0 , 0.5 ) "); + std::complex c1, c2, c3; + in >> c1 >> c2 >> c3; + VERIFY( in.good() ); + VERIFY( c1.real() == 1 && c1.imag() == 0 ); + VERIFY( c2.real() == 2 && c2.imag() == 0 ); + VERIFY( c3.real() == 2 && c3.imag() == 0.5 ); +} + +void +test02() +{ + std::istringstream in; + std::complex c(-1, -1); + const std::complex c0 = c; + + in.str("a"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'a' ); + + in.str(" ( ) "); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == ')' ); + + in.str("(,"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == ',' ); + + in.str("(b)"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'b' ); + + in.str("( c)"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'c' ); + + in.str("(99d"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'd' ); + + in.str("(99 e"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'e' ); + + in.str("(99, f"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'f' ); + + in.str("(99, 88g"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'g' ); + + in.str("(99, 88 h"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == 'h' ); + + in.str("(99, )"); + in >> c; + VERIFY( in.fail() ); + in.clear(); + VERIFY( in.get() == ')' ); + + VERIFY( c == c0 ); +} + +void +test03() +{ + // PR libstdc++/59568 + std::istringstream in; + std::complex c; + + in.str(""); + in >> c; + VERIFY( in.fail() ); + VERIFY( in.eof() ); + in.clear(); + + in.str(" "); + in >> c; + VERIFY( in.fail() ); + VERIFY( in.eof() ); + in.clear(); + + in.str("(99"); + in >> c; + VERIFY( in.fail() ); + VERIFY( in.eof() ); + in.clear(); + + in.str("(99,"); + in >> c; + VERIFY( in.fail() ); + VERIFY( in.eof() ); + in.clear(); + + in.str("(99,99"); + in >> c; + VERIFY( in.fail() ); + VERIFY( in.eof() ); + in.clear(); +} + +int +main() +{ + test01(); + test02(); + test03(); +}