Debug flags unit test and fixed macros

release/4.3a0
Richard Roberts 2011-02-15 00:36:29 +00:00
parent 71007d4550
commit b0c5173bcf
4 changed files with 61 additions and 8 deletions

View File

@ -25,6 +25,7 @@ endif
# Testing
headers += Testable.h TestableAssertions.h numericalDerivative.h
sources += timing.cpp debug.cpp
check_PROGRAMS += tests/testDebug
# Lie Groups
headers += Lie.h Lie-inl.h lieProxies.h LieScalar.h

View File

@ -9,8 +9,6 @@
namespace gtsam {
#ifdef GTSAM_ENABLE_DEBUG
FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
#endif
}

View File

@ -5,8 +5,6 @@
* @created Feb 1, 2011
*/
#pragma once
#include <gtsam/base/FastMap.h>
#include <gtsam/base/types.h>
#include <string>
@ -32,19 +30,22 @@
#endif
#endif
#ifdef GTSAM_ENABLE_DEBUG
namespace gtsam {
extern FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
}
#undef ISDEBUG
#undef SETDEBUG
#ifdef GTSAM_ENABLE_DEBUG
#define ISDEBUG(S) (gtsam::debugFlags[S])
#define SETDEBUG(S,V) (gtsam::debugFlags[S] = (V))
#define SETDEBUG(S,V) ((void)(gtsam::debugFlags[S] = (V)))
#else
#define ISDEBUG(S) (false)
#define SETDEBUG(S,V) (false)
#define SETDEBUG(S,V) ((void)false)
#endif

View File

@ -0,0 +1,53 @@
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file testCholesky.cpp
* @brief
* @author Richard Roberts
* @created Feb 14, 2011
*/
#include <CppUnitLite/TestHarness.h>
#define NDEBUG
#undef GTSAM_ENABLE_DEBUG
#include <gtsam/base/debug.h>
/* ************************************************************************* */
TEST(Debug, debug_disabled) {
const bool debug1 = ISDEBUG("TestDebug");
EXPECT(!debug1);
SETDEBUG("TestDebug", true);
bool debug2 = ISDEBUG("TestDebug");
EXPECT(!debug2);
}
#define GTSAM_ENABLE_DEBUG
#include <gtsam/base/debug.h>
/* ************************************************************************* */
TEST(Debug, debug_enabled) {
const bool debug1 = ISDEBUG("TestDebug");
EXPECT(!debug1);
SETDEBUG("TestDebug", true);
bool debug2 = ISDEBUG("TestDebug");
EXPECT(debug2);
}
/* ************************************************************************* */
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
/* ************************************************************************* */