From 305c874003da9a8b5d16caf19b58273c698fe0d8 Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Sat, 19 Feb 2022 08:59:45 -0800 Subject: [PATCH] Supply a CMake project and a trivial unit test --- Source/Engine/Gramambular/CMakeLists.txt | 31 +++++++++++++++++++ Source/Engine/Gramambular/GramambularTest.cpp | 28 +++++++++++++++++ Source/Engine/Gramambular/Grid.cpp | 0 3 files changed, 59 insertions(+) create mode 100644 Source/Engine/Gramambular/CMakeLists.txt create mode 100644 Source/Engine/Gramambular/GramambularTest.cpp create mode 100644 Source/Engine/Gramambular/Grid.cpp diff --git a/Source/Engine/Gramambular/CMakeLists.txt b/Source/Engine/Gramambular/CMakeLists.txt new file mode 100644 index 00000000..31f660cd --- /dev/null +++ b/Source/Engine/Gramambular/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.17) +project(Gramambular) + +set(CMAKE_CXX_STANDARD 17) + +add_library(GramambularLib Bigram.h BlockReadingBuilder.h Gramambular.h Grid.h Grid.cpp KeyValuePair.h LanguageModel.h Node.h NodeAnchor.h Span.h Unigram.h Walker.h) + +# Let CMake fetch Google Test for us. +# https://github.com/google/googletest/tree/main/googletest#incorporating-into-an-existing-cmake-project +include(FetchContent) + +FetchContent_Declare( + googletest + # Specify the commit you depend on and update it regularly. + URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip +) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +# Test target declarations. +add_executable(GramambularTest GramambularTest.cpp) +target_link_libraries(GramambularTest gtest_main GramambularLib) +include(GoogleTest) +gtest_discover_tests(GramambularTest) + +add_custom_target( + runTest + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/GramambularTest +) +add_dependencies(runTest GramambularTest) diff --git a/Source/Engine/Gramambular/GramambularTest.cpp b/Source/Engine/Gramambular/GramambularTest.cpp new file mode 100644 index 00000000..5868382a --- /dev/null +++ b/Source/Engine/Gramambular/GramambularTest.cpp @@ -0,0 +1,28 @@ +// Copyright (c) 2022 and onwards Lukhnos Liu +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "gtest/gtest.h" + +TEST(GramambularTest, Trivial) { + ASSERT_EQ(1, 1); +} diff --git a/Source/Engine/Gramambular/Grid.cpp b/Source/Engine/Gramambular/Grid.cpp new file mode 100644 index 00000000..e69de29b