Skip to content

Commit

Permalink
test Rc, Arc, Box
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Dec 4, 2024
1 parent cf31c09 commit 7d460f8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions hugr-core/src/hugr/views/impls.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::sync::Arc;
use std::{borrow::Cow, rc::Rc};
use std::{borrow::Cow, rc::Rc, sync::Arc};

use delegate::delegate;

Expand Down Expand Up @@ -62,6 +61,8 @@ impl<H: AsRef<Hugr>, Root> HugrView for RootChecked<H, Root> {

#[cfg(test)]
mod test {
use std::{rc::Rc, sync::Arc};

use crate::hugr::views::{DescendantsGraph, HierarchyView};
use crate::{Hugr, HugrView, Node};

Expand All @@ -73,7 +74,7 @@ mod test {
}

#[test]
fn test_views() {
fn test_refs_to_view() {
let h = Hugr::default();
let v = ViewWrapper(&h);
let c = h.nodes().count();
Expand All @@ -88,5 +89,13 @@ mod test {
assert_eq!(vh.nodes().count(), c);
let h: Hugr = vh.0;
assert_eq!(h.nodes().count(), c);

let vb = ViewWrapper(Box::new(&h));
assert_eq!(vb.nodes().count(), c);
let va = ViewWrapper(Arc::new(h));
assert_eq!(va.nodes().count(), c);
let h = Arc::try_unwrap(va.0).unwrap();
let vr = Rc::new(&h);
assert_eq!(ViewWrapper(&vr).nodes().count(), h.nodes().count());
}
}

0 comments on commit 7d460f8

Please sign in to comment.