summaryrefslogtreecommitdiffstats
path: root/third_party/rust/cstr/tests/pass/const.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/cstr/tests/pass/const.rs')
-rw-r--r--third_party/rust/cstr/tests/pass/const.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/third_party/rust/cstr/tests/pass/const.rs b/third_party/rust/cstr/tests/pass/const.rs
new file mode 100644
index 0000000000..ae8647b954
--- /dev/null
+++ b/third_party/rust/cstr/tests/pass/const.rs
@@ -0,0 +1,10 @@
+use cstr::cstr;
+use std::ffi::CStr;
+
+const FOO: &CStr = cstr!(b"foo\xffbar");
+static BAR: &CStr = cstr!("bar");
+
+fn main() {
+ assert_eq!(FOO, CStr::from_bytes_with_nul(b"foo\xffbar\0").unwrap());
+ assert_eq!(BAR, CStr::from_bytes_with_nul(b"bar\0").unwrap());
+}