Unverified 提交 fde86985 authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #726 from katzyn/tests

Fixes in tests
......@@ -1498,6 +1498,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult("1979-11-12 08:12:34.56", stat, "SELECT X FROM T");
assertResult("-100-01-15 14:04:02.12", stat, "SELECT X FROM U");
String expected = String.format("%tb", timestamp1979).toUpperCase();
expected = stripTrailingPeriod(expected);
assertResult("12-" + expected + "-79 08.12.34.560000 AM", stat,
"SELECT TO_CHAR(X) FROM T");
assertResult("- / , . ; : text - /", stat,
......@@ -1618,6 +1619,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult("11", stat, "SELECT TO_CHAR(X, 'mM') FROM T");
assertResult("11", stat, "SELECT TO_CHAR(X, 'mm') FROM T");
expected = String.format("%1$tb", timestamp1979);
expected = stripTrailingPeriod(expected);
expected = expected.substring(0, 1).toUpperCase() + expected.substring(1);
assertResult(expected.toUpperCase(), stat,
"SELECT TO_CHAR(X, 'MON') FROM T");
......@@ -1672,6 +1674,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn.close();
}
String stripTrailingPeriod(String expected) {
// CLDR provider appends period on some locales
int l = expected.length() - 1;
if (expected.charAt(l) == '.')
expected = expected.substring(0, l);
return expected;
}
private void testIfNull() throws SQLException {
deleteDb("functions");
Connection conn = getConnection("functions");
......
......@@ -9,11 +9,12 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select degrees(null) vn, degrees(1) v1, degrees(1.1) v2, degrees(-1.1) v3, degrees(1.9) v4, degrees(-1.9) v5 from test;
-- Truncate least significant digits because implementations returns slightly
-- different results depending on Java version
select degrees(null) vn, truncate(degrees(1), 10) v1, truncate(degrees(1.1), 10) v2,
truncate(degrees(-1.1), 10) v3, truncate(degrees(1.9), 10) v4,
truncate(degrees(-1.9), 10) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- ----------------- ----------------- ------------------ ------------------ -------------------
> null 57.29577951308232 63.02535746439057 -63.02535746439057 108.86198107485642 -108.86198107485642
> ---- ------------ ------------- -------------- -------------- ---------------
> null 57.295779513 63.0253574643 -63.0253574643 108.8619810748 -108.8619810748
> rows: 1
......@@ -9,11 +9,12 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
select radians(null) vn, radians(1) v1, radians(1.1) v2, radians(-1.1) v3, radians(1.9) v4, radians(-1.9) v5 from test;
-- Truncate least significant digits because implementations returns slightly
-- different results depending on Java version
select radians(null) vn, truncate(radians(1), 10) v1, truncate(radians(1.1), 10) v2,
truncate(radians(-1.1), 10) v3, truncate(radians(1.9), 10) v4,
truncate(radians(-1.9), 10) v5 from test;
> VN V1 V2 V3 V4 V5
> ---- -------------------- -------------------- --------------------- ------------------- --------------------
> null 0.017453292519943295 0.019198621771937624 -0.019198621771937624 0.03316125578789226 -0.03316125578789226
> ---- ------------ ------------ ------------- ------------ -------------
> null 0.0174532925 0.0191986217 -0.0191986217 0.0331612557 -0.0331612557
> rows: 1
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论