Skip to content
Snippets Groups Projects
Commit 14836669 authored by Martin Geisler's avatar Martin Geisler
Browse files

PDL: Fix the order of arguments to ‘assert_eq_with_diff’

We now show the unified diff relative to the known-good code. That is,
if we generate a line too much, this like shows up as an added line.
Before it would show up as a deleted line, which seems wrong.

Test: atest pdl_inline_tests
Change-Id: I9ecb24c4f79b65221131adfe0e44db4529a6a478
parent 2ea11bdb
No related branches found
No related tags found
No related merge requests found
......@@ -496,7 +496,7 @@ mod tests {
fn test_generate_preamble() {
let actual_code = generate_preamble(Path::new("some/path/foo.pdl")).unwrap();
let expected_code = include_str!("../test/generated/preamble.rs");
assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
}
#[test]
......@@ -512,7 +512,7 @@ mod tests {
let decl = &grammar.declarations[0];
let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
let expected_code = include_str!("../test/generated/packet_decl_empty.rs");
assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
}
#[test]
......@@ -532,7 +532,7 @@ mod tests {
let decl = &grammar.declarations[0];
let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
let expected_code = include_str!("../test/generated/packet_decl_simple_little_endian.rs");
assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
}
#[test]
......@@ -552,6 +552,6 @@ mod tests {
let decl = &grammar.declarations[0];
let actual_code = generate_decl(&grammar, &packets, &children, decl).unwrap();
let expected_code = include_str!("../test/generated/packet_decl_simple_big_endian.rs");
assert_eq_with_diff(&rustfmt(&actual_code), &rustfmt(expected_code));
assert_eq_with_diff(&rustfmt(expected_code), &rustfmt(&actual_code));
}
}
......@@ -58,7 +58,7 @@ pub fn rustfmt(input: &str) -> String {
String::from_utf8(output.stdout).expect("rustfmt output was not UTF-8")
}
/// Compare two strings using `diff`
/// Find the unified diff between two strings using `diff`.
///
/// # Panics
///
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment