diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt new file mode 100644 index 0000000..bfbc93c --- /dev/null +++ b/Tests/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/Tests/test_write.cpp b/Tests/test_write.cpp new file mode 100644 index 0000000..5c69a13 --- /dev/null +++ b/Tests/test_write.cpp @@ -0,0 +1,19 @@ +#include +#include "YMF262-HAL.hpp" +#include "FakeGPIO.hpp" + +TEST(YMF262Write, FazDoisCiclos) { + FakeGpio fake; + YMF262_HAL 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 +} \ No newline at end of file