mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 04:51:26 +12:00
rsx/util/test: Cover edge cases in address_range test suite
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
This commit is contained in:
parent
45718d7679
commit
2d9a24d1d6
3 changed files with 50 additions and 1 deletions
|
@ -81,7 +81,8 @@ namespace utils
|
|||
return {};
|
||||
}
|
||||
|
||||
return {_start, _start + (_length - 1)};
|
||||
const T _end = static_cast<T>(_start + _length - 1);
|
||||
return {_start, _end};
|
||||
}
|
||||
|
||||
static constexpr address_range start_end(T _start, T _end)
|
||||
|
|
|
@ -200,6 +200,7 @@ if(BUILD_RPCS3_TESTS)
|
|||
tests/test.cpp
|
||||
tests/test_fmt.cpp
|
||||
tests/test_simple_array.cpp
|
||||
tests/test_address_range.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(rpcs3_test
|
||||
|
|
|
@ -447,4 +447,51 @@ namespace utils
|
|||
EXPECT_EQ(hasher(r1), hasher(r2));
|
||||
EXPECT_NE(hasher(r1), hasher(r3));
|
||||
}
|
||||
|
||||
// Test invalidation rules around umax
|
||||
TEST(AddressRange, Invalidate32)
|
||||
{
|
||||
address_range32 r1 = address_range32::start_length(0x0, 0x1000);
|
||||
r1.invalidate();
|
||||
|
||||
EXPECT_FALSE(r1.valid());
|
||||
EXPECT_EQ(r1.start, 0xffff'ffffu);
|
||||
EXPECT_EQ(r1.end, 0u);
|
||||
}
|
||||
|
||||
TEST(AddressRange, Invalidate64)
|
||||
{
|
||||
address_range64 r1 = address_range64::start_length(0x0, 0x1000);
|
||||
r1.invalidate();
|
||||
|
||||
EXPECT_FALSE(r1.valid());
|
||||
EXPECT_EQ(r1.start, 0xffff'ffff'ffff'ffffull);
|
||||
EXPECT_EQ(r1.end, 0ull);
|
||||
}
|
||||
|
||||
TEST(AddressRange, Invalidate16)
|
||||
{
|
||||
const u16 start = 0x1000, length = 0x1000;
|
||||
address_range16 r1 = address_range16::start_length(start, length);
|
||||
r1.invalidate();
|
||||
|
||||
EXPECT_FALSE(r1.valid());
|
||||
EXPECT_EQ(r1.start, 0xffff);
|
||||
EXPECT_EQ(r1.end, 0);
|
||||
}
|
||||
|
||||
TEST(AddressRange, InvalidConstruction)
|
||||
{
|
||||
address_range32 r1 = address_range32::start_length(umax, u32{umax} / 2);
|
||||
EXPECT_FALSE(r1.valid());
|
||||
}
|
||||
|
||||
TEST(AddressRange, LargeValues64)
|
||||
{
|
||||
const u32 start = umax, length = u32{umax} / 2;
|
||||
address_range64 r1 = address_range64::start_length(start, length);
|
||||
|
||||
EXPECT_EQ(r1.start, 0xffff'ffffull);
|
||||
EXPECT_EQ(r1.end, 0x1'7fff'fffd);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue