Skip to content

Commit

Permalink
Add simple Log::Assert test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoq committed Mar 23, 2015
1 parent 3b9e6e3 commit e0e54db
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mlpack/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_executable(mlpack_test
linear_regression_test.cpp
load_save_test.cpp
local_coordinate_coding_test.cpp
log_test.cpp
logistic_regression_test.cpp
lrsdp_test.cpp
lsh_test.cpp
Expand Down
40 changes: 40 additions & 0 deletions src/mlpack/tests/log_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @file log_test.cpp
* @author Marcus Edel
*
* Test of the mlpack log class.
**/

#include <mlpack/core.hpp>

#include <boost/test/unit_test.hpp>
#include "old_boost_test_definitions.hpp"

#include <mlpack/core/util/backtrace.hpp>

using namespace mlpack;

BOOST_AUTO_TEST_SUITE(LogTest);

/**
* Simple log assert test. Be careful the test halts the program execution, so
* run the test at the end of all other tests.
*/
BOOST_AUTO_TEST_CASE(LogAssertConditionTest)
{
// Only do anything for Assert() if in debugging mode.
#ifdef DEBUG
// If everything goes well we reach the boost test condition which is
// always true by simplicity's sake.
Log::Assert(true, "test");
BOOST_REQUIRE_EQUAL(1, 1);

// The test case should halt the program execution and prints a custom
// error message. Since the program is halted we should never reach the
// boost test condition which is always false by simplicity's sake.
// Log::Assert(false, "test");
// BOOST_REQUIRE_EQUAL(1, 0);
#endif
}

BOOST_AUTO_TEST_SUITE_END();
7 changes: 5 additions & 2 deletions src/mlpack/tests/to_string_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* @file to_string_test.cpp
* @file ToStringTest.cpp
* @author Ryan Birmingham
*
* Test of the toString functionality.
* Test of the AugmentedLagrangian class using the test functions defined in
* aug_lagrangian_test_functions.hpp.
**/

#include <mlpack/core.hpp>
#include <mlpack/core.hpp>
#include <boost/test/unit_test.hpp>
#include "old_boost_test_definitions.hpp"
Expand All @@ -13,6 +15,7 @@
#include <mlpack/core/metrics/lmetric.hpp>
#include <mlpack/core/metrics/mahalanobis_distance.hpp>

#include <mlpack/core/kernels/pspectrum_string_kernel.hpp>
#include <mlpack/core/kernels/pspectrum_string_kernel.hpp>
#include <mlpack/core/kernels/example_kernel.hpp>

Expand Down

0 comments on commit e0e54db

Please sign in to comment.