Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / libc / test / src / stdlib / strtoint64_test.cpp
blobb5fe69dfaa701b12650fa43eb183cd021dbf3232
1 //===-- Unittests for strtoint64 ------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include <stdint.h>
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,
21 int base) {
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);
29 return result;
32 uint64_t strtouint64(const char *__restrict str, char **__restrict str_end,
33 int base) {
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);
41 return result;
43 } // namespace LIBC_NAMESPACE_DECL
45 STRTOL_TEST(Strtoint64, LIBC_NAMESPACE::strtoint64)
46 STRTOL_TEST(Strtouint64, LIBC_NAMESPACE::strtouint64)