00001 // Template for a test suite. 00002 #include <config.h> 00003 #include <cppunit/extensions/HelperMacros.h> 00004 #include <cppunit/Asserter.h> 00005 #include "Asserts.h" 00006 #include "CCAENV1x90.h" 00007 00008 #ifdef HAVE_STD_NAMESPACE 00009 using namespace std; 00010 #endif 00011 00012 extern long ModuleBase; 00013 00014 class TerminationTests : public CppUnit::TestFixture { 00015 CPPUNIT_TEST_SUITE(TerminationTests); 00016 CPPUNIT_TEST(Terminate); 00017 CPPUNIT_TEST(Unterminate); 00018 CPPUNIT_TEST(SwitchTerminate); 00019 CPPUNIT_TEST_SUITE_END(); 00020 00021 00022 private: 00023 CCAENV1x90* m_pModule; 00024 00025 public: 00026 // Construct a module in powered up condition: 00027 00028 void setUp() { 00029 m_pModule = new CCAENV1x90(1, 0, ModuleBase); 00030 m_pModule->Reset(); 00031 } 00032 // Delete the module to prevent resource leaks. 00033 00034 void tearDown() { 00035 delete m_pModule; 00036 } 00037 protected: 00038 void Terminate(); 00039 void Unterminate(); 00040 void SwitchTerminate(); 00041 }; 00042 00043 CPPUNIT_TEST_SUITE_REGISTRATION(TerminationTests); 00044 00045 00046 // After enabling termination, the module should 00047 // be terminated. 00048 00049 void TerminationTests::Terminate() { 00050 m_pModule->Terminate(); 00051 ASSERT(m_pModule->isTerminated()); 00052 } 00053 00054 00055 // Should be able to turn off termination too.. 00056 00057 void 00058 TerminationTests::Unterminate() 00059 { 00060 m_pModule->Unterminate(); 00061 ASSERT(!(m_pModule->isTerminated())); 00062 00063 } 00064 // Should be able to use switch termination and then 00065 // ReadCR will have the sw term bit off. 00066 00067 void 00068 TerminationTests::SwitchTerminate() 00069 { 00070 m_pModule->TerminateWithSwitch(); 00071 00072 unsigned long cr = m_pModule->ReadCR(); 00073 ASSERT((cr & 4) == 0); 00074 }