#include "data_structures/basic_types.h" #include "data_structures/PacketAttribute.h" #include <iostream> #include <string> using namespace std; int main(void) { // Test the PacketAttributeValue classes PacketAttributeValue *val5a = new ConcretePacketAttributeValue<int>(5); PacketAttributeValue *val5b = new ConcretePacketAttributeValue<int>(5); PacketAttributeValue *val8 = new ConcretePacketAttributeValue<int>(8); cout << "val5a < val5b ? " << ( *val5a < *val5b ? "err" : "ok" ) << endl; cout << "val5a > val5b ? " << ( *val5a > *val5b ? "err" : "ok" ) << endl; cout << "val5a <= val5b ? " << ( *val5a <= *val5b ? "ok" : "err" ) << endl; cout << "val5a >= val5b ? " << ( *val5a >= *val5b ? "ok" : "err" ) << endl; cout << "val5a == val5b ? " << ( *val5a == *val5b ? "ok" : "err" ) << endl; cout << "val5a < val8 ? " << ( *val5a < *val8 ? "ok" : "err" ) << endl; cout << "val5a > val8 ? " << ( *val5a > *val8 ? "err" : "ok" ) << endl; cout << "val5a <= val8 ? " << ( *val5a <= *val8 ? "ok" : "err" ) << endl; cout << "val5a >= val8 ? " << ( *val5a >= *val8 ? "err" : "ok" ) << endl; cout << "val5a == val8 ? " << ( *val5a == *val8 ? "err" : "ok" ) << endl; delete val5a; delete val5b; delete val8; PacketAttributeValue *valDouble1a = new ConcretePacketAttributeValue<double>(1.0); PacketAttributeValue *valDouble1b = new ConcretePacketAttributeValue<double>(1.0); PacketAttributeValue *valDouble2 = new ConcretePacketAttributeValue<double>(2.0); cout << "valDouble1a < valDouble1b ? " << ( *valDouble1a < *valDouble1b ? "err" : "ok" ) << endl; cout << "valDouble1a > valDouble1b ? " << ( *valDouble1a > *valDouble1b ? "err" : "ok" ) << endl; cout << "valDouble1a <= valDouble1b ? " << ( *valDouble1a <= *valDouble1b ? "ok" : "err" ) << endl; cout << "valDouble1a >= valDouble1b ? " << ( *valDouble1a >= *valDouble1b ? "ok" : "err" ) << endl; cout << "valDouble1a == valDouble1b ? " << ( *valDouble1a == *valDouble1b ? "ok" : "err" ) << endl; cout << "valDouble1a < valDouble2 ? " << ( *valDouble1a < *valDouble2 ? "ok" : "err" ) << endl; cout << "valDouble1a > valDouble2 ? " << ( *valDouble1a > *valDouble2 ? "err" : "ok" ) << endl; cout << "valDouble1a <= valDouble2 ? " << ( *valDouble1a <= *valDouble2 ? "ok" : "err" ) << endl; cout << "valDouble1a >= valDouble2 ? " << ( *valDouble1a >= *valDouble2 ? "err" : "ok" ) << endl; cout << "valDouble1a == valDouble2 ? " << ( *valDouble1a == *valDouble2 ? "err" : "ok" ) << endl; delete valDouble1a; delete valDouble1b; delete valDouble2; PacketAttributeValue *valStrBarA = new ConcretePacketAttributeValue<string>(string("bar")); PacketAttributeValue *valStrBarB = new ConcretePacketAttributeValue<string>(string("bar")); PacketAttributeValue *valStrFoo = new ConcretePacketAttributeValue<string>(string("foo")); cout << "valStrBarA < valStrBarB ? " << ( *valStrBarA < *valStrBarB ? "err" : "ok" ) << endl; cout << "valStrBarA > valStrBarB ? " << ( *valStrBarA > *valStrBarB ? "err" : "ok" ) << endl; cout << "valStrBarA <= valStrBarB ? " << ( *valStrBarA <= *valStrBarB ? "ok" : "err" ) << endl; cout << "valStrBarA >= valStrBarB ? " << ( *valStrBarA >= *valStrBarB ? "ok" : "err" ) << endl; cout << "valStrBarA == valStrBarB ? " << ( *valStrBarA == *valStrBarB ? "ok" : "err" ) << endl; cout << "valStrBarA < valStrFoo ? " << ( *valStrBarA < *valStrFoo ? "ok" : "err" ) << endl; cout << "valStrBarA > valStrFoo ? " << ( *valStrBarA > *valStrFoo ? "err" : "ok" ) << endl; cout << "valStrBarA <= valStrFoo ? " << ( *valStrBarA <= *valStrFoo ? "ok" : "err" ) << endl; cout << "valStrBarA >= valStrFoo ? " << ( *valStrBarA >= *valStrFoo ? "err" : "ok" ) << endl; cout << "valStrBarA == valStrFoo ? " << ( *valStrBarA == *valStrFoo ? "err" : "ok" ) << endl; delete valStrBarA; delete valStrBarB; delete valStrFoo; PacketAttributeValue *valTimeval1a = new ConcretePacketAttributeValue<Timeval>(); PacketAttributeValue *valTimeval1b = new ConcretePacketAttributeValue<Timeval>(*((ConcretePacketAttributeValue<Timeval> * ) valTimeval1a)); PacketAttributeValue *valTimeval2 = new ConcretePacketAttributeValue<Timeval>(); cout << "valTimeval1a < valTimeval1b ? " << ( *valTimeval1a < *valTimeval1b ? "err" : "ok" ) << endl; cout << "valTimeval1a > valTimeval1b ? " << ( *valTimeval1a > *valTimeval1b ? "err" : "ok" ) << endl; cout << "valTimeval1a <= valTimeval1b ? " << ( *valTimeval1a <= *valTimeval1b ? "ok" : "err" ) << endl; cout << "valTimeval1a >= valTimeval1b ? " << ( *valTimeval1a >= *valTimeval1b ? "ok" : "err" ) << endl; cout << "valTimeval1a == valTimeval1b ? " << ( *valTimeval1a == *valTimeval1b ? "ok" : "err" ) << endl; cout << "valTimeval1a < valTimeval2 ? " << ( *valTimeval1a < *valTimeval2 ? "ok" : "err" ) << endl; cout << "valTimeval1a > valTimeval2 ? " << ( *valTimeval1a > *valTimeval2 ? "err" : "ok" ) << endl; cout << "valTimeval1a <= valTimeval2 ? " << ( *valTimeval1a <= *valTimeval2 ? "ok" : "err" ) << endl; cout << "valTimeval1a >= valTimeval2 ? " << ( *valTimeval1a >= *valTimeval2 ? "err" : "ok" ) << endl; cout << "valTimeval1a == valTimeval2 ? " << ( *valTimeval1a == *valTimeval2 ? "err" : "ok" ) << endl; delete valTimeval1a; delete valTimeval1b; delete valTimeval2; return 0; }