diff options
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t')
9 files changed, 1305 insertions, 0 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc new file mode 100644 index 000000000..c5c7bdd44 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc @@ -0,0 +1,139 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stod(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stod(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + double d1 = 0.0; + size_t idx1 = 0; + try + { + wstring one(L"2.0a"); + d1 = stod(one, &idx1); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( d1 == 2.0 ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(L"1e"); + one.append(2 * numeric_limits<double>::max_exponent10, L'9'); + d1 = stod(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( d1 == 2.0 ); + + try + { + long double ld0 = numeric_limits<double>::max() / 100.0; + wstring one(to_wstring(ld0)); + stod(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + + if ((numeric_limits<long double>::max() / 10000.0L) + > numeric_limits<double>::max()) + { + test = false; + d1 = -1.0; + try + { + long double ld1 = numeric_limits<double>::max(); + ld1 *= 100.0; + wstring one(to_wstring(ld1)); + d1 = stod(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( d1 == -1.0 ); + } + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc new file mode 100644 index 000000000..ffc0867b5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc @@ -0,0 +1,139 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stof(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stof(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + float f1 = 0.0f; + size_t idx1 = 0; + try + { + wstring one(L"2.0a"); + f1 = stof(one, &idx1); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( f1 == 2.0f ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(L"1e"); + one.append(2 * numeric_limits<float>::max_exponent10, L'9'); + f1 = stof(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( f1 == 2.0f ); + + try + { + long double ld0 = numeric_limits<float>::max() / 100.0; + wstring one(to_wstring(ld0)); + stof(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + + if ((numeric_limits<long double>::max() / 10000.0L) + > numeric_limits<float>::max()) + { + test = false; + f1 = -1.0f; + try + { + long double ld1 = numeric_limits<float>::max(); + ld1 *= 100.0; + wstring one(to_wstring(ld1)); + f1 = stof(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( f1 == -1.0f ); + } + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc new file mode 100644 index 000000000..b37cc757b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc @@ -0,0 +1,204 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stoi(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stoi(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + int i1 = 0; + try + { + wstring one(L"a"); + i1 = stoi(one, 0, 16); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( i1 == 10 ); + + size_t idx1 = 0; + try + { + wstring one(L"78"); + i1 = stoi(one, &idx1, 8); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( i1 == 7 ); + VERIFY( idx1 = 1 ); + + try + { + wstring one(L"10112"); + i1 = stoi(one, &idx1, 2); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( i1 == 11 ); + VERIFY( idx1 == 4 ); + + try + { + wstring one(L"0XE"); + i1 = stoi(one, &idx1, 0); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( i1 == 14 ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(1000, L'9'); + i1 = stoi(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( i1 == 14 ); + + try + { + i1 = numeric_limits<int>::max(); + wstring one(to_wstring((long long)i1)); + i1 = stoi(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( i1 == numeric_limits<int>::max() ); + + try + { + i1 = numeric_limits<int>::min(); + wstring one(to_wstring((long long)i1)); + i1 = stoi(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( i1 == numeric_limits<int>::min() ); + + test = false; + i1 = 1; + try + { + long long ll0 = numeric_limits<int>::max(); + ++ll0; + wstring one(to_wstring(ll0)); + i1 = stoi(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( i1 == 1 ); + + test = false; + try + { + long long ll1 = numeric_limits<int>::min(); + --ll1; + wstring one(to_wstring(ll1)); + i1 = stoi(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( i1 == 1 ); + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc new file mode 100644 index 000000000..3cd3df677 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc @@ -0,0 +1,167 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stol(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stol(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + long l1 = 0; + try + { + wstring one(L"a"); + l1 = stol(one, 0, 16); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( l1 == 10 ); + + size_t idx1 = 0; + try + { + wstring one(L"78"); + l1 = stol(one, &idx1, 8); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( l1 == 7 ); + VERIFY( idx1 = 1 ); + + try + { + wstring one(L"10112"); + l1 = stol(one, &idx1, 2); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( l1 == 11 ); + VERIFY( idx1 == 4 ); + + try + { + wstring one(L"0XE"); + l1 = stol(one, &idx1, 0); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( l1 == 14 ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(1000, L'9'); + l1 = stol(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( l1 == 14 ); + + try + { + l1 = numeric_limits<long>::max(); + wstring one(to_wstring((long long)l1)); + l1 = stol(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( l1 == numeric_limits<long>::max() ); + + try + { + l1 = numeric_limits<long>::min(); + wstring one(to_wstring((long long)l1)); + l1 = stol(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( l1 == numeric_limits<long>::min() ); + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc new file mode 100644 index 000000000..4757f0c08 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc @@ -0,0 +1,116 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stold(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stold(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + long double ld1 = 0.0L; + size_t idx1 = 0; + try + { + wstring one(L"2.0a"); + ld1 = stold(one, &idx1); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ld1 == 2.0L ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(L"1e"); + one.append(2 * numeric_limits<long double>::max_exponent10, L'9'); + ld1 = stold(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( ld1 == 2.0L ); + + try + { + long double ld0 = numeric_limits<long double>::max() / 100.0L; + wstring one(to_wstring(ld0)); + stold(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc new file mode 100644 index 000000000..55f484a57 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc @@ -0,0 +1,167 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stoll(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stoll(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + long long ll1 = 0; + try + { + wstring one(L"a"); + ll1 = stoll(one, 0, 16); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ll1 == 10 ); + + size_t idx1 = 0; + try + { + wstring one(L"78"); + ll1 = stoll(one, &idx1, 8); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ll1 == 7 ); + VERIFY( idx1 = 1 ); + + try + { + wstring one(L"10112"); + ll1 = stoll(one, &idx1, 2); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ll1 == 11 ); + VERIFY( idx1 == 4 ); + + try + { + wstring one(L"0XE"); + ll1 = stoll(one, &idx1, 0); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ll1 == 14 ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(1000, L'9'); + ll1 = stoll(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( ll1 == 14 ); + + try + { + ll1 = numeric_limits<long long>::max(); + wstring one(to_wstring(ll1)); + ll1 = stoll(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ll1 == numeric_limits<long long>::max() ); + + try + { + ll1 = numeric_limits<long long>::min(); + wstring one(to_wstring(ll1)); + ll1 = stoll(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ll1 == numeric_limits<long long>::min() ); + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc new file mode 100644 index 000000000..5498a9620 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc @@ -0,0 +1,154 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stoul(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stoul(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + unsigned long ul1 = 0; + try + { + wstring one(L"a"); + ul1 = stoul(one, 0, 16); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ul1 == 10 ); + + size_t idx1 = 0; + try + { + wstring one(L"78"); + ul1 = stoul(one, &idx1, 8); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ul1 == 7 ); + VERIFY( idx1 = 1 ); + + try + { + wstring one(L"10112"); + ul1 = stoul(one, &idx1, 2); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ul1 == 11 ); + VERIFY( idx1 == 4 ); + + try + { + wstring one(L"0XE"); + ul1 = stoul(one, &idx1, 0); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ul1 == 14 ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(1000, L'9'); + ul1 = stoul(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( ul1 == 14 ); + + try + { + ul1 = numeric_limits<unsigned long>::max(); + wstring one(to_wstring((unsigned long long)ul1)); + ul1 = stoul(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ul1 == numeric_limits<unsigned long>::max() ); + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc new file mode 100644 index 000000000..f2d8fb172 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc @@ -0,0 +1,154 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <limits> +#include <stdexcept> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = false; + using namespace std; + + try + { + wstring one; + stoull(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + test = false; + try + { + wstring one(L"a"); + stoull(one); + } + catch(std::invalid_argument) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + + unsigned long long ull1 = 0; + try + { + wstring one(L"a"); + ull1 = stoull(one, 0, 16); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ull1 == 10 ); + + size_t idx1 = 0; + try + { + wstring one(L"78"); + ull1 = stoull(one, &idx1, 8); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ull1 == 7 ); + VERIFY( idx1 = 1 ); + + try + { + wstring one(L"10112"); + ull1 = stoull(one, &idx1, 2); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ull1 == 11 ); + VERIFY( idx1 == 4 ); + + try + { + wstring one(L"0XE"); + ull1 = stoull(one, &idx1, 0); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ull1 == 14 ); + VERIFY( idx1 == 3 ); + + test = false; + try + { + wstring one(1000, L'9'); + ull1 = stoull(one); + } + catch(std::out_of_range) + { + test = true; + } + catch(...) + { + } + VERIFY( test ); + VERIFY( ull1 == 14 ); + + try + { + ull1 = numeric_limits<unsigned long long>::max(); + wstring one(to_wstring(ull1)); + ull1 = stoull(one); + } + catch(...) + { + test = false; + } + VERIFY( test ); + VERIFY( ull1 == numeric_limits<unsigned long long>::max() ); + +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc new file mode 100644 index 000000000..dd46736ea --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.4 Numeric Conversions [string.conversions] + +#include <string> +#include <testsuite_hooks.h> + +void +test01() +{ +#ifdef _GLIBCXX_USE_C99 + + bool test __attribute__((unused)) = true; + using namespace std; + + long long ll1 = -2; + wstring one(to_wstring(ll1)); + VERIFY( one == L"-2" ); + + long long ll2 = 10; + wstring two(to_wstring(ll2)); + VERIFY( two == L"10" ); + + unsigned long long ull1 = 2; + wstring three(to_wstring(ull1)); + VERIFY( three == L"2" ); + + unsigned long long ull2 = 3000; + wstring four(to_wstring(ull2)); + VERIFY( four == L"3000" ); + + long double ld1 = 2.0L; + wstring five(to_wstring(ld1)); + VERIFY( five == L"2.000000" ); + + long double ld2 = -4.0L; + wstring six(to_wstring(ld2)); + VERIFY( six == L"-4.000000" ); + +#endif +} + +int main() +{ + test01(); + return 0; +} |