xref: /llvm-project/libcxx/test/std/depr/depr.c.headers/time_h.compile.pass.cpp (revision 9dfb142ce0bfa11ea7cd9176c27b6c0fca7243e0)
1dafeb97aSLouis Dionne //===----------------------------------------------------------------------===//
2dafeb97aSLouis Dionne //
3dafeb97aSLouis Dionne // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4dafeb97aSLouis Dionne // See https://llvm.org/LICENSE.txt for license information.
5dafeb97aSLouis Dionne // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6dafeb97aSLouis Dionne //
7dafeb97aSLouis Dionne //===----------------------------------------------------------------------===//
8dafeb97aSLouis Dionne 
9dafeb97aSLouis Dionne // test <time.h>
10dafeb97aSLouis Dionne 
11dafeb97aSLouis Dionne #include <time.h>
12*9dfb142cSLouis Dionne 
13*9dfb142cSLouis Dionne #include "test_macros.h"
14dafeb97aSLouis Dionne 
15dafeb97aSLouis Dionne #ifndef NULL
16dafeb97aSLouis Dionne #error NULL not defined
17dafeb97aSLouis Dionne #endif
18dafeb97aSLouis Dionne 
19dafeb97aSLouis Dionne #ifndef CLOCKS_PER_SEC
20dafeb97aSLouis Dionne #error CLOCKS_PER_SEC not defined
21dafeb97aSLouis Dionne #endif
22dafeb97aSLouis Dionne 
23dafeb97aSLouis Dionne clock_t c = 0;
24dafeb97aSLouis Dionne size_t s = 0;
25dafeb97aSLouis Dionne time_t t = 0;
26dafeb97aSLouis Dionne tm tmv = {};
27dafeb97aSLouis Dionne char* c1 = 0;
28dafeb97aSLouis Dionne const char* c2 = 0;
29*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(clock_t, decltype(clock()));
30*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(double,  decltype(difftime(t, t)));
31*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(time_t,  decltype(mktime(&tmv)));
32*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(time_t,  decltype(time(&t)));
33*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(char*,   decltype(asctime(&tmv)));
34*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(char*,   decltype(ctime(&t)));
35*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(tm*,     decltype(gmtime(&t)));
36*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(tm*,     decltype(localtime(&t)));
37*9dfb142cSLouis Dionne ASSERT_SAME_TYPE(size_t,  decltype(strftime(c1, s, c2, &tmv)));
38