1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // PR14919 was fixed in r172447, out_of_range wasn't thrown before.
11 // XFAIL: with_system_cxx_lib=macosx10.7
12 // XFAIL: with_system_cxx_lib=macosx10.8
16 // unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
17 // unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10);
22 #include "test_macros.h"
26 assert(std::stoull("0") == 0);
27 assert(std::stoull(L"0") == 0);
28 assert(std::stoull("-0") == 0);
29 assert(std::stoull(L"-0") == 0);
30 assert(std::stoull(" 10") == 10);
31 assert(std::stoull(L" 10") == 10);
33 assert(std::stoull("10g", &idx, 16) == 16);
36 assert(std::stoull(L"10g", &idx, 16) == 16);
38 #ifndef TEST_HAS_NO_EXCEPTIONS
42 std::stoull("", &idx);
45 catch (const std::invalid_argument&)
52 std::stoull(L"", &idx);
55 catch (const std::invalid_argument&)
61 std::stoull(" - 8", &idx);
64 catch (const std::invalid_argument&)
70 std::stoull(L" - 8", &idx);
73 catch (const std::invalid_argument&)
79 std::stoull("a1", &idx);
82 catch (const std::invalid_argument&)
88 std::stoull(L"a1", &idx);
91 catch (const std::invalid_argument&)
98 std::stoull("9999999999999999999999999999999999999999999999999", &idx);
101 catch (const std::out_of_range&)
107 std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
110 catch (const std::out_of_range&)