Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

use a unit-testing framework#4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Z80coder merged 1 commit intomasterfromunit-test-variable
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletion.vscode/tasks.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
{
"label": "build",
"type": "shell",
"command": "mkdir -p build;cd build; cmake ../src; make",
"command": "cd build; make",
"problemMatcher": [
"$gcc"
],
Expand Down
2 changes: 1 addition & 1 deletiondocs/build.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 theproejct.
Ensure you have built the makefiles as per above. Then holding`CTRL-SHIFT-B` in the IDE will automatically build theproject.

# 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.
Expand Down
5 changes: 5 additions & 0 deletionssrc/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
38 changes: 14 additions & 24 deletionstests/types_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
#include <Datalog.h>
// Let Catch provide main():
#define CATCH_CONFIG_MAIN

#include "catch.hpp"
#include "Datalog.h"

using namespace datalog;

Expand DownExpand Up@@ -109,7 +113,6 @@ bool test2()
return true;
}

#if 1
bool po1()
{
typedef unsigned int Number;
Expand DownExpand Up@@ -193,9 +196,9 @@ bool po1()
const auto& computedA = convert<A>(temp);
//return convert<RELATION_TYPE>(getTrackedSet<RELATION_TYPE>());

cout << "result = ";
operator<< <A>(cout, computedA);
cout << endl;
// cout << "result = ";
// operator<< <A>(cout, computedA);
// cout << endl;

delete a;
delete b;
Expand All@@ -215,7 +218,6 @@ bool po1()

return computedA == aOut;
}
#endif

bool test4()
{
Expand DownExpand Up@@ -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() );
}
26 changes: 26 additions & 0 deletionstests/variable_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
// Let Catch provide main():
#define CATCH_CONFIG_MAIN

#include "catch.hpp"
#include "Variable.h"

using namespace datalog;

bool freeVariableTest() {
Variable<int> intVar;
return !intVar.isBound();
}

bool boundVariableTest() {
Variable<int> 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() );
}

[8]ページ先頭

©2009-2025 Movatter.jp