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/macros/config.h"
12 #include "src/__support/str_to_integer.h"
13 #include "src/errno/libc_errno.h"
15 #include "StrtolTest.h"
16 #include "test/UnitTest/Test.h"
18 namespace LIBC_NAMESPACE_DECL
{
20 int64_t strtoint64(const char *__restrict str
, char **__restrict str_end
,
22 auto result
= internal::strtointeger
<int64_t>(str
, base
);
23 if (result
.has_error())
24 LIBC_NAMESPACE::libc_errno
= result
.error
;
26 if (str_end
!= nullptr)
27 *str_end
= const_cast<char *>(str
+ result
.parsed_len
);
32 uint64_t strtouint64(const char *__restrict str
, char **__restrict str_end
,
34 auto result
= internal::strtointeger
<uint64_t>(str
, base
);
35 if (result
.has_error())
36 LIBC_NAMESPACE::libc_errno
= result
.error
;
38 if (str_end
!= nullptr)
39 *str_end
= const_cast<char *>(str
+ result
.parsed_len
);
43 } // namespace LIBC_NAMESPACE_DECL
45 STRTOL_TEST(Strtoint64
, LIBC_NAMESPACE::strtoint64
)
46 STRTOL_TEST(Strtouint64
, LIBC_NAMESPACE::strtouint64
)