extern crate utf16strings; use utf16strings::*; // "This is a test string." without null-terminator static TEST_STRING_ARR_N: [u16; 22] = [84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 116, 101, 115, 116, 32, 115, 116, 114, 105, 110, 103, 46]; fn assert_eq_test_string_with_null_term(arr: &[u16]) { assert_eq!(arr[22], 0); assert_eq!(arr[0..arr.len() - 1], TEST_STRING_ARR_N); } #[test] fn utf16string_arr_macro_works() { let utf16_arr = utf16string_arr!("This is a test string."); assert_eq_test_string_with_null_term(&utf16_arr); } #[test] fn utf16string_arr_n_macro_works() { let utf16_arr_n = utf16string_arr_n!("This is a test string."); assert_eq!(utf16_arr_n, TEST_STRING_ARR_N); } #[test] fn utf16string_macro_works() { let utf16_string = utf16string!("This is a test string."); let utf16_arr: &[u16]; unsafe { utf16_arr = std::slice::from_raw_parts(utf16_string, 23); } assert_eq_test_string_with_null_term(utf16_arr); } #[test] fn utf16string_n_macro_works() { let utf16_string_n = utf16string_n!("This is a test string."); let utf16_arr_n: &[u16]; unsafe { utf16_arr_n = std::slice::from_raw_parts(utf16_string_n, 22); } assert_eq!(utf16_arr_n, TEST_STRING_ARR_N); }