提交 4df4ae80 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix Value.TYPE_COUNT and TestValueMemory

上级 c3f92764
......@@ -242,7 +242,7 @@ public abstract class Value {
/**
* The number of value types.
*/
public static final int TYPE_COUNT = INTERVAL_MINUTE_TO_SECOND;
public static final int TYPE_COUNT = INTERVAL_MINUTE_TO_SECOND + 1;
private static SoftReference<Value[]> softCache;
private static final BigDecimal MAX_LONG_DECIMAL =
......
......@@ -12,6 +12,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.Random;
import org.h2.api.IntervalQualifier;
import org.h2.api.JavaObjectSerializer;
import org.h2.engine.Constants;
import org.h2.store.DataHandler;
......@@ -36,6 +38,7 @@ import org.h2.value.ValueDouble;
import org.h2.value.ValueFloat;
import org.h2.value.ValueGeometry;
import org.h2.value.ValueInt;
import org.h2.value.ValueInterval;
import org.h2.value.ValueJavaObject;
import org.h2.value.ValueLong;
import org.h2.value.ValueNull;
......@@ -81,6 +84,10 @@ public class TestValueMemory extends TestBase implements DataHandler {
// experiment
continue;
}
if (i == Value.ENUM) {
// TODO ENUM
continue;
}
Value v = create(i);
String s = "type: " + v.getType() +
" calculated: " + v.getMemory() +
......@@ -94,6 +101,10 @@ public class TestValueMemory extends TestBase implements DataHandler {
// experiment
continue;
}
if (i == Value.ENUM) {
// TODO ENUM
continue;
}
Value v = create(i);
if (v == ValueNull.INSTANCE && i == Value.GEOMETRY) {
// jts not in the classpath, OK
......@@ -219,6 +230,23 @@ public class TestValueMemory extends TestBase implements DataHandler {
}
return ValueGeometry.get("POINT (" + random.nextInt(100) + " " +
random.nextInt(100) + ")");
case Value.INTERVAL_YEAR:
case Value.INTERVAL_MONTH:
case Value.INTERVAL_DAY:
case Value.INTERVAL_HOUR:
case Value.INTERVAL_MINUTE:
return ValueInterval.from(IntervalQualifier.valueOf(type - Value.INTERVAL_YEAR),
random.nextInt(), 0);
case Value.INTERVAL_SECOND:
case Value.INTERVAL_YEAR_TO_MONTH:
case Value.INTERVAL_DAY_TO_HOUR:
case Value.INTERVAL_DAY_TO_MINUTE:
case Value.INTERVAL_DAY_TO_SECOND:
case Value.INTERVAL_HOUR_TO_MINUTE:
case Value.INTERVAL_HOUR_TO_SECOND:
case Value.INTERVAL_MINUTE_TO_SECOND:
return ValueInterval.from(IntervalQualifier.valueOf(type - Value.INTERVAL_YEAR),
random.nextInt(), random.nextInt(24));
default:
throw new AssertionError("type=" + type);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论