test configurations
This commit is contained in:
37
src/lib.rs
37
src/lib.rs
@@ -72,13 +72,6 @@ fn from_base36(str: &str) -> u64 {
|
||||
u64::from_str_radix(str, 36).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_base36() {
|
||||
assert_eq!(from_base36("0"), 0);
|
||||
assert_eq!(from_base36("0z"), 35);
|
||||
assert_eq!(from_base36("11"), 37);
|
||||
}
|
||||
|
||||
/// this doesn't work inside ToBase36 for some reason
|
||||
fn to_base36(int: u64) -> String {
|
||||
format!("{}", radix_36(int))
|
||||
@@ -94,11 +87,6 @@ impl ToBase36 for u64 {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_to_base36() {
|
||||
assert_eq!((37 as u64).to_base36(), "11");
|
||||
}
|
||||
|
||||
/// e.g. `\nNAME DLG_0`
|
||||
fn optional_data_line<T: Display>(label: &str, item: Option<T>) -> String {
|
||||
if item.is_some() {
|
||||
@@ -108,8 +96,25 @@ fn optional_data_line<T: Display>(label: &str, item: Option<T>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_optional_data_line() {
|
||||
let output = optional_data_line("NAME", mock::item().name);
|
||||
assert_eq!(output, "\nNAME door".to_string());
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{from_base36, ToBase36, optional_data_line, mock};
|
||||
|
||||
#[test]
|
||||
fn test_from_base36() {
|
||||
assert_eq!(from_base36("0"), 0);
|
||||
assert_eq!(from_base36("0z"), 35);
|
||||
assert_eq!(from_base36("11"), 37);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_to_base36() {
|
||||
assert_eq!((37 as u64).to_base36(), "11");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_optional_data_line() {
|
||||
let output = optional_data_line("NAME", mock::item().name);
|
||||
assert_eq!(output, "\nNAME door".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user