-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(whiskers): support alternative template file encodings
currently supports whatever encodings the encoding_rs_io crate[1] supports there are test cases for UTF-8, UTF-8 with BOM, UTF-16 LE, and UTF-16 BE. [1] https://github.com/BurntSushi/encoding_rs_io
- Loading branch information
1 parent
6148435
commit 81adcb5
Showing
10 changed files
with
149 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! tests that ensure the special encoding fixtures are left untouched | ||
#[test] | ||
fn utf8() { | ||
let bytes = &include_bytes!("fixtures/encodings/utf8.tera")[..3]; | ||
assert_eq!( | ||
bytes, b"---", | ||
"fixtures/encodings/utf8.tera needs to be re-encoded to UTF-8" | ||
); | ||
} | ||
|
||
#[test] | ||
fn utf8bom() { | ||
let bytes = &include_bytes!("fixtures/encodings/utf8bom.tera")[..6]; | ||
assert_eq!( | ||
bytes, b"\xEF\xBB\xBF---", | ||
"fixtures/encodings/utf8bom.tera needs to be re-encoded to UTF-8 with BOM" | ||
); | ||
} | ||
|
||
#[test] | ||
fn utf16be() { | ||
let bytes = &include_bytes!("fixtures/encodings/utf16be.tera")[..2]; | ||
assert_eq!( | ||
bytes, b"\xFE\xFF", | ||
"fixtures/encodings/utf16be.tera needs to be re-encoded to UTF-16 BE" | ||
); | ||
} | ||
|
||
#[test] | ||
fn utf16le() { | ||
let bytes = &include_bytes!("fixtures/encodings/utf16le.tera")[..2]; | ||
assert_eq!( | ||
bytes, b"\xFF\xFE", | ||
"fixtures/encodings/utf16le.tera needs to be re-encoded to UTF-16 LE" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The fixtures in this directory are encoded in various formats to test the encoding detection and decoding capabilities of Whiskers. | ||
|
||
Some text editors like to normalize the encoding of files when saving them. Please be careful not to change them unintentionally. | ||
|
||
There are tests in `tests/encodings.rs` that ensure these fixtures are not unintentionally changed. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
whiskers: | ||
version: "2.0" | ||
--- | ||
it worked! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
whiskers: | ||
version: "2.0" | ||
--- | ||
it worked! |