#![cfg(all(feature = "consoleapi", feature="processenv"))] use fenestroj::*; #[test] #[ignore] // doesn't work in CI, no console. fn test_write_console() { let std_out_handle = get_std_handle(StdHandle::Output).unwrap(); // An empty slice prints nothing assert_eq!(write_console(std_out_handle, &[]), Ok(0)); let a = "a"; let a_w = wide(a); assert_eq!(a.len(), 1); assert_eq!(a_w.len(), 1); assert_eq!(write_console(std_out_handle, &a_w), Ok(1)); let a = "ĉ"; let a_w = wide(a); assert_eq!(a.len(), 2); assert_eq!(a_w.len(), 1); assert_eq!(write_console(std_out_handle, &a_w), Ok(1)); let a = "𐐷"; let a_w = wide(a); assert_eq!(a.len(), 4); assert_eq!(a_w.len(), 2); assert_eq!(write_console(std_out_handle, &a_w), Ok(2)); // unmatched start or end gives weirdness but counts as "success" assert_eq!(write_console(std_out_handle, &[0xD801]), Ok(1)); assert_eq!(write_console(std_out_handle, &[0xDC37]), Ok(1)); }