-
Notifications
You must be signed in to change notification settings - Fork 968
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move existing tests to Tests/UnitTests directory
- Loading branch information
1 parent
d1370d7
commit 5a1974d
Showing
59 changed files
with
70 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <memory> | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include <MemoryAllocation/MemoryAllocatorBase.h> | ||
|
||
struct MockMemoryAllocator { | ||
MOCK_METHOD(std::byte*, allocate, (std::size_t size), (noexcept)); | ||
MOCK_METHOD(void, deallocate, (std::byte* memory, std::size_t size), (noexcept)); | ||
|
||
using MockType = testing::StrictMock<MockMemoryAllocator>; | ||
[[nodiscard]] static std::shared_ptr<MockType> create() | ||
{ | ||
if (const auto existingMock = mockMemoryAllocator.lock()) | ||
return existingMock; | ||
|
||
auto mock = std::make_shared<MockMemoryAllocator::MockType>(); | ||
mockMemoryAllocator = mock; | ||
return mock; | ||
} | ||
|
||
static std::byte* invokeAllocate(std::size_t size) | ||
{ | ||
if (const auto mock = mockMemoryAllocator.lock()) | ||
return mock->allocate(size); | ||
return nullptr; | ||
} | ||
|
||
static void invokeDeallocate(std::byte* memory, std::size_t size) | ||
{ | ||
if (const auto mock = mockMemoryAllocator.lock()) | ||
mock->deallocate(memory, size); | ||
} | ||
|
||
private: | ||
inline static std::weak_ptr<MockMemoryAllocator::MockType> mockMemoryAllocator; | ||
}; | ||
|
||
std::byte* MemoryAllocatorBase::allocate(std::size_t size) noexcept | ||
{ | ||
return MockMemoryAllocator::invokeAllocate(size); | ||
} | ||
|
||
void MemoryAllocatorBase::deallocate(std::byte* memory, std::size_t size) noexcept | ||
{ | ||
MockMemoryAllocator::invokeDeallocate(memory, size); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
add_executable(UnitTests UnitTests.cpp) | ||
|
||
if(MSVC) | ||
target_compile_options(UnitTests PRIVATE /bigobj) | ||
endif() | ||
|
||
target_include_directories(UnitTests PRIVATE "${CMAKE_SOURCE_DIR}/Tests" "${CMAKE_SOURCE_DIR}/Source") | ||
target_link_libraries(UnitTests gtest_main gmock Threads::Threads) | ||
set_target_properties(UnitTests PROPERTIES OUTPUT_NAME UnitTestsBin) | ||
gtest_discover_tests(UnitTests DISCOVERY_TIMEOUT 60) | ||
|
||
add_subdirectory(PlatformTests) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target_sources(UnitTests PRIVATE | ||
MockWindowsPlatformApi.cpp | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.