Skip to content

Commit

Permalink
refactor: remove test.rs file and move tests to a module files
Browse files Browse the repository at this point in the history
  • Loading branch information
Syaw0 committed Nov 2, 2024
1 parent 17609c6 commit 68b701e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
29 changes: 27 additions & 2 deletions src/ansi_escape_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,36 @@ pub struct ANSIEscapeCode {
parameter: String,
}
impl ANSIEscapeCode {
pub fn new(parameter: String) -> Self {
ANSIEscapeCode { parameter }
pub fn new(parameter: &str) -> Self {
ANSIEscapeCode { parameter: parameter.to_string() }
}

pub fn code(&self) -> String {
format!("\\x1b[{}m", self.parameter)
}
}

// =======================================================================

#[cfg(test)]
mod ansi_escape_code_test {
use super::*;

#[test]
fn create_simple_ansi_code() {
let p = ANSIEscapeCode::new("33");
assert_eq!(p.code(), "\\x1b[33m")
}

#[test]
fn create_reset_ansi_code() {
let reset_ansi = ANSIEscapeCode::new("0");
assert_eq!("\\x1b[0m", reset_ansi.code());
}

#[test]
fn create_bright_cyan_ansi_code() {
let reset_ansi = ANSIEscapeCode::new("96");
assert_eq!("\\x1b[96m", reset_ansi.code());
}
}
23 changes: 0 additions & 23 deletions src/test.rs

This file was deleted.

0 comments on commit 68b701e

Please sign in to comment.