[clang][Driver][SPIR-V] Make tool names consistent (#122343)
[llvm-project.git] / libcxx / test / std / time / time.hms / time.hms.members / width.pass.cpp
blobadee920621f5bcd99c2ecd843bf5e6abad62a0fd
1 //===----------------------------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9 // <chrono>
11 // template <class Duration>
12 // class hh_mm_ss
13 // {
14 // public:
15 // static unsigned constexpr fractional_width = see below;
16 // using precision = see below;
18 // fractional_width is the number of fractional decimal digits represented by precision.
19 // fractional_width has the value of the smallest possible integer in the range [0, 18]
20 // such that precision will exactly represent all values of Duration.
21 // If no such value of fractional_width exists, then fractional_width is 6.
24 #include <chrono>
25 #include <cassert>
26 #include <ratio>
28 #include "test_macros.h"
30 template <typename Duration, unsigned width>
31 constexpr bool check_width()
33 using HMS = std::chrono::hh_mm_ss<Duration>;
34 return HMS::fractional_width == width;
37 int main(int, char**)
39 using microfortnights = std::chrono::duration<int, std::ratio<756, 625>>;
41 static_assert( check_width<std::chrono::hours, 0>(), "");
42 static_assert( check_width<std::chrono::minutes, 0>(), "");
43 static_assert( check_width<std::chrono::seconds, 0>(), "");
44 static_assert( check_width<std::chrono::milliseconds, 3>(), "");
45 static_assert( check_width<std::chrono::microseconds, 6>(), "");
46 static_assert( check_width<std::chrono::nanoseconds, 9>(), "");
47 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 2>>, 1>(), "");
48 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 3>>, 6>(), "");
49 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 4>>, 2>(), "");
50 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 5>>, 1>(), "");
51 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 6>>, 6>(), "");
52 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 7>>, 6>(), "");
53 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 8>>, 3>(), "");
54 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 9>>, 6>(), "");
55 static_assert( check_width<std::chrono::duration<int, std::ratio< 1, 10>>, 1>(), "");
56 static_assert( check_width<microfortnights, 4>(), "");
58 return 0;