Skip to content

Commit

Permalink
Update hugr/src/hugr/serialize.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Agustín Borgna <[email protected]>
  • Loading branch information
doug-q and aborgna-q authored Apr 19, 2024
1 parent 83e64a2 commit cd130ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hugr/src/hugr/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ pub mod test {
pub fn check_hugr_schema_roundtrip(hugr: &Hugr) -> Hugr {
check_hugr_roundtrip(hugr, true)
}

/// Serialize and deserialize a HUGR, and check that the result is the same as the original.
///
/// If `check_schema` is true, checks the serialized json against the in-tree schema.
///
/// Returns the deserialized HUGR.
pub fn check_hugr_roundtrip(hugr: &Hugr, check_schema: bool) -> Hugr {
let new_hugr: Hugr = ser_roundtrip_validate(hugr, check_schema.then_some(&SCHEMA));

Expand Down

0 comments on commit cd130ca

Please sign in to comment.