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