[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / numerics / bit / bit.endian / endian.pass.cpp
blobd680fafc4aebe1f7f0710c1dde7db8838b7a438b
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
11 // enum class endian;
12 // <bit>
14 #include <bit>
15 #include <cstring>
16 #include <cassert>
17 #include <cstdint>
19 #include "test_macros.h"
21 int main(int, char**) {
22 static_assert(std::is_enum<std::endian>::value, "");
24 // Check that E is a scoped enum by checking for conversions.
25 typedef std::underlying_type<std::endian>::type UT;
26 static_assert(!std::is_convertible<std::endian, UT>::value, "");
28 // test that the enumeration values exist
29 static_assert( std::endian::little == std::endian::little );
30 static_assert( std::endian::big == std::endian::big );
31 static_assert( std::endian::native == std::endian::native );
32 static_assert( std::endian::little != std::endian::big );
34 // Technically not required, but true on all existing machines
35 static_assert( std::endian::native == std::endian::little ||
36 std::endian::native == std::endian::big );
38 // Try to check at runtime
40 uint32_t i = 0x01020304;
41 char c[4];
42 static_assert(sizeof(i) == sizeof(c));
43 std::memcpy(c, &i, sizeof(c));
45 assert ((c[0] == 1) == (std::endian::native == std::endian::big));
48 return 0;