mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-22 13:20:46 +02:00
More thorough tests for UTF16LE
This commit is contained in:
22
src/input.rs
22
src/input.rs
@@ -371,11 +371,13 @@ fn utf16le() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn utf16le_issue3367() {
|
fn utf16le_issue3367() {
|
||||||
let content = b"\xFF\xFE\x0A\x4E\x00\x4E\x0A\x4F\x00\x52";
|
let content = b"\xFF\xFE\x0A\x4E\x00\x4E\x0A\x4F\x00\x52\x0A\x00\
|
||||||
|
\x6F\x00\x20\x00\x62\x00\x61\x00\x72\x00\x0A\x00\
|
||||||
|
\x68\x00\x65\x00\x6C\x00\x6C\x00\x6F\x00\x20\x00\x77\x00\x6F\x00\x72\x00\x6C\x00\x64\x00";
|
||||||
let mut reader = InputReader::new(&content[..]);
|
let mut reader = InputReader::new(&content[..]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
b"\xFF\xFE\x0A\x4E\x00\x4E\x0A\x4F\x00\x52",
|
b"\xFF\xFE\x0A\x4E\x00\x4E\x0A\x4F\x00\x52\x0A\x00",
|
||||||
&reader.first_line[..]
|
&reader.first_line[..]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -384,7 +386,21 @@ fn utf16le_issue3367() {
|
|||||||
let res = reader.read_line(&mut buffer);
|
let res = reader.read_line(&mut buffer);
|
||||||
assert!(res.is_ok());
|
assert!(res.is_ok());
|
||||||
assert!(res.unwrap());
|
assert!(res.unwrap());
|
||||||
assert_eq!(b"\xFF\xFE\x0A\x4E\x00\x4E\x0A\x4F\x00\x52", &buffer[..]);
|
assert_eq!(b"\xFF\xFE\x0A\x4E\x00\x4E\x0A\x4F\x00\x52\x0A\x00", &buffer[..]);
|
||||||
|
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
|
let res = reader.read_line(&mut buffer);
|
||||||
|
assert!(res.is_ok());
|
||||||
|
assert!(res.unwrap());
|
||||||
|
assert_eq!(b"\x6F\x00\x20\x00\x62\x00\x61\x00\x72\x00\x0A\x00", &buffer[..]);
|
||||||
|
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
|
let res = reader.read_line(&mut buffer);
|
||||||
|
assert!(res.is_ok());
|
||||||
|
assert!(res.unwrap());
|
||||||
|
assert_eq!(b"\x68\x00\x65\x00\x6C\x00\x6C\x00\x6F\x00\x20\x00\x77\x00\x6F\x00\x72\x00\x6C\x00\x64\x00", &buffer[..]);
|
||||||
|
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
|
|
||||||
|
BIN
tests/examples/test_UTF-16BE.txt
vendored
Normal file
BIN
tests/examples/test_UTF-16BE.txt
vendored
Normal file
Binary file not shown.
BIN
tests/examples/test_UTF-16LE-complicated.txt
vendored
Normal file
BIN
tests/examples/test_UTF-16LE-complicated.txt
vendored
Normal file
Binary file not shown.
@@ -1321,6 +1321,26 @@ fn utf16() {
|
|||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
.stdout("hello world\n");
|
.stdout("hello world\n");
|
||||||
|
|
||||||
|
bat()
|
||||||
|
.arg("--plain")
|
||||||
|
.arg("--decorations=always")
|
||||||
|
.arg("test_UTF-16BE.txt")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout("hello world\nthis is a test\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn utf16le() {
|
||||||
|
bat()
|
||||||
|
.arg("--decorations=always")
|
||||||
|
.arg("--style=numbers")
|
||||||
|
.arg("--color=never")
|
||||||
|
.arg("test_UTF-16LE-complicated.txt")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(" 1 上一伊刀\n 2 foo bar\n 3 hello world\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regression test for https://github.com/sharkdp/bat/issues/1922
|
// Regression test for https://github.com/sharkdp/bat/issues/1922
|
||||||
|
Reference in New Issue
Block a user