Skip to content

Commit

Permalink
Verbose assertions for is_none()
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 29, 2024
1 parent 2a41ee5 commit 6d84ab8
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion internal/crypto/src/tests/ocsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn good() {
let ocsp_data =
OcspResponse::from_der_checked(rsp_data, Some(test_time), &mut validation_log).unwrap();

assert!(ocsp_data.revoked_at.is_none());
assert_eq!(ocsp_data.revoked_at, None);
assert!(ocsp_data.ocsp_certs.is_some());
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/examples/v2api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn main() -> Result<()> {
}

println!("{}", reader.json());
assert!(reader.validation_status().is_none());
assert_eq!(reader.validation_status(), None);
assert_eq!(reader.active_manifest().unwrap().title().unwrap(), title);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/asset_handlers/gif_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ mod tests {

let gif_io = GifIO {};

assert!(gif_io.read_xmp(&mut stream).is_none());
assert_eq!(gif_io.read_xmp(&mut stream), None);

let mut output_stream1 = Cursor::new(Vec::with_capacity(SAMPLE1.len()));
gif_io.embed_reference_to_stream(
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/asset_handlers/mp3_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ pub mod tests {
let mp3_io = Mp3IO::new("mp3");

let mut stream = File::open(fixture_path("sample1.mp3"))?;
assert!(mp3_io.read_xmp(&mut stream).is_none());
assert_eq!(mp3_io.read_xmp(&mut stream), None);
stream.rewind()?;

let mut output_stream1 = Cursor::new(Vec::new());
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/asset_handlers/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ mod tests {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test_read_xmp_on_pdf_with_none() {
let pdf = Pdf::from_bytes(include_bytes!("../../tests/fixtures/basic-no-xmp.pdf")).unwrap();
assert!(pdf.read_xmp().is_none());
assert_eq!(pdf.read_xmp(), None);
}

#[cfg_attr(not(target_arch = "wasm32"), test)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/asset_handlers/pdf_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub mod tests {
mock_pdf.expect_read_xmp().returning(|| None);

let pdf_io = PdfIO::new("pdf");
assert!(pdf_io.read_xmp_from_pdf(mock_pdf).is_none());
assert_eq!(pdf_io.read_xmp_from_pdf(mock_pdf), None);
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions sdk/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ mod tests {
let manifest_store = Reader::from_stream(format, &mut dest).expect("from_bytes");

println!("{}", manifest_store);
assert!(manifest_store.validation_status().is_none());
assert_eq!(manifest_store.validation_status(), None);
assert!(manifest_store.active_manifest().is_some());
let manifest = manifest_store.active_manifest().unwrap();
assert_eq!(manifest.title().unwrap(), "Test_Manifest");
Expand Down Expand Up @@ -1344,7 +1344,7 @@ mod tests {
let manifest_store = Reader::from_file(&dest).expect("from_bytes");

println!("{}", manifest_store);
assert!(manifest_store.validation_status().is_none());
assert_eq!(manifest_store.validation_status(), None);
assert_eq!(
manifest_store.active_manifest().unwrap().title().unwrap(),
"Test_Manifest"
Expand Down Expand Up @@ -1401,7 +1401,7 @@ mod tests {
println!("{}", manifest_store);
if format != "c2pa" {
// c2pa files will not validate since they have no associated asset
assert!(manifest_store.validation_status().is_none());
assert_eq!(manifest_store.validation_status(), None);
}
assert_eq!(
manifest_store.active_manifest().unwrap().title().unwrap(),
Expand Down Expand Up @@ -1488,7 +1488,7 @@ mod tests {
.expect("from_bytes");

println!("{}", reader.json());
assert!(reader.validation_status().is_none());
assert_eq!(reader.validation_status(), None);
}

#[test]
Expand Down Expand Up @@ -1547,7 +1547,7 @@ mod tests {
let reader = crate::Reader::from_stream("image/jpeg", output_stream).unwrap();
println!("{reader}");
#[cfg(not(target_arch = "wasm32"))] // skip this until we get wasm async signing working
assert!(reader.validation_status().is_none());
assert_eq!(reader.validation_status(), None);
}

#[cfg_attr(not(target_arch = "wasm32"), actix::test)]
Expand Down Expand Up @@ -1643,7 +1643,7 @@ mod tests {
let reader = Reader::from_stream("image/jpeg", &mut dest).expect("from_bytes");

//println!("{}", reader);
assert!(reader.validation_status().is_none());
assert_eq!(reader.validation_status(), None);
assert_eq!(
reader
.active_manifest()
Expand Down
46 changes: 23 additions & 23 deletions sdk/src/ingredient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,13 +1530,13 @@ mod tests {
assert_eq!(&ingredient.title, title);
assert_eq!(ingredient.format(), format);
assert!(ingredient.manifest_data().is_some());
assert!(ingredient.metadata().is_none());
assert_eq!(ingredient.metadata(), None);
#[cfg(target_arch = "wasm32")]
web_sys::console::debug_2(
&"ingredient_from_memory_async:".into(),
&ingredient.to_string().into(),
);
assert!(ingredient.validation_status().is_none());
assert_eq!(ingredient.validation_status(), None);
}

#[cfg_attr(not(target_arch = "wasm32"), test)]
Expand All @@ -1553,8 +1553,8 @@ mod tests {
assert_eq!(&ingredient.title, title);
assert_eq!(ingredient.format(), format);
assert!(ingredient.manifest_data().is_some());
assert!(ingredient.metadata().is_none());
assert!(ingredient.validation_status().is_none());
assert_eq!(ingredient.metadata(), None);
assert_eq!(ingredient.validation_status(), None);
}

#[cfg_attr(not(target_arch = "wasm32"), actix::test)]
Expand All @@ -1574,7 +1574,7 @@ mod tests {
#[cfg(feature = "add_thumbnails")]
assert!(ingredient.thumbnail().is_some());
assert!(ingredient.manifest_data().is_some());
assert!(ingredient.metadata().is_none());
assert_eq!(ingredient.metadata(), None);
assert!(ingredient.validation_status().is_some());
assert_eq!(
ingredient.validation_status().unwrap()[0].code(),
Expand All @@ -1597,7 +1597,7 @@ mod tests {
assert!(ingredient.provenance().is_some());
assert!(ingredient.provenance().unwrap().starts_with("https:"));
assert!(ingredient.manifest_data().is_some());
assert!(ingredient.validation_status().is_none());
assert_eq!(ingredient.validation_status(), None);
}

#[allow(dead_code)]
Expand All @@ -1619,7 +1619,7 @@ mod tests {
.url()
.unwrap()
.starts_with("http"));
assert!(ingredient.manifest_data().is_none());
assert_eq!(ingredient.manifest_data(), None);
}

#[cfg_attr(not(target_arch = "wasm32"), actix::test)]
Expand All @@ -1640,7 +1640,7 @@ mod tests {
&"ingredient_from_memory_async:".into(),
&ingredient.to_string().into(),
);
assert!(ingredient.validation_status().is_none());
assert_eq!(ingredient.validation_status(), None);
assert!(ingredient.manifest_data().is_some());
assert!(ingredient.provenance().is_some());
}
Expand Down Expand Up @@ -1685,7 +1685,7 @@ mod tests_file_io {
assert!(ingredient.thumbnail().is_some());
assert_eq!(ingredient.thumbnail().unwrap().0, format);
} else {
assert!(ingredient.thumbnail().is_none());
assert_eq!(ingredient.thumbnail(), None);
}
}

Expand All @@ -1701,8 +1701,8 @@ mod tests_file_io {
println!("ingredient = {ingredient}");
assert_eq!(ingredient.title(), "Purple Square.psd");
assert_eq!(ingredient.format(), "image/vnd.adobe.photoshop");
assert!(ingredient.thumbnail().is_none()); // should always be none
assert!(ingredient.manifest_data().is_none());
assert_eq!(ingredient.thumbnail(), None); // should always be none
assert_eq!(ingredient.manifest_data(), None);
}

#[test]
Expand All @@ -1722,7 +1722,7 @@ mod tests_file_io {
.identifier
.starts_with("self#jumbf="));
assert!(ingredient.manifest_data().is_some());
assert!(ingredient.metadata().is_none());
assert_eq!(ingredient.metadata(), None);
}

#[test]
Expand All @@ -1736,9 +1736,9 @@ mod tests_file_io {
assert_eq!(&ingredient.title, NO_MANIFEST_JPEG);
assert_eq!(ingredient.format(), "image/jpeg");
test_thumbnail(&ingredient, "image/jpeg");
assert!(ingredient.provenance().is_none());
assert!(ingredient.manifest_data().is_none());
assert!(ingredient.metadata().is_none());
assert_eq!(ingredient.provenance(), None);
assert_eq!(ingredient.manifest_data(), None);
assert_eq!(ingredient.metadata(), None);
assert!(ingredient.instance_id().starts_with("xmp.iid:"));
#[cfg(feature = "add_thumbnails")]
assert!(ingredient
Expand Down Expand Up @@ -1774,8 +1774,8 @@ mod tests_file_io {
assert_eq!(ingredient.format(), "image/jpeg");
assert_eq!(ingredient.hash(), Some("1234568abcdef"));
assert_eq!(ingredient.thumbnail_ref().unwrap().format, "image/foo"); // always generated
assert!(ingredient.manifest_data().is_none());
assert!(ingredient.metadata().is_none());
assert_eq!(ingredient.manifest_data(), None);
assert_eq!(ingredient.metadata(), None);
}

#[test]
Expand All @@ -1788,8 +1788,8 @@ mod tests_file_io {
println!("ingredient = {ingredient}");
assert_eq!(ingredient.title(), "libpng-test.png");
test_thumbnail(&ingredient, "image/png");
assert!(ingredient.provenance().is_none());
assert!(ingredient.manifest_data.is_none());
assert_eq!(ingredient.provenance(), None);
assert_eq!(ingredient.manifest_data, None);
}

#[test]
Expand Down Expand Up @@ -1824,7 +1824,7 @@ mod tests_file_io {
assert_eq!(ingredient.format(), "image/jpeg");
test_thumbnail(&ingredient, "image/jpeg");
assert!(ingredient.provenance().is_some());
assert!(ingredient.manifest_data().is_none());
assert_eq!(ingredient.manifest_data(), None);
assert!(ingredient.validation_status().is_some());
assert_eq!(
ingredient.validation_status().unwrap()[0].code(),
Expand All @@ -1838,7 +1838,7 @@ mod tests_file_io {
let ap = fixture_path("CIE-sig-CA.jpg");
let ingredient = Ingredient::from_file(ap).expect("from_file");
// println!("ingredient = {ingredient}");
assert!(ingredient.validation_status().is_none());
assert_eq!(ingredient.validation_status(), None);
assert!(ingredient.manifest_data().is_some());
}

Expand Down Expand Up @@ -1890,11 +1890,11 @@ mod tests_file_io {
let mut ingredient = Ingredient::new("title", "format", "instance_id");
ingredient.resources.set_base_path(folder);

assert!(ingredient.thumbnail_ref().is_none());
assert_eq!(ingredient.thumbnail_ref(), None);
// assert!(ingredient
// .set_manifest_data_ref(ResourceRef::new("image/jpg", "foo"))
// .is_err());
assert!(ingredient.manifest_data_ref().is_none());
assert_eq!(ingredient.manifest_data_ref(), None);
// verify we can set a reference
assert!(ingredient
.set_thumbnail_ref(ResourceRef::new("image/jpg", "C.jpg"))
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/jumbf/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub mod tests {
Some(assertion.to_string()),
assertion_label_from_uri(&assertion_uri)
);
assert_eq!(None, assertion_label_from_uri(&absolute_uri));
assert_eq!(assertion_label_from_uri(&absolute_uri), None);

let assertion_relative = to_relative_uri(&assertion_uri);

Expand Down
18 changes: 9 additions & 9 deletions sdk/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ pub(crate) mod tests {
if cfg!(feature = "add_thumbnails") {
assert!(manifest.thumbnail().is_some());
} else {
assert!(manifest.thumbnail().is_none());
assert_eq!(manifest.thumbnail(), None);
}
let ingredient = Ingredient::from_file(&test_output).expect("load_from_asset");
assert!(ingredient.active_manifest().is_some());
Expand Down Expand Up @@ -1816,7 +1816,7 @@ pub(crate) mod tests {
let redacted_uri = &claim2.redactions().unwrap()[0];

let claim1 = store3.get_claim(&claim1_label).unwrap();
assert!(claim1.get_claim_assertion(redacted_uri, 0).is_none());
assert_eq!(claim1.get_claim_assertion(redacted_uri, 0), None);
}

#[test]
Expand Down Expand Up @@ -2587,7 +2587,7 @@ pub(crate) mod tests {
assert!(manifest
.set_thumbnail_ref(ResourceRef::new("image/jpg", "foo"))
.is_err());
assert!(manifest.thumbnail_ref().is_none());
assert_eq!(manifest.thumbnail_ref(), None);
// verify we can set a references that do exist
assert!(manifest
.set_thumbnail_ref(ResourceRef::new("image/jpeg", "C.jpg"))
Expand Down Expand Up @@ -2619,7 +2619,7 @@ pub(crate) mod tests {
// verify there is a thumbnail ref
assert!(manifest.thumbnail_ref().is_some());
// verify there is no thumbnail
assert!(manifest.thumbnail().is_none());
assert_eq!(manifest.thumbnail(), None);

let signer = temp_signer();
manifest
Expand All @@ -2629,8 +2629,8 @@ pub(crate) mod tests {
let manifest_store = Reader::from_file(&output).expect("from_file");
println!("{manifest_store}");
let active_manifest = manifest_store.active_manifest().unwrap();
assert!(active_manifest.thumbnail_ref().is_none());
assert!(active_manifest.thumbnail().is_none());
assert_eq!(active_manifest.thumbnail_ref(), None);
assert_eq!(active_manifest.thumbnail(), None);
}

#[test]
Expand Down Expand Up @@ -2715,7 +2715,7 @@ pub(crate) mod tests {

let manifest_store = Reader::from_file(&output).expect("from_file");
println!("{manifest_store}");
assert!(manifest_store.validation_status().is_none());
assert_eq!(manifest_store.validation_status(), None);
}

#[cfg(all(feature = "file_io", feature = "openssl_sign"))]
Expand Down Expand Up @@ -2774,7 +2774,7 @@ pub(crate) mod tests {

let manifest_store = Reader::from_file(&output).expect("from_file");
println!("{manifest_store}");
assert!(manifest_store.validation_status().is_none());
assert_eq!(manifest_store.validation_status(), None);
}

#[test]
Expand Down Expand Up @@ -2807,6 +2807,6 @@ pub(crate) mod tests {
.unwrap();
println!("{reader}");
assert!(reader.active_manifest().is_some());
assert!(reader.validation_status().is_none());
assert_eq!(reader.validation_status(), None);
}
}
Loading

0 comments on commit 6d84ab8

Please sign in to comment.