fix(csaf): the test module goes last
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
1 parent
87a0f5b5c6
commit
5d640e4457
1 file changed
+29
-29
@@ -237,35 +237,6 @@ fn version_in_text(text: &str) -> Option<String> {
|
||||
(version.starts_with(|c: char| c.is_ascii_digit()) && ends_cleanly).then(|| version.to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::version_in_text;
|
||||
|
||||
#[test]
|
||||
fn only_an_update_to_a_numeric_version_names_a_fix() {
|
||||
let read = |t: &str| version_in_text(t);
|
||||
assert_eq!(
|
||||
read("Update to V3.1.5 or later version").as_deref(),
|
||||
Some("3.1.5")
|
||||
);
|
||||
assert_eq!(read("Update to V9 or later version").as_deref(), Some("9"));
|
||||
assert_eq!(
|
||||
read("Update to V4.2.1 or later version, migrate project").as_deref(),
|
||||
Some("4.2.1")
|
||||
);
|
||||
assert_eq!(read("Update to V2.9.8.").as_deref(), Some("2.9.8"));
|
||||
assert_eq!(read("Update to V3.X.18 or later version"), None);
|
||||
assert_eq!(
|
||||
read("Note: A hardware upgrade to LOGO! V9 BM or later is also required"),
|
||||
None
|
||||
);
|
||||
assert_eq!(
|
||||
read("To obtain SIMATIC S7-410 V10.1 contact your local support."),
|
||||
None
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The text at `key` of `value`, trimmed, if not empty.
|
||||
fn text(value: &serde_json::Value, key: &str) -> Option<String> {
|
||||
value
|
||||
@@ -542,3 +513,32 @@ pub fn parse(doc: &serde_json::Value) -> Result<Advisory, CsafError> {
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::version_in_text;
|
||||
|
||||
#[test]
|
||||
fn only_an_update_to_a_numeric_version_names_a_fix() {
|
||||
let read = |t: &str| version_in_text(t);
|
||||
assert_eq!(
|
||||
read("Update to V3.1.5 or later version").as_deref(),
|
||||
Some("3.1.5")
|
||||
);
|
||||
assert_eq!(read("Update to V9 or later version").as_deref(), Some("9"));
|
||||
assert_eq!(
|
||||
read("Update to V4.2.1 or later version, migrate project").as_deref(),
|
||||
Some("4.2.1")
|
||||
);
|
||||
assert_eq!(read("Update to V2.9.8.").as_deref(), Some("2.9.8"));
|
||||
assert_eq!(read("Update to V3.X.18 or later version"), None);
|
||||
assert_eq!(
|
||||
read("Note: A hardware upgrade to LOGO! V9 BM or later is also required"),
|
||||
None
|
||||
);
|
||||
assert_eq!(
|
||||
read("To obtain SIMATIC S7-410 V10.1 contact your local support."),
|
||||
None
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user