diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:47 -0500 |
| commit | a06baa56b95674fc626b3c3fd680d6a65357fe60 (patch) | |
| tree | cd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libsyntax_pos/analyze_source_file/tests.rs | |
| parent | 8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff) | |
| download | rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip | |
Format the world
Diffstat (limited to 'src/libsyntax_pos/analyze_source_file/tests.rs')
| -rw-r--r-- | src/libsyntax_pos/analyze_source_file/tests.rs | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/libsyntax_pos/analyze_source_file/tests.rs b/src/libsyntax_pos/analyze_source_file/tests.rs index fd485a7f3a9..cb418a4bdaf 100644 --- a/src/libsyntax_pos/analyze_source_file/tests.rs +++ b/src/libsyntax_pos/analyze_source_file/tests.rs @@ -6,40 +6,31 @@ macro_rules! test { source_file_start_pos: $source_file_start_pos:expr, lines: $lines:expr, multi_byte_chars: $multi_byte_chars:expr, - non_narrow_chars: $non_narrow_chars:expr,) => ( + non_narrow_chars: $non_narrow_chars:expr,) => { + #[test] + fn $test_name() { + let (lines, multi_byte_chars, non_narrow_chars) = + analyze_source_file($text, BytePos($source_file_start_pos)); - #[test] - fn $test_name() { + let expected_lines: Vec<BytePos> = $lines.into_iter().map(|pos| BytePos(pos)).collect(); - let (lines, multi_byte_chars, non_narrow_chars) = - analyze_source_file($text, BytePos($source_file_start_pos)); + assert_eq!(lines, expected_lines); - let expected_lines: Vec<BytePos> = $lines - .into_iter() - .map(|pos| BytePos(pos)) - .collect(); + let expected_mbcs: Vec<MultiByteChar> = $multi_byte_chars + .into_iter() + .map(|(pos, bytes)| MultiByteChar { pos: BytePos(pos), bytes }) + .collect(); - assert_eq!(lines, expected_lines); + assert_eq!(multi_byte_chars, expected_mbcs); - let expected_mbcs: Vec<MultiByteChar> = $multi_byte_chars - .into_iter() - .map(|(pos, bytes)| MultiByteChar { - pos: BytePos(pos), - bytes, - }) - .collect(); + let expected_nncs: Vec<NonNarrowChar> = $non_narrow_chars + .into_iter() + .map(|(pos, width)| NonNarrowChar::new(BytePos(pos), width)) + .collect(); - assert_eq!(multi_byte_chars, expected_mbcs); - - let expected_nncs: Vec<NonNarrowChar> = $non_narrow_chars - .into_iter() - .map(|(pos, width)| { - NonNarrowChar::new(BytePos(pos), width) - }) - .collect(); - - assert_eq!(non_narrow_chars, expected_nncs); - }) + assert_eq!(non_narrow_chars, expected_nncs); + } + }; } test!( |
