dolphin/Source/UnitTests/Core/PowerPC/DivUtilsTest.cpp
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00

33 lines
902 B
C++

// Copyright 2021 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <gtest/gtest.h>
#include "Core/PowerPC/JitCommon/DivUtils.h"
using namespace JitCommon;
TEST(DivUtils, Signed)
{
Magic m3 = SignedDivisionConstants(3);
Magic m5 = SignedDivisionConstants(5);
Magic m7 = SignedDivisionConstants(7);
Magic minus3 = SignedDivisionConstants(-3);
Magic minus5 = SignedDivisionConstants(-5);
Magic minus7 = SignedDivisionConstants(-7);
EXPECT_EQ(0x55555556, m3.multiplier);
EXPECT_EQ(0, m3.shift);
EXPECT_EQ(0x66666667, m5.multiplier);
EXPECT_EQ(1, m5.shift);
EXPECT_EQ(-0x6DB6DB6D, m7.multiplier);
EXPECT_EQ(2, m7.shift);
EXPECT_EQ(-0x55555556, minus3.multiplier);
EXPECT_EQ(0, minus3.shift);
EXPECT_EQ(-0x66666667, minus5.multiplier);
EXPECT_EQ(1, minus5.shift);
EXPECT_EQ(0x6DB6DB6D, minus7.multiplier);
EXPECT_EQ(2, minus7.shift);
}