diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 8 | ||||
-rw-r--r-- | test/regress/Makefile.am | 4 | ||||
-rw-r--r-- | test/system/Makefile.am | 10 | ||||
-rw-r--r-- | test/unit/Makefile.am | 15 | ||||
-rw-r--r-- | test/unit/util/stats_black.h | 103 |
5 files changed, 124 insertions, 16 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 501f85090..045599bc1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,8 +2,8 @@ SUBDIRS = unit system regress . MAKEFLAGS = -k -.PHONY: regress0 regress1 regress2 regress3 -regress0 regress1 regress2 regress3: +.PHONY: units regress regress0 regress1 regress2 regress3 +units regress regress0 regress1 regress2 regress3: @$(MAKE) check-pre; \ for dir in $(SUBDIRS); do \ test $$dir = . || (cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $@); \ @@ -11,8 +11,8 @@ regress0 regress1 regress2 regress3: $(MAKE) check-local # synonyms for "check" -.PHONY: regress test -regress test: check +.PHONY: test +test: check am__tty_colors = \ red=; grn=; lgn=; blu=; std=; \ diff --git a/test/regress/Makefile.am b/test/regress/Makefile.am index 80e8da387..3867ee860 100644 --- a/test/regress/Makefile.am +++ b/test/regress/Makefile.am @@ -16,6 +16,10 @@ regress0 regress1 regress2 regress3: .PHONY: regress test regress test: check +# no-ops here +.PHONY: units +units: + EXTRA_DIST = \ run_regression \ README diff --git a/test/system/Makefile.am b/test/system/Makefile.am index 219a26355..954798e6c 100644 --- a/test/system/Makefile.am +++ b/test/system/Makefile.am @@ -39,9 +39,9 @@ $(TESTS):: $(TEST_DEPS) export VERBOSE = 1 # synonyms for "check" -.PHONY: regress test -regress test: check +.PHONY: test +test: check -# in system test dir, regressN are also synonyms for check -.PHONY: regress0 regress1 regress2 regress3 -regress0 regress1 regress2 regress3: check +# no-ops here +.PHONY: units regress regress0 regress1 regress2 regress3s +units regress regress0 regress1 regress2 regress3: diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am index eb920e6c5..1272be069 100644 --- a/test/unit/Makefile.am +++ b/test/unit/Makefile.am @@ -35,7 +35,8 @@ UNIT_TESTS = \ util/integer_black \ util/integer_white \ util/rational_black \ - util/rational_white + util/rational_white \ + util/stats_black export VERBOSE = 1 @@ -52,7 +53,7 @@ AM_CPPFLAGS = \ "-I@top_srcdir@/src" "-I@top_builddir@/src" \ "-I@top_srcdir@/src/prop/minisat" \ -D __STDC_LIMIT_MACROS \ - -D __STDC_FORMAT_MACROS \ + -D __STDC_FORMAT_MACROS \ $(ANTLR_INCLUDES) $(TEST_CPPFLAGS) AM_CXXFLAGS = -Wall -Wno-unknown-pragmas -Wno-parentheses $(TEST_CXXFLAGS) AM_LDFLAGS = $(TEST_LDFLAGS) @@ -158,12 +159,12 @@ libdummy_la_LIBADD = @abs_top_builddir@/src/libcvc4.la endif # synonyms for "check" -.PHONY: regress test -regress test: check +.PHONY: units test +units test: check -# in unit test dir, regressN are also synonyms for check -.PHONY: regress0 regress1 regress2 regress3 -regress0 regress1 regress2 regress3: check +# no-ops here +.PHONY: regress regress0 regress1 regress2 regress3 +regress regress0 regress1 regress2 regress3: if HAVE_CXXTESTGEN # all is fine with the world diff --git a/test/unit/util/stats_black.h b/test/unit/util/stats_black.h new file mode 100644 index 000000000..032efc37a --- /dev/null +++ b/test/unit/util/stats_black.h @@ -0,0 +1,103 @@ +/********************* */ +/*! \file stats_black.h + ** \verbatim + ** Original author: mdeters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys) + ** Courant Institute of Mathematical Sciences + ** New York University + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Black box testing of CVC4::Stat and associated classes + ** + ** Black box testing of CVC4::Stat and associated classes. + **/ + +#include <cxxtest/TestSuite.h> +#include <sstream> +#include <string> +#include <ctime> + +#include "util/stats.h" + +using namespace CVC4; +using namespace std; + +class StatsBlack : public CxxTest::TestSuite { +public: + + void testStats() { + + // StatisticsRegistry + //static void flushStatistics(std::ostream& out); + + //static inline void registerStat(Stat* s) throw (AssertionException); + //static inline void unregisterStat(Stat* s) throw (AssertionException); + + string empty, bar = "bar", baz = "baz"; + ReferenceStat<string> refStr("stat #1", empty); + ReferenceStat<string> refStr2("refStr2", bar); + // setData + // getData + + // flushInformation + // flushStat + + BackedStat<string> backedStr("backed", baz); + // setData + // getData + // operator= + + IntStat sInt("my int", 10); + TimerStat sTimer("a timer ! for measuring time"); + + TS_ASSERT_EQUALS(refStr.getName(), "stat #1"); + TS_ASSERT_EQUALS(refStr2.getName(), "refStr2"); + TS_ASSERT_EQUALS(backedStr.getName(), "backed"); + TS_ASSERT_EQUALS(sInt.getName(), "my int"); + TS_ASSERT_EQUALS(sTimer.getName(), "a timer ! for measuring time"); + + TS_ASSERT_EQUALS(refStr.getData(), empty); + TS_ASSERT_EQUALS(refStr2.getData(), bar); + empty = "a different string"; + bar += " and with an addition"; + TS_ASSERT_EQUALS(refStr.getData(), empty); + TS_ASSERT_EQUALS(refStr2.getData(), bar); + + TS_ASSERT_EQUALS(backedStr.getData(), "baz"); + baz = "something else"; + TS_ASSERT_EQUALS(backedStr.getData(), "baz"); + + TS_ASSERT_EQUALS(sInt.getData(), 10); + sInt.setData(100); + TS_ASSERT_EQUALS(sInt.getData(), 100); + + TS_ASSERT_EQUALS(sTimer.getData(), timespec()); + + stringstream sstr; + + refStr.flushInformation(sstr); + TS_ASSERT_EQUALS(sstr.str(), empty); + sstr.str(""); + refStr2.flushInformation(sstr); + TS_ASSERT_EQUALS(sstr.str(), bar); + sstr.str(""); + backedStr.flushInformation(sstr); + TS_ASSERT_EQUALS(sstr.str(), "baz"); + sstr.str(""); + sInt.flushInformation(sstr); + TS_ASSERT_EQUALS(sstr.str(), "100"); + sstr.str(""); + sTimer.flushInformation(sstr); + TS_ASSERT_EQUALS(sstr.str(), "0.00000000"); + + sTimer.start(); + TS_ASSERT_EQUALS(timespec(), sTimer.getData()); + sTimer.stop(); + TS_ASSERT_LESS_THAN(timespec(), sTimer.getData()); + } + +}; |