blob: eacd0d02b1153711d9132f69e3e793ce0075f135 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <AK/Endian.h>
static_assert(BigEndian<u32> {} == 0, "Big endian values should be default constructed in a constexpr context.");
static_assert(BigEndian<u32> { 42 } == 42, "Big endian values should be value constructed in a constexpr context.");
static_assert(LittleEndian<u32> {} == 0, "Little endian values should be default constructed in a constexpr context.");
static_assert(LittleEndian<u32> { 42 } == 42, "Little endian values should be value constructed in a constexpr context.");
enum class Enum8 : u8 { Element = 1 };
static_assert(BigEndian<Enum8> { Enum8::Element } == Enum8::Element);
static_assert(LittleEndian<Enum8> { Enum8::Element } == Enum8::Element);
enum class Enum16 : u16 { Element = 2 };
static_assert(BigEndian<Enum16> { Enum16::Element } == Enum16::Element);
static_assert(LittleEndian<Enum16> { Enum16::Element } == Enum16::Element);
enum class Enum32 : u32 { Element = 3 };
static_assert(BigEndian<Enum32> { Enum32::Element } == Enum32::Element);
static_assert(LittleEndian<Enum32> { Enum32::Element } == Enum32::Element);
enum class Enum64 : u64 { Element = 4 };
static_assert(BigEndian<Enum64> { Enum64::Element } == Enum64::Element);
static_assert(LittleEndian<Enum64> { Enum64::Element } == Enum64::Element);
|