Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pugixml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SCALE
Code
external
pugixml
Commits
97a515f8
Commit
97a515f8
authored
10 years ago
by
Arseny Kapoulkine
Browse files
Options
Downloads
Patches
Plain Diff
tests: Add more XPath mod tests
parent
e9948b4b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_xpath_operators.cpp
+48
-0
48 additions, 0 deletions
tests/test_xpath_operators.cpp
with
48 additions
and
0 deletions
tests/test_xpath_operators.cpp
+
48
−
0
View file @
97a515f8
...
@@ -481,4 +481,52 @@ TEST(xpath_operators_associativity_arithmetic)
...
@@ -481,4 +481,52 @@ TEST(xpath_operators_associativity_arithmetic)
CHECK_XPATH_NUMBER
(
c
,
STR
(
"1-1+1"
),
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"1-1+1"
),
1
);
}
}
TEST
(
xpath_operators_mod
)
{
// Check that mod operator conforms to Java spec (since this is the only concrete source of information about XPath mod)
xml_node
c
;
// Basic tests from spec
CHECK_XPATH_NUMBER
(
c
,
STR
(
"5 mod 3"
),
2
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"5 mod -3"
),
2
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"-5 mod 3"
),
-
2
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"-5 mod -3"
),
-
2
);
// If either operand is NaN, the result is NaN
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(0 div 0) mod 3"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"3 mod (0 div 0)"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(0 div 0) mod (0 div 0)"
));
// If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(1 div 0) mod 3"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(1 div 0) mod -3"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(-1 div 0) mod 3"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"1 mod 0"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"-1 mod 0"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(1 div 0) mod 0"
));
CHECK_XPATH_NUMBER_NAN
(
c
,
STR
(
"(-1 div 0) mod 0"
));
// If the dividend is finite and the divisor is an infinity, the result equals the dividend
CHECK_XPATH_NUMBER
(
c
,
STR
(
"1 mod (1 div 0)"
),
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"1 mod (-1 div 0)"
),
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"-1 mod (1 div 0)"
),
-
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"0 mod (1 div 0)"
),
0
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"0 mod (-1 div 0)"
),
0
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"100000 mod (1 div 0)"
),
100000
);
// If the dividend is a zero and the divisor is finite, the result equals the dividend.
CHECK_XPATH_NUMBER
(
c
,
STR
(
"0 mod 1000000"
),
0
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"0 mod -1000000"
),
0
);
// In the remaining cases ... the floating-point remainder r from the division of a dividend n by a divisor d
// is defined by the mathematical relation r = n - (d * q) where q is an integer that is negative only if n/d is
// negative and positive only if n/d is positive, and whose magnitude is as large as possible without exceeding the magnitude of the true
// mathematical quotient of n and d.
CHECK_XPATH_NUMBER
(
c
,
STR
(
"9007199254740991 mod 2"
),
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"9007199254740991 mod 3"
),
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"18446744073709551615 mod 2"
),
0
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"18446744073709551615 mod 3"
),
1
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"115792089237316195423570985008687907853269984665640564039457584007913129639935 mod 2"
),
0
);
CHECK_XPATH_NUMBER
(
c
,
STR
(
"115792089237316195423570985008687907853269984665640564039457584007913129639935 mod 3"
),
1
);
}
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment