DataPointImpl datapoint = new DataPointImpl(
CosDpValueTypeEnum.TypeNumber);
datapoint.keyId = 1;
datapoint.name = "real-number";
CosDpValueUnion outValue = new CosDpValueUnion();
CosDpValueUnion in_bool_value = new CosDpValueUnion();
in_bool_value.boolValue(false);
CosDpValueUnion in_number_value = new CosDpValueUnion();
in_number_value.longValue(0);
CosDpValueUnion in_unsigned_value = new CosDpValueUnion();
in_unsigned_value.unsignedValue(0);
CosDpValueUnion in_double_value = new CosDpValueUnion();
in_double_value.dblValue(0.0);
CosDpValueUnion in_string_value = new CosDpValueUnion();
in_string_value.charValue("");
// BOOLEAN data type
// copy bool to bool (new value)
outValue.boolValue(false);
in_bool_value.boolValue(true);
int status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(1, status);
Assert.assertEquals(outValue.boolValue(), in_bool_value.boolValue());
// copy bool to bool (the same value)
outValue.boolValue(false);
in_bool_value.boolValue(false);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(0, status);
Assert.assertEquals(outValue.boolValue(), in_bool_value.boolValue());
// copy number to bool (value = 0)
outValue.boolValue(false);
in_number_value.longValue(0);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(0, status);
Assert.assertEquals(false, outValue.boolValue());
// copy number to bool (value = -1)
outValue.boolValue(false);
in_number_value.longValue(-1);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(true, outValue.boolValue());
// copy number to bool (value = +1)
outValue.boolValue(false);
in_number_value.longValue(1);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(true, outValue.boolValue());
// copy unsigned to bool (value = 0)
outValue.boolValue(false);
in_unsigned_value.unsignedValue(0);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(0, status);
Assert.assertEquals(false, outValue.boolValue());
// copy unsigned to bool (value = +1)
outValue.boolValue(false);
in_unsigned_value.unsignedValue(1);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertEquals(true, outValue.boolValue());
// copy double to bool (value = 0)
outValue.boolValue(false);
in_double_value.dblValue(0);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(0, status);
Assert.assertEquals(false, outValue.boolValue());
// copy double to bool (value = -1.5)
outValue.boolValue(false);
in_double_value.dblValue(-1.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(true, outValue.boolValue());
// copy double to bool (value = -1.5)
outValue.boolValue(false);
in_double_value.dblValue(1.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(true, outValue.boolValue());
// copy string to bool (value = "")
outValue.boolValue(false);
in_string_value.charValue("");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(false, outValue.boolValue());
// copy string to bool (value = "test")
outValue.boolValue(false);
in_string_value.charValue("test");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(true, outValue.boolValue());
// copy string to bool (value = null)
outValue.boolValue(false);
in_string_value.charValue(null);
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(false, outValue.boolValue());
// NUMBER data type
// copy bool to number (value = true)
outValue.longValue(0);
in_bool_value.boolValue(true);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(1, status);
Assert.assertEquals(1, outValue.longValue());
// copy bool to number (value = false)
outValue.longValue(0);
in_bool_value.boolValue(false);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// copy number to number (value = 0, the same value)
outValue.longValue(0);
in_number_value.longValue(0);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// copy number to number (value = 0, the different value)
outValue.longValue(1);
in_number_value.longValue(0);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(0, outValue.longValue());
// copy number to number (value = -1)
outValue.longValue(0);
in_number_value.longValue(-11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(-11, outValue.longValue());
// copy number to number (value = +1)
outValue.longValue(0);
in_number_value.longValue(11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.longValue());
// copy unsigned to number (value = 0)
outValue.longValue(0);
in_unsigned_value.unsignedValue(0);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// copy unsigned to number (value = +1)
outValue.longValue(0);
in_unsigned_value.unsignedValue(11);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.longValue());
// copy double to number (value = 0)
outValue.longValue(0);
in_double_value.dblValue(0);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// copy double to number (value = -11.5)
outValue.longValue(0);
in_double_value.dblValue(-11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(-11, outValue.longValue());
// copy double to number (value = 11.5)
outValue.longValue(0);
in_double_value.dblValue(11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.longValue());
// copy string to number (value = "")
outValue.longValue(0);
in_string_value.charValue("");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// copy string to number (value = "test")
outValue.longValue(0);
in_string_value.charValue("test");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// copy string to number (value = "11")
outValue.longValue(0);
in_string_value.charValue("11");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.longValue());
// copy string to number (value = "-11")
outValue.longValue(0);
in_string_value.charValue("-11");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(-11, outValue.longValue());
// copy string to number (value = null)
outValue.longValue(0);
in_string_value.charValue(null);
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.longValue());
// UNSIGNED data type
// copy bool to unsigned (value = true)
outValue.unsignedValue(0);
in_bool_value.boolValue(true);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(1, status);
Assert.assertEquals(1, outValue.unsignedValue());
// copy bool to unsigned (value = false)
outValue.unsignedValue(0);
in_bool_value.boolValue(false);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy number to unsigned (value = 0)
outValue.unsignedValue(0);
in_number_value.longValue(0);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy number to unsigned (value = -11)
outValue.unsignedValue(0);
in_number_value.longValue(-11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy number to unsigned (value = +11)
outValue.unsignedValue(0);
in_number_value.longValue(11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy unsigned to unsigned (value = 0, the same value)
outValue.unsignedValue(0);
in_unsigned_value.unsignedValue(0);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy unsigned to unsigned (value = 0, the different value)
outValue.unsignedValue(11);
in_unsigned_value.unsignedValue(0);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy unsigned to unsigned (value = +11)
outValue.unsignedValue(0);
in_unsigned_value.unsignedValue(11);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy double to unsigned (value = 0)
outValue.unsignedValue(0);
in_double_value.dblValue(0);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy double to unsigned (value = -11.5)
outValue.unsignedValue(0);
in_double_value.dblValue(-11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy double to unsigned (value = 11.5)
outValue.unsignedValue(0);
in_double_value.dblValue(11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy string to unsigned (value = "")
outValue.unsignedValue(0);
in_string_value.charValue("");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy string to unsigned (value = "test")
outValue.unsignedValue(0);
in_string_value.charValue("test");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// copy string to unsigned (value = "11")
outValue.unsignedValue(0);
in_string_value.charValue("11");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy string to unsigned (value = "-11")
outValue.unsignedValue(0);
in_string_value.charValue("-11");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11, outValue.unsignedValue());
// copy string to unsigned (value = null)
outValue.unsignedValue(0);
in_string_value.charValue(null);
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0, outValue.unsignedValue());
// DOUBLE data type
// copy bool to double (value = true)
outValue.dblValue(0);
in_bool_value.boolValue(true);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(1, status);
Assert.assertEquals(1.0, outValue.dblValue());
// copy bool to double (value = false)
outValue.dblValue(0);
in_bool_value.boolValue(false);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy number to double (value = 0)
outValue.dblValue(0);
in_number_value.longValue(0);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy number to double (value = -11)
outValue.dblValue(0);
in_number_value.longValue(-11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(-11.0, outValue.dblValue());
// copy number to double (value = +11)
outValue.dblValue(0);
in_number_value.longValue(11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11.0, outValue.dblValue());
// copy unsigned to double (value = 0, the same value)
outValue.dblValue(0);
in_unsigned_value.unsignedValue(0);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy unsigned to double (value = +11)
outValue.dblValue(0);
in_unsigned_value.unsignedValue(11);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11.0, outValue.dblValue());
// copy double to double (value = 0, the same value)
outValue.dblValue(0);
in_double_value.dblValue(0);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy double to double (value = 0, different value)
outValue.dblValue(11);
in_double_value.dblValue(0);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy double to double (value = -11.5)
outValue.dblValue(0);
in_double_value.dblValue(-11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(-11.5, outValue.dblValue());
// copy double to double (value = 11.5)
outValue.dblValue(0);
in_double_value.dblValue(11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11.5, outValue.dblValue());
// copy string to double (value = "")
outValue.dblValue(0);
in_string_value.charValue("");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy string to double (value = "test")
outValue.dblValue(0);
in_string_value.charValue("test");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// copy string to double (value = "11.5")
outValue.dblValue(0);
in_string_value.charValue("11.5");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(11.5, outValue.dblValue());
// copy string to double (value = "-11.5")
outValue.dblValue(0);
in_string_value.charValue("-11.5");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertEquals(-11.5, outValue.dblValue());
// copy string to double (value = null)
outValue.dblValue(0);
in_string_value.charValue(null);
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertEquals(0.0, outValue.dblValue());
// STRING data type
// copy bool to string (value = true)
outValue.charValue("");
in_bool_value.boolValue(true);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(1, status);
Assert
.assertTrue(outValue.charValue().compareToIgnoreCase("true") == 0);
// copy bool to string (value = false)
outValue.charValue("");
in_bool_value.boolValue(false);
status = datapoint._copy(outValue, in_bool_value);
Assert.assertEquals(1, status);
Assert
.assertTrue(outValue.charValue().compareToIgnoreCase("false") == 0);
// copy number to string (value = 0)
outValue.charValue("");
in_number_value.longValue(0);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("0") == 0);
// copy number to string (value = -11)
outValue.charValue("");
in_number_value.longValue(-11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("-11") == 0);
// copy number to string (value = +11)
outValue.charValue("");
in_number_value.longValue(11);
status = datapoint._copy(outValue, in_number_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("11") == 0);
// copy unsigned to string (value = 0, the same value)
outValue.charValue("");
in_unsigned_value.unsignedValue(0);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("0") == 0);
// copy unsigned to string (value = +11)
outValue.charValue("");
in_unsigned_value.unsignedValue(11);
status = datapoint._copy(outValue, in_unsigned_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("11") == 0);
// copy double to string (value = 0, the same value)
outValue.charValue("");
in_double_value.dblValue(0);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("0.0") == 0);
// copy double to string (value = -11.5)
outValue.charValue("");
in_double_value.dblValue(-11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("-11.5") == 0);
// copy double to string (value = 11.5)
outValue.charValue("");
in_double_value.dblValue(11.5);
status = datapoint._copy(outValue, in_double_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("11.5") == 0);
// copy string to string (value = "")
outValue.charValue("");
in_string_value.charValue("");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertTrue(outValue.charValue().compareTo("") == 0);
// copy string to string (value = "Test")
outValue.charValue("test");
in_string_value.charValue("Test");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(1, status);
Assert.assertTrue(outValue.charValue().compareTo("Test") == 0);
// copy string to string (value = "Test", the same value)
outValue.charValue("Test");
in_string_value.charValue("Test");
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertTrue(outValue.charValue().compareTo("Test") == 0);
// copy string to string (value = null)
outValue.charValue("");
in_string_value.charValue(null);
status = datapoint._copy(outValue, in_string_value);
Assert.assertEquals(0, status);
Assert.assertTrue(outValue.charValue().compareTo("") == 0);
// copy null to string (value = null)
outValue.charValue("Test");
status = datapoint._copy(outValue, null);
Assert.assertEquals(-1, status);
Assert.assertTrue(outValue.charValue().compareTo("Test") == 0);
// copy string to string (value = null)
in_string_value.charValue("Test");
status = datapoint._copy(null, in_string_value);
Assert.assertEquals(-1, status);
}