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 // XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7
11 // XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8
15 // long stol(const string& str, size_t *idx = 0, int base = 10);
16 // long stol(const wstring& str, size_t *idx = 0, int base = 10);
21 #include "test_macros.h"
25 assert(std::stol("0") == 0);
26 assert(std::stol(L"0") == 0);
27 assert(std::stol("-0") == 0);
28 assert(std::stol(L"-0") == 0);
29 assert(std::stol("-10") == -10);
30 assert(std::stol(L"-10") == -10);
31 assert(std::stol(" 10") == 10);
32 assert(std::stol(L" 10") == 10);
34 assert(std::stol("10g", &idx, 16) == 16);
37 assert(std::stol(L"10g", &idx, 16) == 16);
39 #ifndef TEST_HAS_NO_EXCEPTIONS
46 catch (const std::invalid_argument&)
55 catch (const std::invalid_argument&)
61 std::stol(" - 8", &idx);
64 catch (const std::invalid_argument&)
70 std::stol(L" - 8", &idx);
73 catch (const std::invalid_argument&)
79 std::stol("a1", &idx);
82 catch (const std::invalid_argument&)
88 std::stol(L"a1", &idx);
91 catch (const std::invalid_argument&)
98 std::stol("9999999999999999999999999999999999999999999999999", &idx);
101 catch (const std::out_of_range&)
107 std::stol(L"9999999999999999999999999999999999999999999999999", &idx);
110 catch (const std::out_of_range&)