Skip to content

Commit

Permalink
Subject: add test for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
k5924 committed Apr 7, 2024
1 parent 39bb1f8 commit 42e132f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 42e132f

Please sign in to comment.