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 110 111 112 113 114
|
// NOLINTBEGIN(*)
#include "old_common.h"
int main()
{
// Test empty
DeviceData da;
long lo;
bitset<DeviceData::numFlags> flags;
flags.reset(DeviceData::isempty_flag);
da.exceptions(flags);
bool ret = da >> lo;
assert(ret == false);
TEST_LOG << " Extraction from empty object --> OK" << endl;
flags.set(DeviceData::isempty_flag);
da.exceptions(flags);
try
{
da >> lo;
assert(false);
}
catch(Tango::DevFailed &)
{
}
TEST_LOG << " Extraction from empty object (exception) --> OK" << endl;
flags.reset();
// Test wrong type
DeviceData db;
long l = 2;
db << l;
float fl;
ret = db >> fl;
assert(ret == false);
TEST_LOG << " Extraction with wrong type --> OK" << endl;
flags.set(DeviceData::wrongtype_flag);
db.exceptions(flags);
try
{
db >> fl;
assert(false);
}
catch(Tango::DevFailed &)
{
}
TEST_LOG << " Extraction with wrong type (exception) --> OK" << endl;
// Test assignement operator
DeviceData dd, dd_c;
vector<string> v_str;
v_str.push_back("abc");
v_str.push_back("def");
dd << v_str;
dd_c = dd;
vector<string> out;
dd_c >> out;
assert(out[0] == "abc");
assert(out[1] == "def");
TEST_LOG << " assignement operator --> OK" << endl;
// Test copy constructor
DeviceData d;
double db2 = 3.45;
d << db2;
DeviceData dc(d);
double db_out;
dc >> db_out;
assert(db_out == db2);
TEST_LOG << " Copy constructor --> OK" << endl;
// Test move assignement (if available)
DeviceData ma;
float fl_move = 3.0;
ma << fl_move;
DeviceData mb;
mb = std::move(ma);
float fl_move_out;
mb >> fl_move_out;
assert(fl_move_out == fl_move);
TEST_LOG << " Move assignement --> OK" << endl;
return 0;
}
// NOLINTEND(*)
|