Commit 6176abe6 authored by Martin Wengenmayr's avatar Martin Wengenmayr

adding minimal test example and Readme

parent d8caa3ec
## Installation
* Clone and Install the library `git clone https://github.com/LeMonADE-project/LeMonADE.git`
* Install cmake (minimum version 2.8)
* Go to one of the project directories and perform the standard build:
````sh
# prepare the build directory
mkdir build
cd build
# run cmake with the lemonade path
cmake -DLEMONADE_DIR=</path/to/LeMonADE-library/> ..
make
````
## Examples
* in analyzers and updaters examples files can be found
* the are used in [the example project](projects/exampleProject/)
## Tests
* in [the test directory](test/) you find a setup using the [catch2](https://github.com/catchorg/Catch2) framework
* run the tests similar to the projects
````sh
# prepare the build directory
mkdir build
cd build
# run cmake with the lemonade path
cmake -DLEMONADE_DIR=</path/to/LeMonADE-library/> ..
make
./testsYves
````
* add tests by creating a **test_yourtestname.cpp** file and add this to the [CMakeLists.txt](test/CMakeLists.txt):
```cmake
add_executable(testsLeMonADE test_main.cpp .... )
```
* testing might be annoying but helps you to find nasty bugs
cmake_minimum_required (VERSION 2.8)
if (NOT DEFINED LEMONADE_DIR)
message("LEMONADE_DIR is not provided. If build fails, use -DLEMONADE_DIR=/path/to/LeMonADE/")
endif()
SET (LEMONADE_INCLUDE_DIR ${LEMONADE_DIR}include/)
SET (LEMONADE_LIBRARY_DIR ${LEMONADE_DIR}lib/)
message( ${LEMONADE_DIR} )
include_directories("../")
include_directories (${LEMONADE_INCLUDE_DIR})
link_directories (${LEMONADE_LIBRARY_DIR})
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -O2 -std=c++11")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEBUG} -O2 ")
## ############### Tests linked to main ############# ##
add_executable(testsLeMonADE test_main.cpp test_updaterExample.cpp)
target_link_libraries(testsLeMonADE LeMonADE )
#define CATCH_CONFIG_MAIN
#include "utility/extern/catchorg/catch2/catch.hpp"
TEST_CASE( "1: All test cases reside in other .cpp files (empty)", "[multi-file:1]" ) {
}
// use the catch file but do not add the #define CATCH_CONFIG_MAIN !!
#include "utility/extern/catchorg/catch2/catch.hpp"
#include <LeMonADE/core/Ingredients.h>
#include <LeMonADE/feature/FeatureMoleculesIO.h>
#include "updater/UpdaterExample.h"
typedef LOKI_TYPELIST_1(FeatureMoleculesIO) Features;
typedef ConfigureSystem<VectorInt3,Features,4> Config;
typedef Ingredients<Config> IngredientsType;
TEST_CASE( "run the updater" ) {
// empty instance of ingredients
IngredientsType ingredients;
uint32_t myParameter(42);
// just check for errors to be thrown
UpdaterExample<IngredientsType> Hugo1 (ingredients, myParameter);
REQUIRE_NOTHROW( Hugo1.initialize() );
REQUIRE_NOTHROW( Hugo1.execute() );
REQUIRE_NOTHROW( Hugo1.cleanup() );
// check a condition (should return TRUE), for instance
CHECK(myParameter == 42);
// check something to return false
CHECK_FALSE( myParameter == 2578472);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment