1 //===-- Unittests for strtoint64 ------------------------------------------===//
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 #include "src/__support/str_to_integer.h"
12 #include "src/errno/libc_errno.h"
14 #include "StrtolTest.h"
15 #include "test/UnitTest/Test.h"
17 namespace LIBC_NAMESPACE
{
19 int64_t strtoint64(const char *__restrict str
, char **__restrict str_end
,
21 auto result
= internal::strtointeger
<int64_t>(str
, base
);
22 if (result
.has_error())
23 libc_errno
= result
.error
;
25 if (str_end
!= nullptr)
26 *str_end
= const_cast<char *>(str
+ result
.parsed_len
);
31 uint64_t strtouint64(const char *__restrict str
, char **__restrict str_end
,
33 auto result
= internal::strtointeger
<uint64_t>(str
, base
);
34 if (result
.has_error())
35 libc_errno
= result
.error
;
37 if (str_end
!= nullptr)
38 *str_end
= const_cast<char *>(str
+ result
.parsed_len
);
42 } // namespace LIBC_NAMESPACE
44 STRTOL_TEST(Strtoint64
, LIBC_NAMESPACE::strtoint64
)
45 STRTOL_TEST(Strtouint64
, LIBC_NAMESPACE::strtouint64
)