Skip to content

Commit 95c686f

Browse files
MDEV-37911 : Add Missing Test cases for abs() Function
Adding test cases for abs() .
1 parent 3df4c52 commit 95c686f

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

mysql-test/main/mysqltest_string_functions.result

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22
# Test for MDEV-36108: Variable substitutions in mysqltest
33
# ----------------------------------------------------------------------------
44
# ----------------------------------------------------------------------------
5+
# Test absolute value function
6+
# ----------------------------------------------------------------------------
7+
# Basic abs() function tests
8+
abs(10) -> 10;
9+
abs(-10) -> 10;
10+
abs(0) -> 0;
11+
abs(123456789) -> 123456789;
12+
abs(-987654321) -> 987654321;
13+
abs(NULL) -> ;
14+
abs(5 - 10) -> ;
15+
abs(10 - 5) -> ;
16+
abs(-(-25)) -> ;
17+
abs(-2147483648) -> ;
18+
abs(2147483647) -> ;
19+
abs(1 == 1) -> ;
20+
abs(1 == 0) -> ;
21+
abs(-((5 * -3) + (2 - 8))) -> ; # 9
22+
abs(((10 - 25) * (3 + 2))) -> ; # 75
23+
abs(((2 - 6) * (-4 + 1))) -> ; # 12
24+
abs((((-5 * 6) + 10) - (8 * -2))) -> ; # 8
25+
abs(((((3 - 9) * 2) + 4) - 1)) -> ; # 9
26+
abs(((-100 + 50) * (2 - 5))) -> ; # 150
27+
abs(((-3 * (2 + 4)) + (18 / 3))) -> ; # 12
28+
abs(((((10 - 5) * -3) + 4) * -2)) -> ; # 22
29+
abs((((-2 * -2) - (5 * 3)) + 20)) -> ; # 9
30+
# ----------------------------------------------------------------------------
531
# Test conversion functions (conv, bin, oct, hex)
632
# ----------------------------------------------------------------------------
733
# Basic conv() function tests

mysql-test/main/mysqltest_string_functions.test

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,79 @@
44

55
--source include/not_embedded.inc
66

7+
--echo # ----------------------------------------------------------------------------
8+
--echo # Test absolute value function
9+
--echo # ----------------------------------------------------------------------------
10+
11+
--echo # Basic abs() function tests
12+
13+
let $a1 = $(abs(10));
14+
-- echo abs(10) -> $a1;
15+
16+
let $a2 = $(abs(-10));
17+
-- echo abs(-10) -> $a2;
18+
19+
let $a3 = $(abs(0));
20+
-- echo abs(0) -> $a3;
21+
22+
let $a4 = $(abs(123456789));
23+
-- echo abs(123456789) -> $a4;
24+
25+
let $a5 = $(abs(-987654321));
26+
-- echo abs(-987654321) -> $a5;
27+
28+
let $a6 = $(abs(NULL));
29+
-- echo abs(NULL) -> $a10;
30+
31+
let $a7 = $(abs(5 - 10));
32+
-- echo abs(5 - 10) -> $a11;
33+
34+
let $a8 = $(abs(10 - 5));
35+
-- echo abs(10 - 5) -> $a12;
36+
37+
let $a9 = $(abs(-(-25)));
38+
-- echo abs(-(-25)) -> $a13;
39+
40+
let $a10 = $(abs(-2147483648));
41+
-- echo abs(-2147483648) -> $b3;
42+
43+
let $a11 = $(abs(2147483647));
44+
-- echo abs(2147483647) -> $b4;
45+
46+
let $a12 = $(abs(1 == 1));
47+
-- echo abs(1 == 1) -> $b10;
48+
49+
let $a13 = $(abs(1 == 0));
50+
-- echo abs(1 == 0) -> $b11;
51+
52+
let $a14 = $(abs(-((5 * -3) + (2 - 8))));
53+
-- echo abs(-((5 * -3) + (2 - 8))) -> $c1; # 9
54+
55+
let $a15 = $(abs(((10 - 25) * (3 + 2))));
56+
-- echo abs(((10 - 25) * (3 + 2))) -> $c2; # 75
57+
58+
let $a16 = $(abs(((2 - 6) * (-4 + 1))));
59+
-- echo abs(((2 - 6) * (-4 + 1))) -> $c3; # 12
60+
61+
let $a17 = $(abs((((-5 * 6) + 10) - (8 * -2))));
62+
-- echo abs((((-5 * 6) + 10) - (8 * -2))) -> $c4; # 8
63+
64+
let $a18 = $(abs(((((3 - 9) * 2) + 4) - 1)));
65+
-- echo abs(((((3 - 9) * 2) + 4) - 1)) -> $c5; # 9
66+
67+
let $a19 = $(abs(((-100 + 50) * (2 - 5))));
68+
-- echo abs(((-100 + 50) * (2 - 5))) -> $c6; # 150
69+
70+
let $a20 = $(abs(((-3 * (2 + 4)) + (18 / 3))));
71+
-- echo abs(((-3 * (2 + 4)) + (18 / 3))) -> $c7; # 12
72+
73+
let $a21 = $(abs(((((10 - 5) * -3) + 4) * -2)));
74+
-- echo abs(((((10 - 5) * -3) + 4) * -2)) -> $c8; # 22
75+
76+
let $a22 = $(abs((((-2 * -2) - (5 * 3)) + 20)));
77+
-- echo abs((((-2 * -2) - (5 * 3)) + 20)) -> $c9; # 9
78+
79+
780
--echo # ----------------------------------------------------------------------------
881
--echo # Test conversion functions (conv, bin, oct, hex)
982
--echo # ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)