From 14bc998df9f15042342ac8e649a4adadf17a65f8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 15 Aug 2019 10:32:52 +0300 Subject: [PATCH] Add regression test for include_str! normalization --- src/test/ui/.gitattributes | 1 + src/test/ui/include-macros/data.bin | 2 ++ src/test/ui/include-macros/normalization.rs | 12 ++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 src/test/ui/include-macros/data.bin create mode 100644 src/test/ui/include-macros/normalization.rs diff --git a/src/test/ui/.gitattributes b/src/test/ui/.gitattributes index b62ade73aa9..489dc8ad111 100644 --- a/src/test/ui/.gitattributes +++ b/src/test/ui/.gitattributes @@ -1,2 +1,3 @@ lexer-crlf-line-endings-string-literal-doc-comment.rs -text trailing-carriage-return-in-string.rs -text +*.bin -text diff --git a/src/test/ui/include-macros/data.bin b/src/test/ui/include-macros/data.bin new file mode 100644 index 00000000000..ce4e0b8311a --- /dev/null +++ b/src/test/ui/include-macros/data.bin @@ -0,0 +1,2 @@ +This file starts with BOM. +Lines are separated by \r\n. diff --git a/src/test/ui/include-macros/normalization.rs b/src/test/ui/include-macros/normalization.rs new file mode 100644 index 00000000000..889f08e606e --- /dev/null +++ b/src/test/ui/include-macros/normalization.rs @@ -0,0 +1,12 @@ +// run-pass + +fn main() { + assert_eq!( + &include_bytes!("data.bin")[..], + &b"\xEF\xBB\xBFThis file starts with BOM.\r\nLines are separated by \\r\\n.\r\n"[..], + ); + assert_eq!( + include_str!("data.bin"), + "\u{FEFF}This file starts with BOM.\r\nLines are separated by \\r\\n.\r\n", + ); +}