Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
736b6d51
提交
736b6d51
authored
1月 06, 2018
作者:
sylvain-ilm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TestFunctions less english dependent
上级
f9e3bb4a
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
14 行删除
+24
-14
ToChar.java
h2/src/main/org/h2/util/ToChar.java
+3
-2
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+21
-12
没有找到文件。
h2/src/main/org/h2/util/ToChar.java
浏览文件 @
736b6d51
...
...
@@ -17,6 +17,7 @@ import java.util.Currency;
import
java.util.GregorianCalendar
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
org.h2.api.ErrorCode
;
import
org.h2.message.DbException
;
...
...
@@ -884,7 +885,7 @@ public class ToChar {
}
/** Represents a capitalization / casing strategy. */
private
enum
Capitalization
{
static
public
enum
Capitalization
{
/**
* All letters are uppercased.
...
...
@@ -911,7 +912,7 @@ public class ToChar {
* @return the capitalization / casing strategy which should be used
* when the first and second letters have the specified casing
*/
p
ublic
static
Capitalization
toCapitalization
(
Boolean
up1
,
Boolean
up2
)
{
p
rivate
static
Capitalization
toCapitalization
(
Boolean
up1
,
Boolean
up2
)
{
if
(
up1
==
null
)
{
return
Capitalization
.
CAPITALIZE
;
}
else
if
(
up2
==
null
)
{
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
736b6d51
...
...
@@ -27,6 +27,7 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
java.text.DecimalFormatSymbols
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
...
...
@@ -53,6 +54,7 @@ import org.h2.util.DateTimeUtils;
import
org.h2.util.IOUtils
;
import
org.h2.util.New
;
import
org.h2.util.StringUtils
;
import
org.h2.util.ToChar.Capitalization
;
import
org.h2.util.ToDateParser
;
import
org.h2.value.Value
;
...
...
@@ -1572,7 +1574,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"11/12/1979"
,
stat
,
"SELECT TO_CHAR(X, 'ds') FROM T"
);
expected
=
String
.
format
(
"%1$ta"
,
timestamp1979
);
assertResult
(
expected
.
toUpperCase
(),
stat
,
"SELECT TO_CHAR(X, 'DY') FROM T"
);
assertResult
(
expected
,
stat
,
"SELECT TO_CHAR(X, 'Dy') FROM T"
);
assertResult
(
Capitalization
.
CAPITALIZE
.
apply
(
expected
)
,
stat
,
"SELECT TO_CHAR(X, 'Dy') FROM T"
);
assertResult
(
expected
.
toLowerCase
(),
stat
,
"SELECT TO_CHAR(X, 'dy') FROM T"
);
assertResult
(
expected
.
toLowerCase
(),
stat
,
"SELECT TO_CHAR(X, 'dY') FROM T"
);
assertResult
(
"08:12:34.560000"
,
stat
,
...
...
@@ -1627,11 +1629,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
expected
=
(
expected
+
" "
).
substring
(
0
,
9
);
assertResult
(
expected
.
toUpperCase
(),
stat
,
"SELECT TO_CHAR(X, 'MONTH') FROM T"
);
assertResult
(
expected
,
stat
,
assertResult
(
Capitalization
.
CAPITALIZE
.
apply
(
expected
)
,
stat
,
"SELECT TO_CHAR(X, 'Month') FROM T"
);
assertResult
(
expected
.
toLowerCase
(),
stat
,
"SELECT TO_CHAR(X, 'month') FROM T"
);
assertResult
(
expected
.
trim
(
),
stat
,
assertResult
(
Capitalization
.
CAPITALIZE
.
apply
(
expected
.
trim
()
),
stat
,
"SELECT TO_CHAR(X, 'fmMonth') FROM T"
);
assertResult
(
"4"
,
stat
,
"SELECT TO_CHAR(X, 'Q') FROM T"
);
assertResult
(
"XI"
,
stat
,
"SELECT TO_CHAR(X, 'RM') FROM T"
);
...
...
@@ -1641,7 +1643,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"1979"
,
stat
,
"SELECT TO_CHAR(X, 'RRRR') FROM T"
);
assertResult
(
"34"
,
stat
,
"SELECT TO_CHAR(X, 'SS') FROM T"
);
assertResult
(
"29554"
,
stat
,
"SELECT TO_CHAR(X, 'SSSSS') FROM T"
);
assertResult
(
"8:12:34 AM"
,
stat
,
"SELECT TO_CHAR(X, 'TS') FROM T"
);
expected
=
new
SimpleDateFormat
(
"h:mm:ss aa"
).
format
(
timestamp1979
);
if
(
Locale
.
getDefault
().
getLanguage
().
equals
(
Locale
.
ENGLISH
.
getLanguage
()))
{
assertEquals
(
"8:12:34 AM"
,
expected
);
}
assertResult
(
expected
,
stat
,
"SELECT TO_CHAR(X, 'TS') FROM T"
);
assertResult
(
tzLongName
,
stat
,
"SELECT TO_CHAR(X, 'TZR') FROM T"
);
assertResult
(
tzShortName
,
stat
,
"SELECT TO_CHAR(X, 'TZD') FROM T"
);
expected
=
String
.
format
(
"%f"
,
1.1
).
substring
(
1
,
2
);
...
...
@@ -1928,14 +1934,17 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"0.001"
,
stat
,
"select to_char(0.001, 'FM0.099') from dual;"
);
assertResult
(
"0.001"
,
stat
,
"select to_char(0.0012, 'FM0.099') from dual;"
);
assertResult
(
"0.002"
,
stat
,
"select to_char(0.0019, 'FM0.099') from dual;"
);
assertResult
(
"0.0"
,
stat
,
"select to_char(0, 'FM0D099') from dual;"
);
assertResult
(
"0.00"
,
stat
,
"select to_char(0., 'FM0D009') from dual;"
);
assertResult
(
"0."
,
stat
,
"select to_char(0, 'FM0D9') from dual;"
);
assertResult
(
"0.0"
,
stat
,
"select to_char(0.0, 'FM0D099') from dual;"
);
assertResult
(
"0.00"
,
stat
,
"select to_char(0.00, 'FM0D009') from dual;"
);
assertResult
(
"0.00"
,
stat
,
"select to_char(0, 'FM0D009') from dual;"
);
assertResult
(
"0.0"
,
stat
,
"select to_char(0, 'FM0D09') from dual;"
);
assertResult
(
"0.0"
,
stat
,
"select to_char(0, 'FM0D0') from dual;"
);
final
char
decimalSeparator
=
DecimalFormatSymbols
.
getInstance
().
getDecimalSeparator
();
final
String
oneDecimal
=
"0"
+
decimalSeparator
+
"0"
;
final
String
twoDecimals
=
"0"
+
decimalSeparator
+
"00"
;
assertResult
(
oneDecimal
,
stat
,
"select to_char(0, 'FM0D099') from dual;"
);
assertResult
(
twoDecimals
,
stat
,
"select to_char(0., 'FM0D009') from dual;"
);
assertResult
(
"0"
+
decimalSeparator
,
stat
,
"select to_char(0, 'FM0D9') from dual;"
);
assertResult
(
oneDecimal
,
stat
,
"select to_char(0.0, 'FM0D099') from dual;"
);
assertResult
(
twoDecimals
,
stat
,
"select to_char(0.00, 'FM0D009') from dual;"
);
assertResult
(
twoDecimals
,
stat
,
"select to_char(0, 'FM0D009') from dual;"
);
assertResult
(
oneDecimal
,
stat
,
"select to_char(0, 'FM0D09') from dual;"
);
assertResult
(
oneDecimal
,
stat
,
"select to_char(0, 'FM0D0') from dual;"
);
conn
.
close
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论