File: from_cp437.rs

package info (click to toggle)
rust-codepage-437 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: makefile: 4
file content (56 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use codepage_437::{CP437_CONTROL, FromCp437};
use self::super::super::super::ALL_CP437;
use self::super::super::ALL_UTF8;


macro_rules! array_test {
	($test_name:ident, $sz:expr) => {
		#[test]
		fn $test_name() {
			let mut buf = [0u8; $sz];
			buf.copy_from_slice(&ALL_CP437[..$sz]);
			assert_eq!(String::from_cp437(buf, &CP437_CONTROL), ALL_UTF8.chars().take($sz).collect::<String>());
		}
	}
}


#[test]
fn vec() {
    assert_eq!(String::from_cp437(ALL_CP437.to_vec(), &CP437_CONTROL), ALL_UTF8);
}


array_test!(array_0, 0);
array_test!(array_1, 1);
array_test!(array_2, 2);
array_test!(array_3, 3);
array_test!(array_4, 4);
array_test!(array_5, 5);
array_test!(array_6, 6);
array_test!(array_7, 7);
array_test!(array_8, 8);
array_test!(array_9, 9);
array_test!(array_10, 10);
array_test!(array_11, 11);
array_test!(array_12, 12);
array_test!(array_13, 13);
array_test!(array_14, 14);
array_test!(array_15, 15);
array_test!(array_16, 16);
array_test!(array_17, 17);
array_test!(array_18, 18);
array_test!(array_19, 19);
array_test!(array_20, 20);
array_test!(array_21, 21);
array_test!(array_22, 22);
array_test!(array_23, 23);
array_test!(array_24, 24);
array_test!(array_25, 25);
array_test!(array_26, 26);
array_test!(array_27, 27);
array_test!(array_28, 28);
array_test!(array_29, 29);
array_test!(array_30, 30);
array_test!(array_31, 31);
array_test!(array_32, 32);