Create write unit test to check the proper choreography and delays, and add CMakeLists.txt for compiling the unit tests
This commit is contained in:
parent
8e4fceec7e
commit
2172ed0735
|
|
@ -0,0 +1,25 @@
|
||||||
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
project(YMF262_Tests CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
googletest
|
||||||
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||||
|
GIT_TAG v1.15.2
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
|
||||||
|
add_executable(run_tests test_write.cpp)
|
||||||
|
|
||||||
|
target_include_directories(run_tests PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../Lib/YMF262-HAL/Inc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(run_tests PRIVATE gtest_main)
|
||||||
|
|
||||||
|
include(GoogleTest)
|
||||||
|
gtest_discover_tests(run_tests)
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "YMF262-HAL.hpp"
|
||||||
|
#include "FakeGPIO.hpp"
|
||||||
|
|
||||||
|
TEST(YMF262Write, FazDoisCiclos) {
|
||||||
|
FakeGpio fake;
|
||||||
|
YMF262_HAL<FakeGpio> hal(fake, 14318000, 216000000);
|
||||||
|
|
||||||
|
hal.write(Bank::BANK_0, 0x40, 0x20);
|
||||||
|
|
||||||
|
// imprime o que foi registrado (pra você VER a coreografia)
|
||||||
|
for (const auto& linha : fake.log) {
|
||||||
|
std::cout << linha << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// verificações básicas: o primeiro ciclo é endereço, o barramento recebeu 0x40 (64)
|
||||||
|
EXPECT_EQ(fake.log.front(), "a0 ADDR"); // começou em modo endereço
|
||||||
|
EXPECT_FALSE(fake.log.empty()); // anotou algo
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue