Skip to content

Commit

Permalink
Merge pull request gapry#2 from gapry/gtest_init
Browse files Browse the repository at this point in the history
Initialize Google Test Framework
  • Loading branch information
gapry authored May 30, 2024
2 parents c01fd5b + dfc3d08 commit 2c7e243
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)

project(${project_name})

find_package(fmt CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)

include_directories("${CMAKE_CURRENT_LIST_DIR}")

Expand Down Expand Up @@ -44,6 +45,10 @@ IF(BUILD_TEST)
add_executable(test_${project_name}.out ${src_test})
target_compile_options(test_${project_name}.out PRIVATE -g)
target_compile_options(test_${project_name}.out PRIVATE -O0)
target_link_libraries(test_${project_name}.out PUBLIC ${dir_emulator})
target_link_libraries(test_${project_name}.out PUBLIC ${dir_emulator}
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main)
ENDIF(BUILD_TEST)

23 changes: 23 additions & 0 deletions test/cpu/cpu_test_suite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <test/cpu/cpu_test_suite.hpp>

#include <arabica/cpu/cpu.hpp>
#include <arabica/memory/memory.hpp>

#include <gtest/gtest.h>

namespace arabica {

void test_cpu(void) {
init_cpu();
write_memory(0x200, 0x61);
write_memory(0x200, 0x00);
run_cpu();
// TODO: Verify something
}

} // namespace arabica

TEST(test_cpu, AssertionTrue) {
arabica::test_cpu();
ASSERT_TRUE(true);
}
7 changes: 7 additions & 0 deletions test/cpu/cpu_test_suite.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace arabica {

void test_cpu(void);

}
18 changes: 7 additions & 11 deletions test/test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#include <fmt/core.h>
#include <arabica/cpu/cpu.hpp>
#include <arabica/memory/memory.hpp>
#include <test/cpu/cpu_test_suite.hpp>

int main(void) {
init_cpu();
write_memory(0x200, 0x61);
write_memory(0x200, 0x00);
run_cpu();
// TODO: Verify something
return 0;
}
#include <gtest/gtest.h>

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
1 change: 1 addition & 0 deletions vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ fi

$dir_vcpkg/vcpkg install fmt
$dir_vcpkg/vcpkg install sdl2
$dir_vcpkg/vcpkg install gtest

0 comments on commit 2c7e243

Please sign in to comment.