mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
test_sort: Add one more test checking arbitrary precision handling
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user