1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
12 // unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10);
18 #include "test_macros.h"
20 int main(int, char**) {
21 assert(std::stoull("0") == 0);
22 assert(std::stoull("-0") == 0);
23 assert(std::stoull(" 10") == 10);
26 assert(std::stoull("10g", &idx
, 16) == 16);
29 #ifndef TEST_HAS_NO_EXCEPTIONS
33 (void)std::stoull("", &idx
);
35 } catch (const std::invalid_argument
&) {
42 (void)std::stoull(" - 8", &idx
);
44 } catch (const std::invalid_argument
&) {
51 (void)std::stoull("a1", &idx
);
53 } catch (const std::invalid_argument
&) {
60 // LWG#2009 and PR14919
61 (void)std::stoull("9999999999999999999999999999999999999999999999999", &idx
);
63 } catch (const std::out_of_range
&) {
67 #endif // TEST_HAS_NO_EXCEPTIONS
69 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
70 assert(std::stoull(L
"0") == 0);
71 assert(std::stoull(L
"-0") == 0);
72 assert(std::stoull(L
" 10") == 10);
75 assert(std::stoull(L
"10g", &idx
, 16) == 16);
78 # ifndef TEST_HAS_NO_EXCEPTIONS
82 (void)std::stoull(L
"", &idx
);
84 } catch (const std::invalid_argument
&) {
91 (void)std::stoull(L
" - 8", &idx
);
93 } catch (const std::invalid_argument
&) {
100 (void)std::stoull(L
"a1", &idx
);
102 } catch (const std::invalid_argument
&) {
109 // LWG#2009 and PR14919
110 (void)std::stoull(L
"9999999999999999999999999999999999999999999999999", &idx
);
112 } catch (const std::out_of_range
&) {
116 # endif // TEST_HAS_NO_EXCEPTIONS
117 #endif // TEST_HAS_NO_WIDE_CHARACTERS