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 // long long stoll(const string& str, size_t *idx = 0, int base = 10);
17 // long long stoll(const wstring& str, size_t *idx = 0, int base = 10);
22 #include "test_macros.h"
26 assert(std::stoll("0") == 0);
27 assert(std::stoll(L"0") == 0);
28 assert(std::stoll("-0") == 0);
29 assert(std::stoll(L"-0") == 0);
30 assert(std::stoll("-10") == -10);
31 assert(std::stoll(L"-10") == -10);
32 assert(std::stoll(" 10") == 10);
33 assert(std::stoll(L" 10") == 10);
35 assert(std::stoll("10g", &idx, 16) == 16);
38 assert(std::stoll(L"10g", &idx, 16) == 16);
40 #ifndef TEST_HAS_NO_EXCEPTIONS
47 catch (const std::invalid_argument&)
53 std::stoll(L"", &idx);
56 catch (const std::invalid_argument&)
62 std::stoll(" - 8", &idx);
65 catch (const std::invalid_argument&)
71 std::stoll(L" - 8", &idx);
74 catch (const std::invalid_argument&)
80 std::stoll("a1", &idx);
83 catch (const std::invalid_argument&)
89 std::stoll(L"a1", &idx);
92 catch (const std::invalid_argument&)
98 std::stoll("99999999999999999999999999", &idx);
101 catch (const std::out_of_range&)
107 std::stoll(L"99999999999999999999999999", &idx);
110 catch (const std::out_of_range&)