diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /vendor/indoc/tests/test_unindent.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/indoc/tests/test_unindent.rs')
-rw-r--r-- | vendor/indoc/tests/test_unindent.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/indoc/tests/test_unindent.rs b/vendor/indoc/tests/test_unindent.rs new file mode 100644 index 000000000..798907c5e --- /dev/null +++ b/vendor/indoc/tests/test_unindent.rs @@ -0,0 +1,53 @@ +#![allow(clippy::shadow_unrelated)] + +use unindent::{unindent, unindent_bytes, Unindent}; + +#[test] +fn fn_unindent_str() { + let s = " + line one + line two"; + assert_eq!(unindent(s), "line one\nline two"); + + let s = "\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(unindent(s), "line one\nline two"); +} + +#[test] +fn fn_unindent_bytes() { + let b = b" + line one + line two"; + assert_eq!(unindent_bytes(b), b"line one\nline two"); + + let b = b"\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(unindent_bytes(b), b"line one\nline two"); +} + +#[test] +fn trait_unindent_str() { + let s = " + line one + line two"; + assert_eq!(s.unindent(), "line one\nline two"); + + let s = "\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(s.unindent(), "line one\nline two"); +} + +#[test] +fn trait_unindent_bytes() { + let b = b" + line one + line two"; + assert_eq!(b.unindent(), b"line one\nline two"); + + let b = b"\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(b.unindent(), b"line one\nline two"); +} + +#[test] +fn carriage_returns() { + let s = "\r\n\tline one\r\n\tline two"; + assert_eq!(unindent(s), "line one\r\nline two"); +} |