mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
test_sort: Add one more test checking arbitrary precision handling
This commit is contained in:
parent
ee1a6d2e66
commit
8c98f433bf
1 changed files with 40 additions and 0 deletions
|
@ -1527,3 +1527,43 @@ fn test_g_misc() {
|
|||
.succeeds()
|
||||
.stdout_is(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Test numbers with a large number of digits, where only the last digit is different.
|
||||
// We use scientific notation to make sure string sorting does not correctly order them.
|
||||
fn test_g_arbitrary() {
|
||||
let input = [
|
||||
// GNU coreutils doesn't handle those correctly as they don't fit exactly in long double
|
||||
"3",
|
||||
"3.000000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0.3000000000000000000000000000000000000000000000000000000000000000002e1",
|
||||
"0.03000000000000000000000000000000000000000000000000000000000000000003e2",
|
||||
"0.003000000000000000000000000000000000000000000000000000000000000000001e3",
|
||||
// GNU coreutils does handle those correctly though
|
||||
"10",
|
||||
"10.000000000000004",
|
||||
"1.0000000000000002e1",
|
||||
"0.10000000000000003e2",
|
||||
"0.010000000000000001e3",
|
||||
]
|
||||
.join("\n");
|
||||
let output = [
|
||||
"3",
|
||||
"0.003000000000000000000000000000000000000000000000000000000000000000001e3",
|
||||
"0.3000000000000000000000000000000000000000000000000000000000000000002e1",
|
||||
"0.03000000000000000000000000000000000000000000000000000000000000000003e2",
|
||||
"3.000000000000000000000000000000000000000000000000000000000000000004",
|
||||
"10",
|
||||
"0.010000000000000001e3",
|
||||
"1.0000000000000002e1",
|
||||
"0.10000000000000003e2",
|
||||
"10.000000000000004",
|
||||
]
|
||||
.join("\n")
|
||||
+ "\n";
|
||||
new_ucmd!()
|
||||
.args(&["-g"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_is(output);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue