2014-03-09 13:27:04 +00:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-03-09 13:27:04 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "Common/CommonFuncs.h"
|
|
|
|
|
2015-09-04 03:39:03 +00:00
|
|
|
TEST(CommonFuncs, ArraySizeFunction)
|
2014-03-09 13:27:04 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
char test[4];
|
|
|
|
u32 test2[42];
|
2014-03-09 13:27:04 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPECT_EQ(4u, ArraySize(test));
|
|
|
|
EXPECT_EQ(42u, ArraySize(test2));
|
2014-08-31 12:52:21 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
(void)test;
|
|
|
|
(void)test2;
|
2014-03-09 13:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommonFuncs, RoundUpPow2Macro)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPECT_EQ(4, ROUND_UP_POW2(3));
|
|
|
|
EXPECT_EQ(4, ROUND_UP_POW2(4));
|
|
|
|
EXPECT_EQ(8, ROUND_UP_POW2(6));
|
|
|
|
EXPECT_EQ(0x40000000, ROUND_UP_POW2(0x23456789));
|
2014-03-09 13:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommonFuncs, CrashMacro)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPECT_DEATH({ Crash(); }, "");
|
2014-03-09 13:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommonFuncs, Swap)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
EXPECT_EQ(0xf0, Common::swap8(0xf0));
|
|
|
|
EXPECT_EQ(0x1234, Common::swap16(0x3412));
|
|
|
|
EXPECT_EQ(0x12345678u, Common::swap32(0x78563412));
|
|
|
|
EXPECT_EQ(0x123456789abcdef0ull, Common::swap64(0xf0debc9a78563412ull));
|
2014-03-09 13:27:04 +00:00
|
|
|
}
|