[mlpack-git] master: Add simple Log::Assert test case. (e0e54db)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Mar 23 08:54:56 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/2adbba4c04428f296bc6152ccbcf3e0ffcf1caa4...e0e54db5b47e2af1cbd0d9b2b272035483a0df27

>---------------------------------------------------------------

commit e0e54db5b47e2af1cbd0d9b2b272035483a0df27
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Mon Mar 23 13:54:43 2015 +0100

    Add simple Log::Assert test case.


>---------------------------------------------------------------

e0e54db5b47e2af1cbd0d9b2b272035483a0df27
 src/mlpack/tests/CMakeLists.txt     |  1 +
 src/mlpack/tests/log_test.cpp       | 40 +++++++++++++++++++++++++++++++++++++
 src/mlpack/tests/to_string_test.cpp |  7 +++++--
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt
index efd2202..0caa3bb 100644
--- a/src/mlpack/tests/CMakeLists.txt
+++ b/src/mlpack/tests/CMakeLists.txt
@@ -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
diff --git a/src/mlpack/tests/log_test.cpp b/src/mlpack/tests/log_test.cpp
new file mode 100644
index 0000000..5251684
--- /dev/null
+++ b/src/mlpack/tests/log_test.cpp
@@ -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();
diff --git a/src/mlpack/tests/to_string_test.cpp b/src/mlpack/tests/to_string_test.cpp
index cd094b1..bc7d436 100644
--- a/src/mlpack/tests/to_string_test.cpp
+++ b/src/mlpack/tests/to_string_test.cpp
@@ -1,11 +1,13 @@
 /**
- * @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"
 
@@ -14,6 +16,7 @@
 #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>
 
 #include <mlpack/core/optimizers/aug_lagrangian/aug_lagrangian.hpp>



More information about the mlpack-git mailing list