2018-09-14 12:20:28 +02:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(dead_code)]
|
2024-04-28 15:37:14 -04:00
|
|
|
|
2015-01-20 15:45:07 -08:00
|
|
|
#[derive(Clone, Debug)]
|
2012-01-19 16:10:31 -08:00
|
|
|
enum foo {
|
2024-04-28 18:04:25 -04:00
|
|
|
a(usize),
|
|
|
|
b(String),
|
2012-01-15 21:42:10 -08:00
|
|
|
}
|
|
|
|
|
2015-01-20 15:45:07 -08:00
|
|
|
fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
|
2014-12-20 00:09:35 -08:00
|
|
|
assert_eq!(exp, format!("{:?}", v));
|
2012-01-15 21:42:10 -08:00
|
|
|
}
|
|
|
|
|
2024-04-28 15:37:14 -04:00
|
|
|
#[test]
|
|
|
|
fn log_knows_the_names_of_variants_in_std() {
|
2015-01-20 15:45:07 -08:00
|
|
|
let mut x = Some(foo::a(22));
|
|
|
|
let exp = "Some(a(22))".to_string();
|
2014-12-20 00:09:35 -08:00
|
|
|
let act = format!("{:?}", x);
|
2014-03-18 21:31:40 -07:00
|
|
|
assert_eq!(act, exp);
|
|
|
|
check_log(exp, x);
|
|
|
|
|
|
|
|
x = None;
|
2014-05-25 03:17:19 -07:00
|
|
|
let exp = "None".to_string();
|
2014-12-20 00:09:35 -08:00
|
|
|
let act = format!("{:?}", x);
|
2014-03-18 21:31:40 -07:00
|
|
|
assert_eq!(act, exp);
|
2012-01-15 21:42:10 -08:00
|
|
|
check_log(exp, x);
|
|
|
|
}
|