Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / test / src / stdlib / strtoint64_test.cpp
blobf8d807b146f2ec4e0a8916639f2c9687d8e486b6
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/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,
20 int base) {
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);
28 return result;
31 uint64_t strtouint64(const char *__restrict str, char **__restrict str_end,
32 int base) {
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);
40 return result;
42 } // namespace LIBC_NAMESPACE
44 STRTOL_TEST(Strtoint64, LIBC_NAMESPACE::strtoint64)
45 STRTOL_TEST(Strtouint64, LIBC_NAMESPACE::strtouint64)