Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0e91d76a
Unverified
提交
0e91d76a
authored
2月 03, 2019
作者:
Evgenij Ryazanov
提交者:
GitHub
2月 03, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1713 from katzyn/value
Remove DataType.defaultDisplaySize and fix display size in TypeInfo
上级
992f5c7f
cf0283d6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
223 行增加
和
80 行删除
+223
-80
CustomDataTypesHandler.java
h2/src/main/org/h2/api/CustomDataTypesHandler.java
+13
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-1
BinaryOperation.java
h2/src/main/org/h2/expression/BinaryOperation.java
+2
-2
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-1
Function.java
h2/src/main/org/h2/expression/function/Function.java
+2
-2
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+4
-4
DataType.java
h2/src/main/org/h2/value/DataType.java
+1
-16
TypeInfo.java
h2/src/main/org/h2/value/TypeInfo.java
+76
-51
TestCustomDataTypesHandler.java
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
+5
-1
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+2
-2
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+116
-0
没有找到文件。
h2/src/main/org/h2/api/CustomDataTypesHandler.java
浏览文件 @
0e91d76a
...
...
@@ -7,6 +7,8 @@ package org.h2.api;
import
org.h2.store.DataHandler
;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
/**
...
...
@@ -36,6 +38,17 @@ public interface CustomDataTypesHandler {
*/
DataType
getDataTypeById
(
int
type
);
/**
* Get type info for the given data type identity.
*
* @param type identifier of a data type
* @param precision precision
* @param scale scale
* @param extTypeInfo the extended type information, or null
* @return type information
*/
TypeInfo
getTypeInfoById
(
int
type
,
long
precision
,
int
scale
,
ExtTypeInfo
extTypeInfo
);
/**
* Get order for custom data type given its integer id
*
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
0e91d76a
...
...
@@ -5899,7 +5899,7 @@ public class Parser {
String
columnName
=
"C"
+
(
i
+
1
);
if
(
rows
.
isEmpty
())
{
if
(
type
.
getValueType
()
==
Value
.
UNKNOWN
)
{
type
=
TypeInfo
.
TYPE_STRING
_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING
;
}
column
=
new
Column
(
columnName
,
type
);
columns
.
add
(
column
);
...
...
h2/src/main/org/h2/expression/BinaryOperation.java
浏览文件 @
0e91d76a
...
...
@@ -172,7 +172,7 @@ public class BinaryOperation extends Expression {
break
;
}
}
type
=
TypeInfo
.
TYPE_STRING
_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING
;
break
;
}
case
PLUS:
...
...
@@ -188,7 +188,7 @@ public class BinaryOperation extends Expression {
// string when text concatenation with + is enabled
if
(
opType
==
OpType
.
PLUS
&&
session
.
getDatabase
().
getMode
().
allowPlusForStringConcat
)
{
type
=
TypeInfo
.
TYPE_STRING
_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING
;
opType
=
OpType
.
CONCAT
;
}
else
{
type
=
TypeInfo
.
TYPE_DECIMAL_DEFAULT
;
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
0e91d76a
...
...
@@ -648,7 +648,7 @@ public class Aggregate extends AbstractAggregate {
}
switch
(
aggregateType
)
{
case
GROUP_CONCAT:
type
=
TypeInfo
.
TYPE_STRING
_DEFAULT
;
type
=
TypeInfo
.
TYPE_STRING
;
break
;
case
COUNT_ALL:
case
COUNT:
...
...
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
0e91d76a
...
...
@@ -2374,7 +2374,7 @@ public class Function extends Expression implements FunctionCall {
}
}
if
(
typeInfo
.
getValueType
()
==
Value
.
UNKNOWN
)
{
typeInfo
=
TypeInfo
.
TYPE_STRING
_DEFAULT
;
typeInfo
=
TypeInfo
.
TYPE_STRING
;
}
break
;
}
...
...
@@ -2406,7 +2406,7 @@ public class Function extends Expression implements FunctionCall {
}
}
if
(
typeInfo
.
getValueType
()
==
Value
.
UNKNOWN
)
{
typeInfo
=
TypeInfo
.
TYPE_STRING
_DEFAULT
;
typeInfo
=
TypeInfo
.
TYPE_STRING
;
}
break
;
}
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
0e91d76a
...
...
@@ -3187,12 +3187,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements
public
ResultSet
getClientInfoProperties
()
throws
SQLException
{
Properties
clientInfo
=
conn
.
getClientInfo
();
SimpleResult
result
=
new
SimpleResult
();
result
.
addColumn
(
"NAME"
,
"NAME"
,
TypeInfo
.
TYPE_STRING
_DEFAULT
);
result
.
addColumn
(
"NAME"
,
"NAME"
,
TypeInfo
.
TYPE_STRING
);
result
.
addColumn
(
"MAX_LEN"
,
"MAX_LEN"
,
TypeInfo
.
TYPE_INT
);
result
.
addColumn
(
"DEFAULT_VALUE"
,
"DEFAULT_VALUE"
,
TypeInfo
.
TYPE_STRING
_DEFAULT
);
result
.
addColumn
(
"DESCRIPTION"
,
"DESCRIPTION"
,
TypeInfo
.
TYPE_STRING
_DEFAULT
);
result
.
addColumn
(
"DEFAULT_VALUE"
,
"DEFAULT_VALUE"
,
TypeInfo
.
TYPE_STRING
);
result
.
addColumn
(
"DESCRIPTION"
,
"DESCRIPTION"
,
TypeInfo
.
TYPE_STRING
);
// Non-standard column
result
.
addColumn
(
"VALUE"
,
"VALUE"
,
TypeInfo
.
TYPE_STRING
_DEFAULT
);
result
.
addColumn
(
"VALUE"
,
"VALUE"
,
TypeInfo
.
TYPE_STRING
);
for
(
Entry
<
Object
,
Object
>
entry
:
clientInfo
.
entrySet
())
{
result
.
addRow
(
ValueString
.
get
((
String
)
entry
.
getKey
()),
ValueInt
.
get
(
Integer
.
MAX_VALUE
),
ValueString
.
EMPTY
,
ValueString
.
EMPTY
,
ValueString
.
get
((
String
)
entry
.
getValue
()));
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
0e91d76a
...
...
@@ -158,11 +158,6 @@ public class DataType {
*/
public
int
defaultScale
;
/**
* The default display size.
*/
public
int
defaultDisplaySize
;
/**
* If this data type should not be listed in the database meta data.
*/
...
...
@@ -185,7 +180,6 @@ public class DataType {
DataType
dataType
=
new
DataType
();
dataType
.
defaultPrecision
=
dataType
.
maxPrecision
=
ValueNull
.
PRECISION
;
dataType
.
defaultDisplaySize
=
ValueNull
.
DISPLAY_SIZE
;
add
(
Value
.
NULL
,
Types
.
NULL
,
dataType
,
new
String
[]{
"NULL"
},
...
...
@@ -337,7 +331,6 @@ public class DataType {
dataType
=
new
DataType
();
dataType
.
prefix
=
dataType
.
suffix
=
"'"
;
dataType
.
defaultPrecision
=
dataType
.
maxPrecision
=
ValueUuid
.
PRECISION
;
dataType
.
defaultDisplaySize
=
ValueUuid
.
DISPLAY_SIZE
;
add
(
Value
.
UUID
,
Types
.
BINARY
,
createString
(
false
),
// UNIQUEIDENTIFIER is the MSSQL mode equivalent
...
...
@@ -377,7 +370,7 @@ public class DataType {
32
);
dataType
=
new
DataType
();
dataType
.
maxPrecision
=
dataType
.
defaultPrecision
=
dataType
.
defaultDisplaySize
=
Integer
.
MAX_VALUE
;
dataType
.
maxPrecision
=
dataType
.
defaultPrecision
=
Integer
.
MAX_VALUE
;
add
(
Value
.
RESULT_SET
,
DataType
.
TYPE_RESULT_SET
,
dataType
,
new
String
[]{
"RESULT_SET"
},
...
...
@@ -441,9 +434,6 @@ public class DataType {
dataType
.
defaultScale
=
ValueInterval
.
DEFAULT_SCALE
;
dataType
.
maxScale
=
ValueInterval
.
MAXIMUM_SCALE
;
}
dataType
.
defaultDisplaySize
=
ValueInterval
.
getDisplaySize
(
type
,
ValueInterval
.
DEFAULT_PRECISION
,
// Scale will be ignored if it is not supported
ValueInterval
.
DEFAULT_SCALE
);
add
(
type
,
Types
.
OTHER
,
dataType
,
new
String
[]{(
"INTERVAL "
+
name
).
intern
()},
36
...
...
@@ -469,7 +459,6 @@ public class DataType {
dt
.
supportsScale
=
dataType
.
supportsScale
;
dt
.
defaultPrecision
=
dataType
.
defaultPrecision
;
dt
.
defaultScale
=
dataType
.
defaultScale
;
dt
.
defaultDisplaySize
=
dataType
.
defaultDisplaySize
;
dt
.
caseSensitive
=
dataType
.
caseSensitive
;
dt
.
hidden
=
i
>
0
;
dt
.
memory
=
memory
;
...
...
@@ -504,7 +493,6 @@ public class DataType {
dataType
.
maxPrecision
=
maxPrecision
;
dataType
.
defaultPrecision
=
defaultPrecision
;
dataType
.
defaultScale
=
defaultScale
;
dataType
.
defaultDisplaySize
=
defaultDisplaySize
;
if
(
needsPrecisionAndScale
)
{
dataType
.
params
=
"PRECISION,SCALE"
;
dataType
.
supportsPrecision
=
true
;
...
...
@@ -537,7 +525,6 @@ public class DataType {
dataType
.
maxScale
=
maxScale
;
dataType
.
defaultPrecision
=
precision
;
dataType
.
defaultScale
=
scale
;
dataType
.
defaultDisplaySize
=
precision
;
return
dataType
;
}
...
...
@@ -550,7 +537,6 @@ public class DataType {
dataType
.
supportsPrecision
=
true
;
dataType
.
maxPrecision
=
Integer
.
MAX_VALUE
;
dataType
.
defaultPrecision
=
Integer
.
MAX_VALUE
;
dataType
.
defaultDisplaySize
=
Integer
.
MAX_VALUE
;
return
dataType
;
}
...
...
@@ -568,7 +554,6 @@ public class DataType {
dataType
.
params
=
"TYPE,SRID"
;
dataType
.
maxPrecision
=
Integer
.
MAX_VALUE
;
dataType
.
defaultPrecision
=
Integer
.
MAX_VALUE
;
dataType
.
defaultDisplaySize
=
Integer
.
MAX_VALUE
;
return
dataType
;
}
...
...
h2/src/main/org/h2/value/TypeInfo.java
浏览文件 @
0e91d76a
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestCustomDataTypesHandler.java
浏览文件 @
0e91d76a
...
...
@@ -191,7 +191,6 @@ public class TestCustomDataTypesHandler extends TestDb {
if
(
name
.
toLowerCase
(
Locale
.
ENGLISH
).
equals
(
COMPLEX_DATA_TYPE_NAME
))
{
return
complexDataType
;
}
return
null
;
}
...
...
@@ -203,6 +202,11 @@ public class TestCustomDataTypesHandler extends TestDb {
return
null
;
}
@Override
public
TypeInfo
getTypeInfoById
(
int
type
,
long
precision
,
int
scale
,
ExtTypeInfo
extTypeInfo
)
{
return
new
TypeInfo
(
type
,
0
,
0
,
ValueDouble
.
DISPLAY_SIZE
*
2
+
1
,
null
);
}
@Override
public
String
getDataTypeClassName
(
int
type
)
{
if
(
type
==
COMPLEX_DATA_TYPE_ID
)
{
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
0e91d76a
...
...
@@ -143,7 +143,7 @@ public class TestDate extends TestBase {
assertEquals
((
int
)
((
nanos
>>>
32
)
^
nanos
),
t1
.
hashCode
());
// Literals return maximum precision
TypeInfo
type
=
t1
.
getType
();
assertEquals
(
ValueTime
.
DEFAULT
_PRECISION
,
type
.
getDisplaySize
());
assertEquals
(
ValueTime
.
MAXIMUM
_PRECISION
,
type
.
getDisplaySize
());
assertEquals
(
ValueTime
.
MAXIMUM_PRECISION
,
type
.
getPrecision
());
assertEquals
(
"java.sql.Time"
,
t1
.
getObject
().
getClass
().
getName
());
ValueTime
t1b
=
ValueTime
.
parse
(
"11:11:11"
);
...
...
@@ -221,7 +221,7 @@ public class TestDate extends TestBase {
t1
.
hashCode
());
// Literals return maximum precision
TypeInfo
type
=
t1
.
getType
();
assertEquals
(
ValueTimestamp
.
DEFAULT
_PRECISION
,
type
.
getDisplaySize
());
assertEquals
(
ValueTimestamp
.
MAXIMUM
_PRECISION
,
type
.
getDisplaySize
());
assertEquals
(
ValueTimestamp
.
MAXIMUM_PRECISION
,
type
.
getPrecision
());
assertEquals
(
9
,
type
.
getScale
());
assertEquals
(
"java.sql.Timestamp"
,
t1
.
getObject
().
getClass
().
getName
());
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
0e91d76a
...
...
@@ -45,6 +45,7 @@ import org.h2.value.ValueDecimal;
import
org.h2.value.ValueDouble
;
import
org.h2.value.ValueFloat
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInterval
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueLobDb
;
import
org.h2.value.ValueNull
;
...
...
@@ -83,6 +84,7 @@ public class TestValue extends TestDb {
testModulusDecimal
();
testModulusOperator
();
testLobComparison
();
testTypeInfo
();
}
private
void
testResultSetOperations
()
throws
SQLException
{
...
...
@@ -502,4 +504,118 @@ public class TestValue extends TestDb {
}
}
private
void
testTypeInfo
()
{
testTypeInfoCheck
(
Value
.
UNKNOWN
,
-
1
,
-
1
,
-
1
,
TypeInfo
.
TYPE_UNKNOWN
);
try
{
TypeInfo
.
getTypeInfo
(
Value
.
UNKNOWN
);
fail
();
}
catch
(
DbException
ex
)
{
assertEquals
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
ex
.
getErrorCode
());
}
testTypeInfoCheck
(
Value
.
NULL
,
1
,
0
,
4
,
TypeInfo
.
TYPE_NULL
,
TypeInfo
.
getTypeInfo
(
Value
.
NULL
));
testTypeInfoCheck
(
Value
.
BOOLEAN
,
1
,
0
,
5
,
TypeInfo
.
TYPE_BOOLEAN
,
TypeInfo
.
getTypeInfo
(
Value
.
BOOLEAN
));
testTypeInfoCheck
(
Value
.
BYTE
,
3
,
0
,
4
,
TypeInfo
.
TYPE_BYTE
,
TypeInfo
.
getTypeInfo
(
Value
.
BYTE
));
testTypeInfoCheck
(
Value
.
SHORT
,
5
,
0
,
6
,
TypeInfo
.
TYPE_SHORT
,
TypeInfo
.
getTypeInfo
(
Value
.
SHORT
));
testTypeInfoCheck
(
Value
.
INT
,
10
,
0
,
11
,
TypeInfo
.
TYPE_INT
,
TypeInfo
.
getTypeInfo
(
Value
.
INT
));
testTypeInfoCheck
(
Value
.
LONG
,
19
,
0
,
20
,
TypeInfo
.
TYPE_LONG
,
TypeInfo
.
getTypeInfo
(
Value
.
LONG
));
testTypeInfoCheck
(
Value
.
FLOAT
,
7
,
0
,
15
,
TypeInfo
.
TYPE_FLOAT
,
TypeInfo
.
getTypeInfo
(
Value
.
FLOAT
));
testTypeInfoCheck
(
Value
.
DOUBLE
,
17
,
0
,
24
,
TypeInfo
.
TYPE_DOUBLE
,
TypeInfo
.
getTypeInfo
(
Value
.
DOUBLE
));
testTypeInfoCheck
(
Value
.
DECIMAL
,
Integer
.
MAX_VALUE
,
Integer
.
MAX_VALUE
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_DECIMAL
,
TypeInfo
.
getTypeInfo
(
Value
.
DECIMAL
));
testTypeInfoCheck
(
Value
.
DECIMAL
,
65_535
,
32_767
,
65_537
,
TypeInfo
.
TYPE_DECIMAL_DEFAULT
);
testTypeInfoCheck
(
Value
.
TIME
,
18
,
9
,
18
,
TypeInfo
.
TYPE_TIME
,
TypeInfo
.
getTypeInfo
(
Value
.
TIME
));
for
(
int
s
=
0
;
s
<=
9
;
s
++)
{
int
d
=
s
>
0
?
s
+
9
:
8
;
testTypeInfoCheck
(
Value
.
TIME
,
d
,
s
,
d
,
TypeInfo
.
getTypeInfo
(
Value
.
TIME
,
0
,
s
,
null
));
}
testTypeInfoCheck
(
Value
.
DATE
,
10
,
0
,
10
,
TypeInfo
.
TYPE_DATE
,
TypeInfo
.
getTypeInfo
(
Value
.
DATE
));
testTypeInfoCheck
(
Value
.
TIMESTAMP
,
29
,
9
,
29
,
TypeInfo
.
TYPE_TIMESTAMP
,
TypeInfo
.
getTypeInfo
(
Value
.
TIMESTAMP
));
for
(
int
s
=
0
;
s
<=
9
;
s
++)
{
int
d
=
s
>
0
?
s
+
20
:
19
;
testTypeInfoCheck
(
Value
.
TIMESTAMP
,
d
,
s
,
d
,
TypeInfo
.
getTypeInfo
(
Value
.
TIMESTAMP
,
0
,
s
,
null
));
}
testTypeInfoCheck
(
Value
.
TIMESTAMP_TZ
,
35
,
9
,
35
,
TypeInfo
.
TYPE_TIMESTAMP_TZ
,
TypeInfo
.
getTypeInfo
(
Value
.
TIMESTAMP_TZ
));
for
(
int
s
=
0
;
s
<=
9
;
s
++)
{
int
d
=
s
>
0
?
s
+
26
:
25
;
testTypeInfoCheck
(
Value
.
TIMESTAMP_TZ
,
d
,
s
,
d
,
TypeInfo
.
getTypeInfo
(
Value
.
TIMESTAMP_TZ
,
0
,
s
,
null
));
}
testTypeInfoCheck
(
Value
.
BYTES
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
getTypeInfo
(
Value
.
BYTES
));
testTypeInfoCheck
(
Value
.
BLOB
,
Long
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
getTypeInfo
(
Value
.
BLOB
));
testTypeInfoCheck
(
Value
.
CLOB
,
Long
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
getTypeInfo
(
Value
.
CLOB
));
testTypeInfoCheck
(
Value
.
STRING
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_STRING
,
TypeInfo
.
getTypeInfo
(
Value
.
STRING
));
testTypeInfoCheck
(
Value
.
STRING_FIXED
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
getTypeInfo
(
Value
.
STRING_FIXED
));
testTypeInfoCheck
(
Value
.
STRING_IGNORECASE
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
getTypeInfo
(
Value
.
STRING_IGNORECASE
));
testTypeInfoCheck
(
Value
.
ARRAY
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_ARRAY
,
TypeInfo
.
getTypeInfo
(
Value
.
ARRAY
));
testTypeInfoCheck
(
Value
.
RESULT_SET
,
Integer
.
MAX_VALUE
,
Integer
.
MAX_VALUE
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_RESULT_SET
,
TypeInfo
.
getTypeInfo
(
Value
.
RESULT_SET
));
testTypeInfoCheck
(
Value
.
ROW
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_ROW
,
TypeInfo
.
getTypeInfo
(
Value
.
ROW
));
testTypeInfoCheck
(
Value
.
JAVA_OBJECT
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_JAVA_OBJECT
,
TypeInfo
.
getTypeInfo
(
Value
.
JAVA_OBJECT
));
testTypeInfoCheck
(
Value
.
UUID
,
16
,
0
,
36
,
TypeInfo
.
TYPE_UUID
,
TypeInfo
.
getTypeInfo
(
Value
.
UUID
));
testTypeInfoCheck
(
Value
.
GEOMETRY
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_GEOMETRY
,
TypeInfo
.
getTypeInfo
(
Value
.
GEOMETRY
));
testTypeInfoCheck
(
Value
.
ENUM
,
Integer
.
MAX_VALUE
,
0
,
Integer
.
MAX_VALUE
,
TypeInfo
.
TYPE_ENUM_UNDEFINED
,
TypeInfo
.
getTypeInfo
(
Value
.
ENUM
));
testTypeInfoInterval1
(
Value
.
INTERVAL_YEAR
);
testTypeInfoInterval1
(
Value
.
INTERVAL_MONTH
);
testTypeInfoInterval1
(
Value
.
INTERVAL_DAY
);
testTypeInfoInterval1
(
Value
.
INTERVAL_HOUR
);
testTypeInfoInterval1
(
Value
.
INTERVAL_MINUTE
);
testTypeInfoInterval2
(
Value
.
INTERVAL_SECOND
);
testTypeInfoInterval1
(
Value
.
INTERVAL_YEAR_TO_MONTH
);
testTypeInfoInterval1
(
Value
.
INTERVAL_DAY_TO_HOUR
);
testTypeInfoInterval1
(
Value
.
INTERVAL_DAY_TO_MINUTE
);
testTypeInfoInterval2
(
Value
.
INTERVAL_DAY_TO_SECOND
);
testTypeInfoInterval1
(
Value
.
INTERVAL_HOUR_TO_MINUTE
);
testTypeInfoInterval2
(
Value
.
INTERVAL_HOUR_TO_SECOND
);
testTypeInfoInterval2
(
Value
.
INTERVAL_MINUTE_TO_SECOND
);
}
private
void
testTypeInfoInterval1
(
int
type
)
{
testTypeInfoCheck
(
type
,
18
,
0
,
ValueInterval
.
getDisplaySize
(
type
,
18
,
0
),
TypeInfo
.
getTypeInfo
(
type
));
for
(
int
p
=
1
;
p
<=
18
;
p
++)
{
testTypeInfoCheck
(
type
,
p
,
0
,
ValueInterval
.
getDisplaySize
(
type
,
p
,
0
),
TypeInfo
.
getTypeInfo
(
type
,
p
,
0
,
null
));
}
}
private
void
testTypeInfoInterval2
(
int
type
)
{
testTypeInfoCheck
(
type
,
18
,
9
,
ValueInterval
.
getDisplaySize
(
type
,
18
,
9
),
TypeInfo
.
getTypeInfo
(
type
));
for
(
int
p
=
1
;
p
<=
18
;
p
++)
{
for
(
int
s
=
0
;
s
<=
9
;
s
++)
{
testTypeInfoCheck
(
type
,
p
,
s
,
ValueInterval
.
getDisplaySize
(
type
,
p
,
s
),
TypeInfo
.
getTypeInfo
(
type
,
p
,
s
,
null
));
}
}
}
private
void
testTypeInfoCheck
(
int
valueType
,
long
precision
,
int
scale
,
int
displaySize
,
TypeInfo
...
typeInfos
)
{
for
(
TypeInfo
typeInfo
:
typeInfos
)
{
testTypeInfoCheck
(
valueType
,
precision
,
scale
,
displaySize
,
typeInfo
);
}
}
private
void
testTypeInfoCheck
(
int
valueType
,
long
precision
,
int
scale
,
int
displaySize
,
TypeInfo
typeInfo
)
{
assertEquals
(
valueType
,
typeInfo
.
getValueType
());
assertEquals
(
precision
,
typeInfo
.
getPrecision
());
assertEquals
(
scale
,
typeInfo
.
getScale
());
assertEquals
(
displaySize
,
typeInfo
.
getDisplaySize
());
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论