brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 34a645f Raw
45 lines · cpp
1//===-- Unittests for ctime -----------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/time/ctime.h"10#include "test/UnitTest/ErrnoCheckingTest.h"11#include "test/UnitTest/Test.h"12#include "test/src/time/TmHelper.h"13 14using LlvmLibcCtime = LIBC_NAMESPACE::testing::ErrnoCheckingTest;15 16TEST_F(LlvmLibcCtime, nullptr) {17  char *result;18  result = LIBC_NAMESPACE::ctime(nullptr);19  ASSERT_STREQ(nullptr, result);20}21 22TEST_F(LlvmLibcCtime, ValidUnixTimestamp0) {23  time_t t;24  char *result;25  t = 0;26  result = LIBC_NAMESPACE::ctime(&t);27  ASSERT_STREQ("Thu Jan  1 00:00:00 1970\n", result);28}29 30TEST_F(LlvmLibcCtime, ValidUnixTimestamp32Int) {31  time_t t;32  char *result;33  t = 2147483647;34  result = LIBC_NAMESPACE::ctime(&t);35  ASSERT_STREQ("Tue Jan 19 03:14:07 2038\n", result);36}37 38TEST_F(LlvmLibcCtime, InvalidArgument) {39  time_t t;40  char *result;41  t = 2147483648;42  result = LIBC_NAMESPACE::ctime(&t);43  ASSERT_STREQ(nullptr, result);44}45