diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8aee083..9f777b5 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ { "label": "build", "type": "shell", - "command": "mkdir -p build; cd build; cmake ../src; make", + "command": "cd build; make", "problemMatcher": [ "$gcc" ], diff --git a/docs/build.md b/docs/build.md index 2c487ea..42da8ac 100644 --- a/docs/build.md +++ b/docs/build.md @@ -13,7 +13,7 @@ make Add the C/C++ extension for Visual Studio Code for IntelliSense configuration: in the IDE press `CTRL-P` and then paste the command `ext install ms-vscode.cpptools`. -Typping `CTRL-SHIFT-B` in the IDE will automatically build the proejct. +Ensure you have built the makefiles as per above. Then holding `CTRL-SHIFT-B` in the IDE will automatically build the project. # Building directly with CMake in Visual Studio 2019 Visual Studio 2019 supports using CMake to manage the build directly by selecting File -> Open -> Cmake... and opening `src/CMakeLists.txt`. Then Visual Studio's normal build shortcuts will update the CMake configuration as well as building the project. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9644bfe..34d4e07 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,3 +25,8 @@ set(CMAKE_CXX_STANDARD 17) add_executable(types_test ../tests/types_test.cpp) target_include_directories(types_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(types_test PUBLIC UNIX) + +# variable_test target +add_executable(variable_test ../tests/variable_test.cpp) +target_include_directories(variable_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(variable_test PUBLIC UNIX) diff --git a/tests/types_test.cpp b/tests/types_test.cpp index 40d9e4e..91ab821 100644 --- a/tests/types_test.cpp +++ b/tests/types_test.cpp @@ -1,4 +1,8 @@ -#include +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "Datalog.h" using namespace datalog; @@ -109,7 +113,6 @@ bool test2() return true; } -#if 1 bool po1() { typedef unsigned int Number; @@ -193,9 +196,9 @@ bool po1() const auto& computedA = convert(temp); //return convert(getTrackedSet()); - cout << "result = "; - operator<< (cout, computedA); - cout << endl; +// cout << "result = "; +// operator<< (cout, computedA); +// cout << endl; delete a; delete b; @@ -215,7 +218,6 @@ bool po1() return computedA == aOut; } -#endif bool test4() { @@ -312,21 +314,9 @@ bool test4() return true; } -int main() -{ - bool ok1 = test1(); - bool ok2 = test2(); -#if 1 - bool ok3 = po1(); - bool ok4 = test4(); - - if (!(ok1 and ok2 and ok3 and ok4)) { - cout << "FAIL" << endl; - return 1; - } else { - cout << "PASSED" << endl; - return 0; - } -#endif - return 1; -} +TEST_CASE( "toy-examples", "[types-test]" ) { + REQUIRE( test1() ); + REQUIRE( test2() ); + REQUIRE( po1() ); + REQUIRE( test4() ); +} \ No newline at end of file diff --git a/tests/variable_test.cpp b/tests/variable_test.cpp new file mode 100644 index 0000000..c5b82ec --- /dev/null +++ b/tests/variable_test.cpp @@ -0,0 +1,26 @@ +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" +#include "Variable.h" + +using namespace datalog; + +bool freeVariableTest() { + Variable intVar; + return !intVar.isBound(); +} + +bool boundVariableTest() { + Variable intVar; + intVar.bind(0); + return intVar.isBound(); +} + +TEST_CASE( "An new variable is unbound", "[variable]" ) { + REQUIRE( freeVariableTest() ); +} + +TEST_CASE( "A variable with a value is bound", "[variable]" ) { + REQUIRE( freeVariableTest() ); +}