testModulusDecimal();
testModulusOperator();
}
private void testCastTrim() {
Value v;
String spaces = new String(new char[100]).replace((char) 0, ' ');
v = ValueArray.get(new Value[]{ValueString.get("hello"), ValueString.get("world")});
assertEquals(10, v.getPrecision());
assertEquals(5, v.convertPrecision(5, true).getPrecision());
v = ValueArray.get(new Value[]{ValueString.get(""), ValueString.get("")});
assertEquals(0, v.getPrecision());
assertEquals("('')", v.convertPrecision(1, true).toString());
v = ValueBytes.get(spaces.getBytes());
assertEquals(100, v.getPrecision());
assertEquals(10, v.convertPrecision(10, false).getPrecision());
assertEquals(10, v.convertPrecision(10, false).getBytes().length);
assertEquals(32, v.convertPrecision(10, false).getBytes()[9]);
assertEquals(10, v.convertPrecision(10, true).getPrecision());
final Value vd = ValueDecimal.get(new BigDecimal("1234567890.123456789"));
assertEquals(19, vd.getPrecision());
assertEquals("1234567890.1234567", vd.convertPrecision(10, true).getString());
new AssertThrows(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1) { public void test() {
vd.convertPrecision(10, false);
}};
v = ValueLobDb.createSmallLob(Value.CLOB, spaces.getBytes(), 100);
assertEquals(100, v.getPrecision());
assertEquals(10, v.convertPrecision(10, false).getPrecision());