ladybird/AK/Tests/TestBitCast.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

25 lines
564 B
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/TestSuite.h>
#include <AK/BitCast.h>
template<typename A, typename B>
void check_cast_both_ways(const A& a, const B& b)
{
EXPECT_EQ((bit_cast<A, B>(b)), a);
EXPECT_EQ((bit_cast<B, A>(a)), b);
}
TEST_CASE(double_int_conversion)
{
check_cast_both_ways(static_cast<u64>(0), 0.0);
check_cast_both_ways(static_cast<u64>(1) << 63, -0.0);
check_cast_both_ways(static_cast<u64>(0x4172f58bc0000000), 19880124.0);
}
TEST_MAIN(BitCast)