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 109
|
#include "UniversalCharacterTest.hh"
#include "tyvis/UniversalCharacter.hh"
#include <warped/SerializedInstance.h>
#include <clutils/StringUtilities.h>
char
UniversalCharacterTest::getDefaultValue(){
static char defaultValue = 'x';
return defaultValue;
}
void
UniversalCharacterTest::setUp(){
toTest = new UniversalCharacter( getDefaultValue() );
}
void
UniversalCharacterTest::tearDown(){
delete toTest;
}
void
UniversalCharacterTest::testGetUniversalKind(){
CPPUNIT_ASSERT( toTest->getUniversalKind() == VHDLData::UNIVERSAL_CHARACTER );
}
void
UniversalCharacterTest::testGetLength(){
CPPUNIT_ASSERT( toTest->length() == 1 );
}
void
UniversalCharacterTest::testPrint(){
ostringstream printStream;
toTest->print( printStream );
CPPUNIT_ASSERT( "x" == printStream.str() );
}
void
UniversalCharacterTest::testEqual(){
UniversalCharacter a( 'x' );
UniversalCharacter b( 'x' );
CPPUNIT_ASSERT( a == b );
}
void
UniversalCharacterTest::testNotEqual(){
UniversalCharacter a( 'x' );
UniversalCharacter b( 'v' );
CPPUNIT_ASSERT( a != b );
}
void
UniversalCharacterTest::testGreater(){
UniversalCharacter a( 'v' );
UniversalCharacter b( 'x' );
CPPUNIT_ASSERT( b > a );
}
void
UniversalCharacterTest::testGreaterEqual(){
UniversalCharacter a( 'v' );
UniversalCharacter b( 'x' );
UniversalCharacter c( 'x' );
CPPUNIT_ASSERT( b >= a );
CPPUNIT_ASSERT( b >= c );
}
void
UniversalCharacterTest::testLess(){
UniversalCharacter a( 'v' );
UniversalCharacter b( 'x' );
CPPUNIT_ASSERT( a < b );
}
void
UniversalCharacterTest::testLessEqual(){
UniversalCharacter a( 'v' );
UniversalCharacter b( 'x' );
UniversalCharacter c( 'x' );
CPPUNIT_ASSERT( a <= c );
CPPUNIT_ASSERT( b <= c );
}
void
UniversalCharacterTest::testClone(){
UniversalCharacter *cloned = dynamic_cast<UniversalCharacter *>(toTest->clone());
CPPUNIT_ASSERT( cloned != 0 );
CPPUNIT_ASSERT( cloned != toTest );
CPPUNIT_ASSERT( *cloned = *toTest );
delete cloned;
}
void
UniversalCharacterTest::testSerialization(){
SerializedInstance *serialized = static_cast<Serializable *>(toTest)->serialize();
CPPUNIT_ASSERT( serialized->getDataType() == toTest->getDataType() );
UniversalCharacter *deserialized = dynamic_cast<UniversalCharacter *>( serialized->deserialize() );
CPPUNIT_ASSERT( deserialized != 0 );
CPPUNIT_ASSERT( deserialized != toTest );
CPPUNIT_ASSERT( *deserialized = *toTest );
delete deserialized;
}
|