-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable TestBound in the CMakeFile of the test folder. In this version, we duplicate the CMake and CMake builds to download the Google Test Framework. This is required due to the fact that with the current option ExternalProject_Add the external project is only downloaded and installed during the first CMake build. We will change this in another PR to align it with the framework Eigen. Tests that work on linux "obviously" do not work always with windows ¯_(ツ)_/¯, e.g., in debug mode. The above test fail was due to the fact that (.*) regular expression is not supported, but .* is. The issue is only happening on Windows. In addition, the message looks a little bit different on Windows compared to Unix systems. The output differs in "inside Bound.\n Condition" (Unix) from "inside egoa::Bound::Bound.\n Condition" (Windows). Commits: * Enable TestBound in the CMakeFile * Add TestBound testcases * Remove Gurobi Library from TestBound * Check whether Windows and MacOS find the include with that file * Replace find_package with own find CMake for Google Testframework * Downloads need an initial build then the data is on the disk Why: * add subdirectory in CMake requires the CMakeFile that is not downloaded yet * Check sudo * The error in the tests is due to wrong runtime library * Does DLL works * Check without debug * Resolve libcpmt.lib(StlLCMapStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in TestBound.obj [D:\a\egoa\egoa\build\tests\TestBound.vcxproj] See note in: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html#variable:CMAKE_MSVC_RUNTIME_LIBRARY * Fix a label mistake * Add more verbose to the test output to understand what is going on * Check if differentiation is necessary between Debug and Release * Follow the error given in Windows debug death test "')' is unsupported" D:\a\egoa\egoa\external\GoogleTestFramework\googletest\src/gtest-port.cc(844): error: Failed Syntax error at index 42 in simple regular expression "(.*) assertion failed at (.*)Bound.hpp:(.*) inside Bound. Condition: minimum_ <= maximum_": ')' is unsupported. Running main() from D:\a\egoa\egoa\external\GoogleTestFramework\googletest\src\gtest_main.cc D:\a\egoa\egoa\tests\DataStructures\TestBound.cpp(70): error: Death test: {egoa::Bound<> bound (3,1);} Result: died but not with expected error. Expected: contains regular expression "(.*) assertion failed at (.*)Bound.hpp:(.*) inside Bound.\n Condition: minimum_ <= maximum_" Actual msg: [ DEATH ] USAGE assertion failed at D:\a\egoa\egoa\include\DataStructures/Bound.hpp:48 inside egoa::Bound<double>::Bound. [ DEATH ] Condition: minimum_ <= maximum_ [ FAILED ] TestBound.DeathTest (146 ms) * The output differs in "inside Bound.\n Condition" from "inside egoa::Bound<double>::Bound.\n Condition". D:\a\egoa\egoa\tests\DataStructures\TestBound.cpp(70): error: Death test: {egoa::Bound<> bound (3,1);} Result: died but not with expected error. Expected: contains regular expression ".* assertion failed at .*Bound.hpp:.* inside Bound.\n Condition: minimum_ <= maximum_" Actual msg: [ DEATH ] USAGE assertion failed at D:\a\egoa\egoa\include\DataStructures/Bound.hpp:48 inside egoa::Bound<double>::Bound. [ DEATH ] Condition: minimum_ <= maximum_
- Loading branch information
1 parent
c525119
commit 63a79b1
Showing
6 changed files
with
211 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* TestBound.cpp | ||
* | ||
* Created on: Jan 28, 2019 | ||
* Author: Franziska Wegner | ||
*/ | ||
|
||
#include "TestBound.hpp" | ||
|
||
#include "DataStructures/Bound.hpp" | ||
|
||
#include "Helper/TestHelper.hpp" | ||
|
||
// using ::testing::Eq; | ||
// using ::testing::ByRef; | ||
using ::testing::Ge; | ||
using ::testing::Le; | ||
|
||
namespace egoa::test { | ||
|
||
TestBound::TestBound () {} | ||
|
||
TestBound::~TestBound () {} | ||
|
||
void TestBound::SetUp () {} | ||
|
||
void TestBound::TearDown () {} | ||
|
||
TEST_F ( TestBound, MinPositiveNos ) { | ||
egoa::Bound<> bound(2.1, 2.5); | ||
|
||
EXPECT_DOUBLE_EQ (2.1, bound.Minimum()); | ||
ASSERT_THAT(bound.Minimum(), Le(bound.Maximum())); | ||
|
||
bound.Range(2.00000001, 2.00000005); | ||
|
||
EXPECT_DOUBLE_EQ (2.00000001, bound.Minimum()); | ||
ASSERT_THAT(bound.Minimum(), Le(bound.Maximum())); | ||
} | ||
|
||
TEST_F ( TestBound, MaxPositiveNos ) { | ||
egoa::Bound<> bound(2.1, 2.5); | ||
|
||
EXPECT_DOUBLE_EQ (2.5, bound.Maximum()); | ||
ASSERT_THAT(bound.Maximum(), Ge(bound.Minimum())); | ||
|
||
bound.Range(2.00000001, 2.00000005); | ||
EXPECT_DOUBLE_EQ (2.00000005, bound.Maximum()); | ||
ASSERT_THAT(bound.Maximum(), Ge(bound.Minimum())); | ||
} | ||
|
||
TEST_F ( TestBound, DeathTest ) { | ||
// ASSERT_DEATH({ Bound(3, 1);}, "terminating with uncaught exception of type BoundMismatch: Minimum > maximum: 3 < 1"); | ||
#ifdef EGOA_EXCEPTION_HANDLING | ||
try { | ||
egoa::Bound<> bound (3,1); | ||
FAIL() << "Expected BoundMismatch"; | ||
} | ||
catch(egoa::BoundMismatch const & err) { | ||
EXPECT_EQ(err.What(), std::string("Minimum > maximum: 3 < 1")); | ||
} | ||
catch(...) { | ||
FAIL() << "Expected BoundMismatch2"; | ||
} | ||
#elif EGOA_ENABLE_ASSERTION | ||
auto assertionString = buildAssertionString ( "Bound.hpp" | ||
, "Bound" | ||
, "Bound" | ||
, "minimum_ <= maximum_"); | ||
ASSERT_DEATH( {egoa::Bound<> bound (3,1);}, assertionString ); | ||
#endif | ||
} | ||
|
||
} // namespace egoa::test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* TestBound.hpp | ||
* | ||
* Created on: Jan 28, 2019 | ||
* Author: Franziska Wegner | ||
*/ | ||
|
||
#ifndef EGOA__TESTS__DATA_STRUCTURES__BOUND_HPP | ||
#define EGOA__TESTS__DATA_STRUCTURES__BOUND_HPP | ||
|
||
#include "gtest/gtest.h" | ||
#include "gmock/gmock.h" | ||
|
||
namespace egoa::test { | ||
|
||
/** | ||
* @brief Fixture for testing class Bound | ||
*/ | ||
class TestBound : public ::testing::Test { | ||
|
||
protected: | ||
|
||
// You can do set-up work for each test here. | ||
TestBound(); | ||
|
||
// You can do clean-up work that doesn't throw exceptions here. | ||
virtual ~TestBound(); | ||
|
||
// If the constructor and destructor are not enough for setting up | ||
// and cleaning up each test, you can define the following methods: | ||
|
||
// Code here will be called immediately after the constructor (right | ||
// before each test). | ||
virtual void SetUp(); | ||
|
||
// Code here will be called immediately after each test (right | ||
// before the destructor). | ||
virtual void TearDown(); | ||
}; | ||
|
||
} // namespace egoa::test | ||
|
||
#endif // EGOA__TESTS__DATA_STRUCTURES__BOUND_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters