00001
00002 #include <config.h>
00003
00004
00005 #include <cppunit/extensions/HelperMacros.h>
00006 #include <cppunit/Asserter.h>
00007 #include "Asserts.h"
00008 #include "CCAENV1x90.h"
00009 #include "DesignByContract.h"
00010 #include <iostream>
00011 #include <Exception.h>
00012
00013 #ifdef HAVE_STD_NAMESPACE
00014 using namespace std;
00015 #endif
00016
00017 using namespace DesignByContract;
00018
00019 extern unsigned long ModuleBase;
00020
00021 class ConstructTests : public CppUnit::TestFixture {
00022 CPPUNIT_TEST_SUITE(ConstructTests);
00023 CPPUNIT_TEST(ConstructFailures);
00024 CPPUNIT_TEST(GoodConstruct);
00025 CPPUNIT_TEST_SUITE_END();
00026
00027 #ifdef HAVE_STD_HEADER
00028 using namespace std;
00029 #endif
00030 private:
00031
00032 public:
00033 void setUp() {
00034 }
00035 void tearDown() {
00036 }
00037 protected:
00038 void ConstructFailures();
00039 void GoodConstruct();
00040 };
00041
00042 CPPUNIT_TEST_SUITE_REGISTRATION(ConstructTests);
00043
00048 void ConstructTests::ConstructFailures()
00049 {
00050
00051 try {
00052 EXCEPTION((CCAENV1x90(21, 0, ModuleBase)),
00053 Require);
00054 EXCEPTION((CCAENV1x90(0, 0, ModuleBase)),
00055 Require);
00056 EXCEPTION(CCAENV1x90(1, 8, ModuleBase) ,
00057 CException);
00058 EXCEPTION((CCAENV1x90(1, 0, ModuleBase+4)),
00059 string);
00060 }
00061 catch (Require& e) {
00062 cerr << "Caught require " << e << endl;
00063 }
00064 catch (Ensure& e) {
00065 cerr << "Caught ensure exceiption " << e << endl;
00066 }
00067 catch (DesignByContractException& e) {
00068 cerr << "Caught " << e << endl;
00069 }
00070 catch (string& r) {
00071 cerr << "String e " << r << endl;
00072 }
00073 catch (CException& rexcept) {
00074 cerr << "Caught nscl exception " <<
00075 rexcept.ReasonText() << rexcept.WasDoing() << endl;
00076 }
00077 catch (...) {
00078 cerr << "Caught some exception dont know what??" << endl;
00079 }
00080
00081
00082 }
00086 void
00087 ConstructTests::GoodConstruct()
00088 {
00089 CCAENV1x90 test(1, 0, ModuleBase);
00090 test.Reset();
00091
00092
00093 ASSERT(!test.isTriggerMatching());
00094 }