From 42e132f7e778718de6f82a2f9fda36de3da2b1b2 Mon Sep 17 00:00:00 2001 From: Kamran Bhatti Date: Sun, 7 Apr 2024 18:46:34 +0100 Subject: [PATCH] Subject: add test for utils --- src/utils.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 1847bff..3bd054e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,20 @@ pub fn is_newline_char(byte: u8) -> bool { byte == b'\n' } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_newline_char() { + // Test newline character + assert_eq!(is_newline_char(b'\n'), true); + // Test non-newline characters + assert_eq!(is_newline_char(b'a'), false); + assert_eq!(is_newline_char(b' '), false); + assert_eq!(is_newline_char(b'\t'), false); + // Test other newline characters like carriage return + assert_eq!(is_newline_char(b'\r'), false); + } +}