Skip to content

Commit 8b85462

Browse files
committed
[test] Tests for numeric operations in eXist-db
1 parent 6f4c2a5 commit 8b85462

13 files changed

+884
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* eXist-db Open Source Native XML Database
3+
* Copyright (C) 2001 The eXist-db Authors
4+
*
5+
6+
* http://www.exist-db.org
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public
19+
* License along with this library; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
*/
22+
package xquery.numericOp;
23+
24+
import org.exist.test.runner.XSuite;
25+
import org.junit.runner.RunWith;
26+
27+
@RunWith(XSuite.class)
28+
@XSuite.XSuiteFiles({
29+
"src/test/xquery/numericOp"
30+
})
31+
public class NumericOpTests {
32+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
xquery version "3.1";
23+
24+
(:~
25+
: Tests for the op:numeric-add operator.
26+
:)
27+
module namespace ona = "http://exist-db.org/test/op-numeric-add";
28+
29+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
30+
31+
declare
32+
%test:args("1.13", "1.13")
33+
%test:assertEquals("2.2599999952316283")
34+
function ona:numeric-add-float-double($f as xs:float, $d as xs:double) {
35+
$f + $d
36+
};
37+
38+
declare
39+
%test:args("1.13", "1.13")
40+
%test:assertEquals("2.2599999952316283")
41+
function ona:numeric-add-double-float($d as xs:double, $f as xs:float) {
42+
$d + $f
43+
};
44+
45+
declare
46+
%test:args("1.13", "1.13")
47+
%test:assertEquals("2.26")
48+
function ona:numeric-add-double-decimal($d as xs:double, $dec as xs:decimal) {
49+
$d + $dec
50+
};
51+
52+
declare
53+
%test:args("1.13", "1.13")
54+
%test:assertEquals("2.26")
55+
function ona:numeric-add-decimal-double($dec as xs:decimal, $d as xs:double) {
56+
$dec + $d
57+
};
58+
59+
declare
60+
%test:args("1.13", "1.13")
61+
%test:assertEquals("2.26")
62+
function ona:numeric-add-decimal-float($dec as xs:decimal, $f as xs:float) {
63+
$dec + $f
64+
};
65+
66+
declare
67+
%test:args("1.13", "1.13")
68+
%test:assertEquals("2.26")
69+
function ona:numeric-add-float-decimal($f as xs:float, $dec as xs:decimal) {
70+
$f + $dec
71+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
xquery version "3.1";
23+
24+
(:~
25+
: Tests for the op:numeric-divide operator.
26+
:)
27+
module namespace ond = "http://exist-db.org/test/op-numeric-divide";
28+
29+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
30+
31+
declare
32+
%test:args("1.13", "1.13")
33+
%test:assertEquals("0.9999999957802023")
34+
function ond:numeric-divide-float-double($f as xs:float, $d as xs:double) {
35+
$f div $d
36+
};
37+
38+
declare
39+
%test:args("1.13", "1.13")
40+
%test:assertEquals("1.0000000042197978")
41+
function ond:numeric-divide-double-float($d as xs:double, $f as xs:float) {
42+
$d div $f
43+
};
44+
45+
declare
46+
%test:args("1.13", "1.13")
47+
%test:assertEquals("1")
48+
function ond:numeric-divide-double-decimal($d as xs:double, $dec as xs:decimal) {
49+
$d div $dec
50+
};
51+
52+
declare
53+
%test:args("1.13", "1.13")
54+
%test:assertEquals("1")
55+
function ond:numeric-divide-decimal-double($dec as xs:decimal, $d as xs:double) {
56+
$dec div $d
57+
};
58+
59+
declare
60+
%test:args("1.13", "1.13")
61+
%test:assertEquals("1")
62+
function ond:numeric-divide-decimal-float($dec as xs:decimal, $f as xs:float) {
63+
$dec div $f
64+
};
65+
66+
declare
67+
%test:args("1.13", "1.13")
68+
%test:assertEquals("1")
69+
function ond:numeric-divide-float-decimal($f as xs:float, $dec as xs:decimal) {
70+
$f div $dec
71+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
xquery version "3.1";
23+
24+
(:~
25+
: Tests for the op:numeric-equal operator.
26+
:)
27+
module namespace one = "http://exist-db.org/test/op-numeric-equal";
28+
29+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
30+
31+
declare
32+
%test:args("1.13", "1.13")
33+
%test:assertFalse
34+
function one:numeric-equal-float-double($f as xs:float, $d as xs:double) {
35+
$f eq $d
36+
};
37+
38+
declare
39+
%test:args("1.13", "1.13")
40+
%test:assertFalse
41+
function one:numeric-equal-double-float($d as xs:double, $f as xs:float) {
42+
$d eq $f
43+
};
44+
45+
declare
46+
%test:args("1.13", "1.13")
47+
%test:assertTrue
48+
function one:numeric-equal-double-decimal($d as xs:double, $dec as xs:decimal) {
49+
$d eq $dec
50+
};
51+
52+
declare
53+
%test:args("1.13", "1.13")
54+
%test:assertTrue
55+
function one:numeric-equal-decimal-double($dec as xs:decimal, $d as xs:double) {
56+
$dec eq $d
57+
};
58+
59+
declare
60+
%test:args("1.13", "1.13")
61+
%test:assertTrue
62+
function one:numeric-equal-decimal-float($dec as xs:decimal, $f as xs:float) {
63+
$dec eq $f
64+
};
65+
66+
declare
67+
%test:args("1.13", "1.13")
68+
%test:assertTrue
69+
function one:numeric-equal-float-decimal($f as xs:float, $dec as xs:decimal) {
70+
$f eq $dec
71+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
xquery version "3.1";
23+
24+
(:~
25+
: Tests for the "ge" operator.
26+
:)
27+
module namespace onge = "http://exist-db.org/test/op-numeric-greater-than-or-equal";
28+
29+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
30+
31+
declare
32+
%test:args("1.13", "1.13")
33+
%test:assertFalse
34+
function onge:numeric-greater-than-or-equal-float-double($f as xs:float, $d as xs:double) {
35+
$f ge $d
36+
};
37+
38+
declare
39+
%test:args("1.13", "1.13")
40+
%test:assertTrue
41+
function onge:numeric-greater-than-or-equal-double-float($d as xs:double, $f as xs:float) {
42+
$d ge $f
43+
};
44+
45+
declare
46+
%test:args("1.13", "1.13")
47+
%test:assertTrue
48+
function onge:numeric-greater-than-or-equal-double-decimal($d as xs:double, $dec as xs:decimal) {
49+
$d ge $dec
50+
};
51+
52+
declare
53+
%test:args("1.13", "1.13")
54+
%test:assertTrue
55+
function onge:numeric-greater-than-or-equal-decimal-double($dec as xs:decimal, $d as xs:double) {
56+
$dec ge $d
57+
};
58+
59+
declare
60+
%test:args("1.13", "1.13")
61+
%test:assertTrue
62+
function onge:numeric-greater-than-or-equal-decimal-float($dec as xs:decimal, $f as xs:float) {
63+
$dec ge $f
64+
};
65+
66+
declare
67+
%test:args("1.13", "1.13")
68+
%test:assertTrue
69+
function onge:numeric-greater-than-or-equal-float-decimal($f as xs:float, $dec as xs:decimal) {
70+
$f ge $dec
71+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
xquery version "3.1";
23+
24+
(:~
25+
: Tests for the op:numeric-greater-than operator.
26+
:)
27+
module namespace ongt = "http://exist-db.org/test/op-numeric-greater-than";
28+
29+
declare namespace test = "http://exist-db.org/xquery/xqsuite";
30+
31+
declare
32+
%test:args("1.13", "1.13")
33+
%test:assertFalse
34+
function ongt:numeric-greater-than-float-double($f as xs:float, $d as xs:double) {
35+
$f gt $d
36+
};
37+
38+
declare
39+
%test:args("1.13", "1.13")
40+
%test:assertTrue
41+
function ongt:numeric-greater-than-double-float($d as xs:double, $f as xs:float) {
42+
$d gt $f
43+
};
44+
45+
declare
46+
%test:args("1.13", "1.13")
47+
%test:assertFalse
48+
function ongt:numeric-greater-than-double-decimal($d as xs:double, $dec as xs:decimal) {
49+
$d gt $dec
50+
};
51+
52+
declare
53+
%test:args("1.13", "1.13")
54+
%test:assertFalse
55+
function ongt:numeric-greater-than-decimal-double($dec as xs:decimal, $d as xs:double) {
56+
$dec gt $d
57+
};
58+
59+
declare
60+
%test:args("1.13", "1.13")
61+
%test:assertFalse
62+
function ongt:numeric-greater-than-decimal-float($dec as xs:decimal, $f as xs:float) {
63+
$dec gt $f
64+
};
65+
66+
declare
67+
%test:args("1.13", "1.13")
68+
%test:assertFalse
69+
function ongt:numeric-greater-than-float-decimal($f as xs:float, $dec as xs:decimal) {
70+
$f gt $dec
71+
};

0 commit comments

Comments
 (0)