Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:
contents: read

jobs:
build:
test-msbuild:
runs-on: windows-latest

steps:
Expand All @@ -42,4 +42,69 @@ jobs:

- name: Run tests
working-directory: ${{env.GITHUB_WORKSPACE}}
run: .\Debug\test.exe
run: .\Debug\test.exe

test-cmake:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ ubuntu-latest, windows-latest ]
build_type: [ Release ]
c_compiler: [ gcc, clang, cl ]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ libant.sln.DotSettings.user
*.filters
packages/
x64/
cmake-build-debug/
Debug/
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.26)
project(libant)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

enable_testing()

include_directories(.)

file(GLOB TEST_SOURCES "test/*.cpp")

add_executable(libant ${TEST_SOURCES})

target_link_libraries(
libant
GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(libant)
2 changes: 1 addition & 1 deletion automaton/ant/la_ant.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstdint>
#include <vector>

#include "../spatial_structure/la_cell.h"
#include <spatial_structure/la_cell.h>

constexpr int NORTH_2D[2] = {0, -1};
constexpr int EAST_2D[2] = {1, 0};
Expand Down
2 changes: 1 addition & 1 deletion automaton/scanning/la_scanning_automaton.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <functional>

#include "../la_automaton.h"
#include "../rule/la_rule.h"
#include "../../rule/la_rule.h"

class la_scanning_automaton : public la_automaton
{
Expand Down
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Debug/
2 changes: 1 addition & 1 deletion test/fixtures.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <gtest/gtest.h>
#include "../libant.h"
#include <libant.h>

class AutomatonTestFixtures : public ::testing::TestWithParam<const char *>
{
Expand Down
2 changes: 2 additions & 0 deletions test/test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="fixtures.h" />
<ClInclude Include=".." />
</ItemGroup>
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand All @@ -67,6 +68,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down
1 change: 0 additions & 1 deletion test/test_game_of_life.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "fixtures.h"
#include "../libant.h"

class GameOfLifeTest : public AutomatonTestFixtures {
// No need for additional setup and teardown here
Expand Down
6 changes: 1 addition & 5 deletions test/test_langtons_ant.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#pragma once

#include "fixtures.h"
#include "../libant.h"
#include "fixtures.h"

class LangtonsAntTest : public AutomatonTestFixtures {
// No need for additional setup and teardown here
Expand All @@ -14,7 +11,6 @@ INSTANTIATE_TEST_CASE_P(
custom_test_name<LangtonsAntTest>
);

// TEST_P(LangtonsAntTest, test_langtons_ant_quadtree)
TEST_P(LangtonsAntTest, test_langtons_ant)
{
auto backend = get_backend({3, 3});
Expand Down
1 change: 0 additions & 1 deletion test/test_rule.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <gtest/gtest.h>

#include "fixtures.h"
#include "../libant.h"

using namespace libant;

Expand Down
1 change: 0 additions & 1 deletion test/test_spatial_structure.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "fixtures.h"
#include "../libant.h"

class SpatialStructureTest : public AutomatonTestFixtures {
// No need for additional setup and teardown here
Expand Down