mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-10 12:21:39 +00:00
Add more tests for Common and Core/MMIO
This commit is contained in:
parent
2e70ff2441
commit
aabd524142
7 changed files with 240 additions and 0 deletions
46
Source/UnitTests/Common/CommonFuncsTest.cpp
Normal file
46
Source/UnitTests/Common/CommonFuncsTest.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2014 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "Common/CommonFuncs.h"
|
||||
|
||||
TEST(CommonFuncs, ArraySizeMacro)
|
||||
{
|
||||
char test[4];
|
||||
u32 test2[42];
|
||||
|
||||
EXPECT_EQ(4, ArraySize(test));
|
||||
EXPECT_EQ(42, ArraySize(test2));
|
||||
}
|
||||
|
||||
TEST(CommonFuncs, RoundUpPow2Macro)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
TEST(CommonFuncs, CrashMacro)
|
||||
{
|
||||
EXPECT_DEATH({ Crash(); }, "");
|
||||
}
|
||||
|
||||
TEST(CommonFuncs, MinMax)
|
||||
{
|
||||
EXPECT_EQ(4, min(4, 5));
|
||||
EXPECT_EQ(-1, min(-1, 1));
|
||||
|
||||
EXPECT_EQ(5, max(4, 5));
|
||||
EXPECT_EQ(1, max(-1, 1));
|
||||
}
|
||||
|
||||
TEST(CommonFuncs, Swap)
|
||||
{
|
||||
EXPECT_EQ(0xf0, Common::swap8(0xf0));
|
||||
EXPECT_EQ(0x1234, Common::swap16(0x3412));
|
||||
EXPECT_EQ(0x12345678, Common::swap32(0x78563412));
|
||||
EXPECT_EQ(0x123456789abcdef0ull, Common::swap64(0xf0debc9a78563412ull));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue