Skip to content

Commit

Permalink
Fixed unit tests for to/from_attr()
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi committed Jan 28, 2022
1 parent 34fd711 commit 9bfd6b2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,31 @@ mod tests {

#[test]
fn string_to_attr_val() {
let val: i32 = string_to_attr("123".to_string()).unwrap();
let val: i64 = i64::from_attr("123").unwrap();
assert_eq!(val, 123);

let val = string_to_attr::<bool>("1".to_string()).unwrap();
let val = bool::from_attr("1").unwrap();
assert_eq!(val, true);

let val: bool = string_to_attr(" 0 \n".to_string()).unwrap();
let val: bool = bool::from_attr(" 0 \n").unwrap();
assert_eq!(val, false);

let val: String = string_to_attr("hello".to_string()).unwrap();
let val: String = String::from_attr("hello").unwrap();
assert_eq!(&val, "hello");
}

#[test]
fn attr_val_to_string() {
let s = attr_to_string(123).unwrap();
let s = i64::to_attr(&123).unwrap();
assert_eq!(&s, "123");

let s = attr_to_string(true).unwrap();
let s = bool::to_attr(&true).unwrap();
assert_eq!(&s, "1");

let s = attr_to_string(false).unwrap();
let s = bool::to_attr(&false).unwrap();
assert_eq!(&s, "0");

let s = attr_to_string("hello").unwrap();
let s = String::to_attr(&"hello".to_string()).unwrap();
assert_eq!(&s, "hello");
}
}

0 comments on commit 9bfd6b2

Please sign in to comment.