| 1 | use std::ffi::OsString; |
| 2 | |
| 3 | use crate::{swrite, swriteln, SWrite}; |
| 4 | |
| 5 | #[test] |
| 6 | fn test_swrite() { |
| 7 | let mut buf = OsString::new(); |
| 8 | swrite!(buf, "Hello, {}!", "world"); |
| 9 | assert_eq!(buf, "Hello, world!"); |
| 10 | } |
| 11 | |
| 12 | #[test] |
| 13 | fn test_swriteln() { |
| 14 | let mut buf = OsString::new(); |
| 15 | swriteln!(buf, "Hello, {}!", "world"); |
| 16 | assert_eq!(buf, "Hello, world!\n"); |
| 17 | } |
| 18 | |
| 19 | #[test] |
| 20 | fn test_swriteln_appends() { |
| 21 | let mut buf = OsString::new(); |
| 22 | swrite!(buf, "Hello, {}", "world"); |
| 23 | assert_eq!(buf, "Hello, world"); |
| 24 | swriteln!(buf, "!"); |
| 25 | assert_eq!(buf, "Hello, world!\n"); |
| 26 | } |
| 27 | |
| 28 | #[test] |
| 29 | fn test_swriteln_empty() { |
| 30 | let mut buf = OsString::new(); |
| 31 | swriteln!(buf); |
| 32 | assert_eq!(buf, "\n"); |
| 33 | let mut buf = OsString::new(); |
| 34 | swriteln!(buf,); |
| 35 | assert_eq!(buf, "\n"); |
| 36 | } |