提交 206c716f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add more tests of ValueArray.convertPrecision()

上级 dd39e633
......@@ -849,6 +849,19 @@ public abstract class TestBase {
assertFalse(message, rs1.next());
}
/**
* Check if two objects are the same, and if not throw an exception.
*
* @param expected the expected value
* @param actual the actual value
* @throws AssertionError if the objects are not the same
*/
public void assertSame(Object expected, Object actual) {
if (expected != actual) {
fail(" expected: " + expected + " != actual: " + actual);
}
}
/**
* Check if the first value is larger or equal than the second value, and if
* not throw an exception.
......
......@@ -61,6 +61,7 @@ public class TestValue extends TestBase {
testCastTrim();
testValueResultSet();
testDataType();
testArray();
testUUID();
testDouble(false);
testDouble(true);
......@@ -330,6 +331,21 @@ public class TestValue extends TestBase {
assertEquals(123123123, ts.getNanos());
}
private void testArray() {
ValueArray src = ValueArray.get(
new Value[] {ValueString.get("1"), ValueString.get("22"), ValueString.get("333")});
assertEquals(6, src.getPrecision());
assertSame(src, src.convertPrecision(5, false));
assertEquals(src, src.convertPrecision(6, true));
ValueArray exp = ValueArray.get(
new Value[] {ValueString.get("1"), ValueString.get("22"), ValueString.get("33")});
assertEquals(exp, src.convertPrecision(5, true));
exp = ValueArray.get(new Value[] {ValueString.get("1"), ValueString.get("22")});
assertEquals(exp, src.convertPrecision(3, true));
exp = ValueArray.get(new Value[0]);
assertEquals(exp, src.convertPrecision(0, true));
}
private void testUUID() {
long maxHigh = 0, maxLow = 0, minHigh = -1L, minLow = -1L;
for (int i = 0; i < 100; i++) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论