Remove building with NOCRYPTO option
[minix.git] / external / bsd / libc++ / dist / libcxx / test / strings / string.conversions / stoull.pass.cpp
blobb1a2f9f09780572a2edfb2a7ccc2064a881f703d
1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // XFAIL: with_system_lib=x86_64-apple-darwin11
11 // XFAIL: with_system_lib=x86_64-apple-darwin12
13 // <string>
15 // unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
16 // unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10);
18 #include <string>
19 #include <cassert>
21 int main()
23 assert(std::stoull("0") == 0);
24 assert(std::stoull(L"0") == 0);
25 assert(std::stoull("-0") == 0);
26 assert(std::stoull(L"-0") == 0);
27 assert(std::stoull(" 10") == 10);
28 assert(std::stoull(L" 10") == 10);
29 size_t idx = 0;
30 assert(std::stoull("10g", &idx, 16) == 16);
31 assert(idx == 2);
32 idx = 0;
33 assert(std::stoull(L"10g", &idx, 16) == 16);
34 assert(idx == 2);
35 idx = 0;
36 try
38 std::stoull("", &idx);
39 assert(false);
41 catch (const std::invalid_argument&)
43 assert(idx == 0);
45 idx = 0;
46 try
48 std::stoull(L"", &idx);
49 assert(false);
51 catch (const std::invalid_argument&)
53 assert(idx == 0);
55 try
57 std::stoull(" - 8", &idx);
58 assert(false);
60 catch (const std::invalid_argument&)
62 assert(idx == 0);
64 try
66 std::stoull(L" - 8", &idx);
67 assert(false);
69 catch (const std::invalid_argument&)
71 assert(idx == 0);
73 try
75 std::stoull("a1", &idx);
76 assert(false);
78 catch (const std::invalid_argument&)
80 assert(idx == 0);
82 try
84 std::stoull(L"a1", &idx);
85 assert(false);
87 catch (const std::invalid_argument&)
89 assert(idx == 0);
91 // LWG issue #2009
92 try
94 std::stoull("9999999999999999999999999999999999999999999999999", &idx);
95 assert(false);
97 catch (const std::out_of_range&)
99 assert(idx == 0);
103 std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
104 assert(false);
106 catch (const std::out_of_range&)
108 assert(idx == 0);