1use super::*;
4
5#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9pub struct UTF8;
10impl Format for UTF8 {
11 fn escape(f: &mut Formatter, s: &str) -> Result<(), Error> {
12 f.write_str(s)
13 }
14 fn mime() -> mime::Mime {
15 return mime::TEXT_PLAIN_UTF_8;
16 }
17 fn this_format() -> Self {
18 UTF8
19 }
20}
21
22display_integers_as!(UTF8);
23display_floats_as!(UTF8, "e", "", 1, None);
24
25#[test]
26fn escaping() {
27 assert_eq!(&format_as!(UTF8, ("&")).into_string(), "&");
28}
29#[test]
30fn floats() {
31 assert_eq!(&format_as!(UTF8, 3.0).into_string(), "3");
32 assert_eq!(&format_as!(UTF8, 3e5).into_string(), "3e5");
33 assert_eq!(&format_as!(UTF8, 3e4).into_string(), "3e4");
34 assert_eq!(&format_as!(UTF8, 3e3).into_string(), "3e3");
35 assert_eq!(&format_as!(UTF8, 3e2).into_string(), "300");
36}