1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#include "FileOpenStatusTest.hh"
#include <warped/SerializedInstance.h>
#include <clutils/StringUtilities.h>
int
FileOpenStatusTest::getDefaultValue(){
static int defaultValue = 3;
return defaultValue;
}
void
FileOpenStatusTest::setUp(){
toTest = new FileOpenStatus( FileOpenStatus::NAME_ERROR );
}
void
FileOpenStatusTest::tearDown(){
delete toTest;
}
void
FileOpenStatusTest::testGetUniversalKind(){
CPPUNIT_ASSERT( toTest->getUniversalKind() == VHDLData::FILE_OPEN_STATUS );
}
void
FileOpenStatusTest::testGetLength(){
CPPUNIT_ASSERT( toTest->length() == 1 );
}
void
FileOpenStatusTest::testPrint(){
ostringstream printStream;
toTest->print( printStream );
CPPUNIT_ASSERT( "NAME_ERROR" == printStream.str() );
}
void
FileOpenStatusTest::testEqual(){
FileOpenStatus a(FileOpenStatus::STATUS_ERROR);
FileOpenStatus b(FileOpenStatus::STATUS_ERROR);
CPPUNIT_ASSERT( a == b );
}
void
FileOpenStatusTest::testNotEqual(){
FileOpenStatus a(FileOpenStatus::STATUS_ERROR);
FileOpenStatus b(FileOpenStatus::OPEN_OK);
CPPUNIT_ASSERT( a != b );
}
void
FileOpenStatusTest::testGreater(){
FileOpenStatus a(FileOpenStatus::OPEN_OK);
FileOpenStatus b(FileOpenStatus::STATUS_ERROR);
CPPUNIT_ASSERT( b > a );
}
void
FileOpenStatusTest::testGreaterEqual(){
FileOpenStatus a(FileOpenStatus::OPEN_OK);
FileOpenStatus b(FileOpenStatus::NAME_ERROR);
FileOpenStatus c(FileOpenStatus::NAME_ERROR);
CPPUNIT_ASSERT( b >= a );
CPPUNIT_ASSERT( b >= c );
}
void
FileOpenStatusTest::testLess(){
FileOpenStatus a(FileOpenStatus::OPEN_OK);
FileOpenStatus b(FileOpenStatus::STATUS_ERROR);
CPPUNIT_ASSERT( a < b );
}
void
FileOpenStatusTest::testLessEqual(){
FileOpenStatus a(FileOpenStatus::OPEN_OK);
FileOpenStatus b(FileOpenStatus::MODE_ERROR);
FileOpenStatus c(FileOpenStatus::MODE_ERROR);
CPPUNIT_ASSERT( a <= c );
CPPUNIT_ASSERT( b <= c );
}
void
FileOpenStatusTest::testClone(){
FileOpenStatus *cloned = dynamic_cast<FileOpenStatus *>(toTest->clone());
CPPUNIT_ASSERT( cloned != 0 );
CPPUNIT_ASSERT( cloned != toTest );
CPPUNIT_ASSERT( *cloned == *toTest );
delete cloned;
}
void
FileOpenStatusTest::testSerialization(){
SerializedInstance *serialized = static_cast<Serializable *>(toTest)->serialize();
CPPUNIT_ASSERT( serialized->getDataType() == toTest->getDataType() );
FileOpenStatus *deserialized = dynamic_cast<FileOpenStatus *>( serialized->deserialize() );
CPPUNIT_ASSERT( deserialized != 0 );
CPPUNIT_ASSERT( deserialized != toTest );
CPPUNIT_ASSERT( *deserialized == *toTest );
delete deserialized;
}
|