mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
Merge pull request #2981 from jfinkels/split-hex-numbers
split: add support for -x option (hex suffixes)
This commit is contained in:
commit
e1a611374a
5 changed files with 193 additions and 48 deletions
|
@ -2,7 +2,7 @@
|
|||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes asciilowercase fghij klmno pqrst uvwxyz fivelines
|
||||
// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes
|
||||
extern crate rand;
|
||||
extern crate regex;
|
||||
|
||||
|
@ -409,6 +409,28 @@ fn test_numeric_dynamic_suffix_length() {
|
|||
assert_eq!(file_read(&at, "x9000"), "a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hex_dynamic_suffix_length() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
// Split into chunks of one byte each, use hexadecimal digits
|
||||
// instead of letters as file suffixes.
|
||||
//
|
||||
// The input file has (16^2) - 16 + 1 = 241 bytes. This is just
|
||||
// enough to force `split` to dynamically increase the length of
|
||||
// the filename for the very last chunk.
|
||||
//
|
||||
// x00, x01, x02, ..., xed, xee, xef, xf000
|
||||
//
|
||||
ucmd.args(&["-x", "-b", "1", "twohundredfortyonebytes.txt"])
|
||||
.succeeds();
|
||||
for i in 0..240 {
|
||||
let filename = format!("x{:02x}", i);
|
||||
let contents = file_read(&at, &filename);
|
||||
assert_eq!(contents, "a");
|
||||
}
|
||||
assert_eq!(file_read(&at, "xf000"), "a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_suffixes_exhausted() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue