diff options
Diffstat (limited to 'libcxx/test/strings/string.conversions')
-rw-r--r-- | libcxx/test/strings/string.conversions/stod.pass.cpp | 166 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stof.pass.cpp | 170 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stoi.pass.cpp | 108 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stol.pass.cpp | 111 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stold.pass.cpp | 168 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stoll.pass.cpp | 110 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stoul.pass.cpp | 109 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stoull.pass.cpp | 110 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/to_string.pass.cpp | 126 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/to_wstring.pass.cpp | 126 |
10 files changed, 0 insertions, 1304 deletions
diff --git a/libcxx/test/strings/string.conversions/stod.pass.cpp b/libcxx/test/strings/string.conversions/stod.pass.cpp deleted file mode 100644 index 026d2301e07..00000000000 --- a/libcxx/test/strings/string.conversions/stod.pass.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <string> - -// double stod(const string& str, size_t *idx = 0); -// double stod(const wstring& str, size_t *idx = 0); - -#include <string> -#include <cmath> -#include <cassert> - -int main() -{ - assert(std::stod("0") == 0); - assert(std::stod(L"0") == 0); - assert(std::stod("-0") == 0); - assert(std::stod(L"-0") == 0); - assert(std::stod("-10") == -10); - assert(std::stod(L"-10.5") == -10.5); - assert(std::stod(" 10") == 10); - assert(std::stod(L" 10") == 10); - size_t idx = 0; - assert(std::stod("10g", &idx) == 10); - assert(idx == 2); - idx = 0; - assert(std::stod(L"10g", &idx) == 10); - assert(idx == 2); - try - { - assert(std::stod("1.e60", &idx) == 1.e60); - assert(idx == 5); - } - catch (const std::out_of_range&) - { - assert(false); - } - try - { - assert(std::stod(L"1.e60", &idx) == 1.e60); - assert(idx == 5); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::stod("1.e360", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stod(L"1.e360", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stod("INF", &idx) == INFINITY); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::stod(L"INF", &idx) == INFINITY); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::isnan(std::stod("NAN", &idx))); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::isnan(std::stod(L"NAN", &idx))); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - std::stod("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stod(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stod(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stod(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stod("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stod(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stof.pass.cpp b/libcxx/test/strings/string.conversions/stof.pass.cpp deleted file mode 100644 index 65809cb2cf1..00000000000 --- a/libcxx/test/strings/string.conversions/stof.pass.cpp +++ /dev/null @@ -1,170 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <string> - -// float stof(const string& str, size_t *idx = 0); -// float stof(const wstring& str, size_t *idx = 0); - -#include <string> -#include <cmath> -#include <cassert> - -int main() -{ - assert(std::stof("0") == 0); - assert(std::stof(L"0") == 0); - assert(std::stof("-0") == 0); - assert(std::stof(L"-0") == 0); - assert(std::stof("-10") == -10); - assert(std::stof(L"-10.5") == -10.5); - assert(std::stof(" 10") == 10); - assert(std::stof(L" 10") == 10); - size_t idx = 0; - assert(std::stof("10g", &idx) == 10); - assert(idx == 2); - idx = 0; - assert(std::stof(L"10g", &idx) == 10); - assert(idx == 2); - idx = 0; - try - { - assert(std::stof("1.e60", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stof(L"1.e60", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - idx = 0; - try - { - assert(std::stof("1.e360", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stof(L"1.e360", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stof("INF", &idx) == INFINITY); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::stof(L"INF", &idx) == INFINITY); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::isnan(std::stof("NAN", &idx))); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::isnan(std::stof(L"NAN", &idx))); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - std::stof("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stof(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stof(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stof(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stof("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stof(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stoi.pass.cpp b/libcxx/test/strings/string.conversions/stoi.pass.cpp deleted file mode 100644 index c2fc2103579..00000000000 --- a/libcxx/test/strings/string.conversions/stoi.pass.cpp +++ /dev/null @@ -1,108 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <string> - -// int stoi(const string& str, size_t *idx = 0, int base = 10); -// int stoi(const wstring& str, size_t *idx = 0, int base = 10); - -#include <string> -#include <cassert> - -int main() -{ - assert(std::stoi("0") == 0); - assert(std::stoi(L"0") == 0); - assert(std::stoi("-0") == 0); - assert(std::stoi(L"-0") == 0); - assert(std::stoi("-10") == -10); - assert(std::stoi(L"-10") == -10); - assert(std::stoi(" 10") == 10); - assert(std::stoi(L" 10") == 10); - size_t idx = 0; - assert(std::stoi("10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - assert(std::stoi(L"10g", &idx, 16) == 16); - assert(idx == 2); - if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max()) - { - try - { - std::stoi("0x100000000", &idx, 16); - assert(false); - } - catch (const std::out_of_range&) - { - } - try - { - std::stoi(L"0x100000000", &idx, 16); - assert(false); - } - catch (const std::out_of_range&) - { - } - } - idx = 0; - try - { - std::stoi("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoi(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoi(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoi(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoi("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoi(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stol.pass.cpp b/libcxx/test/strings/string.conversions/stol.pass.cpp deleted file mode 100644 index d1cd75dcf17..00000000000 --- a/libcxx/test/strings/string.conversions/stol.pass.cpp +++ /dev/null @@ -1,111 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <string> - -// long stol(const string& str, size_t *idx = 0, int base = 10); -// long stol(const wstring& str, size_t *idx = 0, int base = 10); - -#include <string> -#include <cassert> - -int main() -{ - assert(std::stol("0") == 0); - assert(std::stol(L"0") == 0); - assert(std::stol("-0") == 0); - assert(std::stol(L"-0") == 0); - assert(std::stol("-10") == -10); - assert(std::stol(L"-10") == -10); - assert(std::stol(" 10") == 10); - assert(std::stol(L" 10") == 10); - size_t idx = 0; - assert(std::stol("10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - assert(std::stol(L"10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - try - { - std::stol("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stol(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stol(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stol(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stol("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stol(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -// LWG issue #2009 - try - { - std::stol("9999999999999999999999999999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - std::stol(L"9999999999999999999999999999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stold.pass.cpp b/libcxx/test/strings/string.conversions/stold.pass.cpp deleted file mode 100644 index 93c59fe09a1..00000000000 --- a/libcxx/test/strings/string.conversions/stold.pass.cpp +++ /dev/null @@ -1,168 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <string> - -// long double stold(const string& str, size_t *idx = 0); -// long double stold(const wstring& str, size_t *idx = 0); - -#include <iostream> - -#include <string> -#include <cmath> -#include <cassert> - -int main() -{ - assert(std::stold("0") == 0); - assert(std::stold(L"0") == 0); - assert(std::stold("-0") == 0); - assert(std::stold(L"-0") == 0); - assert(std::stold("-10") == -10); - assert(std::stold(L"-10.5") == -10.5); - assert(std::stold(" 10") == 10); - assert(std::stold(L" 10") == 10); - size_t idx = 0; - assert(std::stold("10g", &idx) == 10); - assert(idx == 2); - idx = 0; - assert(std::stold(L"10g", &idx) == 10); - assert(idx == 2); - try - { - assert(std::stold("1.e60", &idx) == 1.e60L); - assert(idx == 5); - } - catch (const std::out_of_range&) - { - assert(false); - } - try - { - assert(std::stold(L"1.e60", &idx) == 1.e60L); - assert(idx == 5); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::stold("1.e6000", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stold(L"1.e6000", &idx) == INFINITY); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - assert(std::stold("INF", &idx) == INFINITY); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::stold(L"INF", &idx) == INFINITY); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::isnan(std::stold("NAN", &idx))); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - assert(std::isnan(std::stold(L"NAN", &idx))); - assert(idx == 3); - } - catch (const std::out_of_range&) - { - assert(false); - } - idx = 0; - try - { - std::stold("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stold(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stold(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stold(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stold("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stold(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stoll.pass.cpp b/libcxx/test/strings/string.conversions/stoll.pass.cpp deleted file mode 100644 index 11f15e1fd0f..00000000000 --- a/libcxx/test/strings/string.conversions/stoll.pass.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <string> - -// long long stoll(const string& str, size_t *idx = 0, int base = 10); -// long long stoll(const wstring& str, size_t *idx = 0, int base = 10); - -#include <string> -#include <cassert> - -int main() -{ - assert(std::stoll("0") == 0); - assert(std::stoll(L"0") == 0); - assert(std::stoll("-0") == 0); - assert(std::stoll(L"-0") == 0); - assert(std::stoll("-10") == -10); - assert(std::stoll(L"-10") == -10); - assert(std::stoll(" 10") == 10); - assert(std::stoll(L" 10") == 10); - size_t idx = 0; - assert(std::stoll("10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - assert(std::stoll(L"10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - try - { - std::stoll("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoll(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoll(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoll(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoll("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoll(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoll("99999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - std::stoll(L"99999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stoul.pass.cpp b/libcxx/test/strings/string.conversions/stoul.pass.cpp deleted file mode 100644 index fcd19e88355..00000000000 --- a/libcxx/test/strings/string.conversions/stoul.pass.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <string> - -// unsigned long stoul(const string& str, size_t *idx = 0, int base = 10); -// unsigned long stoul(const wstring& str, size_t *idx = 0, int base = 10); - -#include <string> -#include <cassert> - -int main() -{ - assert(std::stoul("0") == 0); - assert(std::stoul(L"0") == 0); - assert(std::stoul("-0") == 0); - assert(std::stoul(L"-0") == 0); - assert(std::stoul(" 10") == 10); - assert(std::stoul(L" 10") == 10); - size_t idx = 0; - assert(std::stoul("10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - assert(std::stoul(L"10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - try - { - std::stoul("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoul(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoul(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoul(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoul("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoul(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -// LWG issue #2009 - try - { - std::stoul("9999999999999999999999999999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - std::stoul(L"9999999999999999999999999999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/stoull.pass.cpp b/libcxx/test/strings/string.conversions/stoull.pass.cpp deleted file mode 100644 index b1a2f9f0978..00000000000 --- a/libcxx/test/strings/string.conversions/stoull.pass.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <string> - -// unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10); -// unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10); - -#include <string> -#include <cassert> - -int main() -{ - assert(std::stoull("0") == 0); - assert(std::stoull(L"0") == 0); - assert(std::stoull("-0") == 0); - assert(std::stoull(L"-0") == 0); - assert(std::stoull(" 10") == 10); - assert(std::stoull(L" 10") == 10); - size_t idx = 0; - assert(std::stoull("10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - assert(std::stoull(L"10g", &idx, 16) == 16); - assert(idx == 2); - idx = 0; - try - { - std::stoull("", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - idx = 0; - try - { - std::stoull(L"", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoull(" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoull(L" - 8", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoull("a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } - try - { - std::stoull(L"a1", &idx); - assert(false); - } - catch (const std::invalid_argument&) - { - assert(idx == 0); - } -// LWG issue #2009 - try - { - std::stoull("9999999999999999999999999999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } - try - { - std::stoull(L"9999999999999999999999999999999999999999999999999", &idx); - assert(false); - } - catch (const std::out_of_range&) - { - assert(idx == 0); - } -} diff --git a/libcxx/test/strings/string.conversions/to_string.pass.cpp b/libcxx/test/strings/string.conversions/to_string.pass.cpp deleted file mode 100644 index 05e5e4b922a..00000000000 --- a/libcxx/test/strings/string.conversions/to_string.pass.cpp +++ /dev/null @@ -1,126 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <string> - -// string to_string(int val); -// string to_string(unsigned val); -// string to_string(long val); -// string to_string(unsigned long val); -// string to_string(long long val); -// string to_string(unsigned long long val); -// string to_string(float val); -// string to_string(double val); -// string to_string(long double val); - -#include <string> -#include <cassert> -#include <sstream> - -template <class T> -void -test_signed() -{ - { - std::string s = std::to_string(T(0)); - assert(s.size() == 1); - assert(s[s.size()] == 0); - assert(s == "0"); - } - { - std::string s = std::to_string(T(12345)); - assert(s.size() == 5); - assert(s[s.size()] == 0); - assert(s == "12345"); - } - { - std::string s = std::to_string(T(-12345)); - assert(s.size() == 6); - assert(s[s.size()] == 0); - assert(s == "-12345"); - } - { - std::string s = std::to_string(std::numeric_limits<T>::max()); - assert(s.size() == std::numeric_limits<T>::digits10 + 1); - std::istringstream is(s); - T t(0); - is >> t; - assert(t == std::numeric_limits<T>::max()); - } - { - std::string s = std::to_string(std::numeric_limits<T>::min()); - std::istringstream is(s); - T t(0); - is >> t; - assert(t == std::numeric_limits<T>::min()); - } -} - -template <class T> -void -test_unsigned() -{ - { - std::string s = std::to_string(T(0)); - assert(s.size() == 1); - assert(s[s.size()] == 0); - assert(s == "0"); - } - { - std::string s = std::to_string(T(12345)); - assert(s.size() == 5); - assert(s[s.size()] == 0); - assert(s == "12345"); - } - { - std::string s = std::to_string(std::numeric_limits<T>::max()); - assert(s.size() == std::numeric_limits<T>::digits10 + 1); - std::istringstream is(s); - T t(0); - is >> t; - assert(t == std::numeric_limits<T>::max()); - } -} - -template <class T> -void -test_float() -{ - { - std::string s = std::to_string(T(0)); - assert(s.size() == 8); - assert(s[s.size()] == 0); - assert(s == "0.000000"); - } - { - std::string s = std::to_string(T(12345)); - assert(s.size() == 12); - assert(s[s.size()] == 0); - assert(s == "12345.000000"); - } - { - std::string s = std::to_string(T(-12345)); - assert(s.size() == 13); - assert(s[s.size()] == 0); - assert(s == "-12345.000000"); - } -} - -int main() -{ - test_signed<int>(); - test_signed<long>(); - test_signed<long long>(); - test_unsigned<unsigned>(); - test_unsigned<unsigned long>(); - test_unsigned<unsigned long long>(); - test_float<float>(); - test_float<double>(); - test_float<long double>(); -} diff --git a/libcxx/test/strings/string.conversions/to_wstring.pass.cpp b/libcxx/test/strings/string.conversions/to_wstring.pass.cpp deleted file mode 100644 index 281aa1a5e79..00000000000 --- a/libcxx/test/strings/string.conversions/to_wstring.pass.cpp +++ /dev/null @@ -1,126 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <string> - -// wstring to_wstring(int val); -// wstring to_wstring(unsigned val); -// wstring to_wstring(long val); -// wstring to_wstring(unsigned long val); -// wstring to_wstring(long long val); -// wstring to_wstring(unsigned long long val); -// wstring to_wstring(float val); -// wstring to_wstring(double val); -// wstring to_wstring(long double val); - -#include <string> -#include <cassert> -#include <sstream> - -template <class T> -void -test_signed() -{ - { - std::wstring s = std::to_wstring(T(0)); - assert(s.size() == 1); - assert(s[s.size()] == 0); - assert(s == L"0"); - } - { - std::wstring s = std::to_wstring(T(12345)); - assert(s.size() == 5); - assert(s[s.size()] == 0); - assert(s == L"12345"); - } - { - std::wstring s = std::to_wstring(T(-12345)); - assert(s.size() == 6); - assert(s[s.size()] == 0); - assert(s == L"-12345"); - } - { - std::wstring s = std::to_wstring(std::numeric_limits<T>::max()); - assert(s.size() == std::numeric_limits<T>::digits10 + 1); - std::wistringstream is(s); - T t(0); - is >> t; - assert(t == std::numeric_limits<T>::max()); - } - { - std::wstring s = std::to_wstring(std::numeric_limits<T>::min()); - std::wistringstream is(s); - T t(0); - is >> t; - assert(t == std::numeric_limits<T>::min()); - } -} - -template <class T> -void -test_unsigned() -{ - { - std::wstring s = std::to_wstring(T(0)); - assert(s.size() == 1); - assert(s[s.size()] == 0); - assert(s == L"0"); - } - { - std::wstring s = std::to_wstring(T(12345)); - assert(s.size() == 5); - assert(s[s.size()] == 0); - assert(s == L"12345"); - } - { - std::wstring s = std::to_wstring(std::numeric_limits<T>::max()); - assert(s.size() == std::numeric_limits<T>::digits10 + 1); - std::wistringstream is(s); - T t(0); - is >> t; - assert(t == std::numeric_limits<T>::max()); - } -} - -template <class T> -void -test_float() -{ - { - std::wstring s = std::to_wstring(T(0)); - assert(s.size() == 8); - assert(s[s.size()] == 0); - assert(s == L"0.000000"); - } - { - std::wstring s = std::to_wstring(T(12345)); - assert(s.size() == 12); - assert(s[s.size()] == 0); - assert(s == L"12345.000000"); - } - { - std::wstring s = std::to_wstring(T(-12345)); - assert(s.size() == 13); - assert(s[s.size()] == 0); - assert(s == L"-12345.000000"); - } -} - -int main() -{ - test_signed<int>(); - test_signed<long>(); - test_signed<long long>(); - test_unsigned<unsigned>(); - test_unsigned<unsigned long>(); - test_unsigned<unsigned long long>(); - test_float<float>(); - test_float<double>(); - test_float<long double>(); -} |