Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions cpp-linter/src/clang_tools/clang_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use crate::{
common_fs::{FileObj, get_line_count_from_offset},
};

#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Default)]
pub struct FormatAdvice {
/// A list of [`Replacement`]s that clang-tidy wants to make.
#[serde(rename(deserialize = "replacement"))]
#[serde(rename(deserialize = "replacement"), default)]
pub replacements: Vec<Replacement>,

pub patched: Option<Vec<u8>>,
Expand Down Expand Up @@ -196,6 +196,22 @@ mod tests {
assert!(result.is_err());
}

#[test]
fn parse_xml_no_replacements() {
let xml_raw = r#"<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
</replacements>"#
.as_bytes()
.to_vec();
let expected = FormatAdvice {
replacements: vec![],
patched: None,
};
let xml = String::from_utf8(xml_raw).unwrap();
let document = quick_xml::de::from_str::<FormatAdvice>(&xml).unwrap();
assert_eq!(expected, document);
}

#[test]
fn parse_xml() {
let xml_raw = r#"<?xml version='1.0'?>
Expand Down
Loading