diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2014-03-02 04:44:56 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2014-03-03 00:25:41 +0100 |
| commit | d4ed4adacea53df3f511deb5e5cf84ce5c9b9b6e (patch) | |
| tree | 2ccfd19221af49c2b32cf121b9a9abd07e01ce86 /Source/UnitTests/Core | |
| parent | 747021e0c89d50f93ded1c9809fd33e14a4b3575 (diff) | |
Add the infrastructure required to easily add unit tests and test it with a very simple test file.
Diffstat (limited to 'Source/UnitTests/Core')
| -rw-r--r-- | Source/UnitTests/Core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | Source/UnitTests/Core/MMIOTest.cpp | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Source/UnitTests/Core/CMakeLists.txt b/Source/UnitTests/Core/CMakeLists.txt new file mode 100644 index 0000000000..e52290e387 --- /dev/null +++ b/Source/UnitTests/Core/CMakeLists.txt @@ -0,0 +1 @@ +add_dolphin_test(MMIOTest MMIOTest.cpp core) diff --git a/Source/UnitTests/Core/MMIOTest.cpp b/Source/UnitTests/Core/MMIOTest.cpp new file mode 100644 index 0000000000..97cabda658 --- /dev/null +++ b/Source/UnitTests/Core/MMIOTest.cpp @@ -0,0 +1,24 @@ +#include <unordered_set> +#include <gtest/gtest.h> + +#include "Common/CommonTypes.h" +#include "Core/HW/MMIO.h" + +// Tests that the UniqueID function returns a "unique enough" identifier +// number: that is, it is unique in the address ranges we care about. +TEST(UniqueID, UniqueEnough) +{ + std::unordered_set<u32> ids; + for (u32 i = 0xCC000000; i < 0xCC010000; ++i) + { + u32 unique_id = MMIO::UniqueID(i); + EXPECT_EQ(ids.end(), ids.find(unique_id)); + ids.insert(unique_id); + } + for (u32 i = 0xCD000000; i < 0xCD010000; ++i) + { + u32 unique_id = MMIO::UniqueID(i); + EXPECT_EQ(ids.end(), ids.find(unique_id)); + ids.insert(unique_id); + } +} |
