Skip to content

Commit

Permalink
Make tests without features pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
zrho committed Jun 24, 2024
1 parent e81f376 commit cf537bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions hugr-sexpr/tests/derive_input.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use hugr_sexpr::{from_str, input::Input, read::ReadError, Symbol, Value};

#[test]
#[cfg(feature = "derive")]
pub fn positional() {
#[derive(Input)]
struct Test {
Expand All @@ -15,6 +16,7 @@ pub fn positional() {
}

#[test]
#[cfg(feature = "derive")]
pub fn optional_given() {
#[derive(Input)]
struct Test {
Expand All @@ -27,6 +29,8 @@ pub fn optional_given() {
assert_eq!(test.field.unwrap(), "string");
}

#[test]
#[cfg(feature = "derive")]
pub fn optional_absent() {
#[derive(Input)]
struct Test {
Expand All @@ -40,6 +44,7 @@ pub fn optional_absent() {
}

#[test]
#[cfg(feature = "derive")]
pub fn optional_duplicate() {
#[derive(Debug, Input)]
struct Test {
Expand All @@ -57,6 +62,7 @@ pub fn optional_duplicate() {
}

#[test]
#[cfg(feature = "derive")]
pub fn required_given() {
#[derive(Input)]
struct Test {
Expand All @@ -69,12 +75,14 @@ pub fn required_given() {
assert_eq!(test.field, "string");
}

#[test]
#[cfg(feature = "derive")]
pub fn required_absent() {
#[derive(Input)]
struct Test {
#[allow(dead_code)]
#[sexpr(optional)]
field: Option<String>,
#[sexpr(required)]
field: String,
}

let result = from_str::<Test>(r#""#);
Expand All @@ -83,6 +91,7 @@ pub fn required_absent() {
}

#[test]
#[cfg(feature = "derive")]
pub fn required_duplicate() {
#[derive(Input)]
struct Test {
Expand All @@ -97,6 +106,7 @@ pub fn required_duplicate() {
}

#[test]
#[cfg(feature = "derive")]
pub fn repeated() {
#[derive(Input)]
struct Test {
Expand All @@ -117,6 +127,7 @@ pub fn repeated() {
}

#[test]
#[cfg(feature = "derive")]
pub fn resursive_field() {
#[derive(Input, PartialEq, Eq, Debug)]
struct Outer {
Expand Down
5 changes: 5 additions & 0 deletions hugr-sexpr/tests/derive_output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use hugr_sexpr::{from_str, output::Output, to_values, Value};

#[test]
#[cfg(feature = "derive")]
pub fn positional() {
#[derive(Output)]
pub struct Test {
Expand All @@ -19,6 +20,7 @@ pub fn positional() {
}

#[test]
#[cfg(feature = "derive")]
pub fn required() {
#[derive(Output)]
pub struct Test {
Expand All @@ -38,6 +40,7 @@ pub fn required() {
}

#[test]
#[cfg(feature = "derive")]
pub fn optional_given() {
#[derive(Output)]
pub struct Test {
Expand All @@ -57,6 +60,7 @@ pub fn optional_given() {
}

#[test]
#[cfg(feature = "derive")]
pub fn optional_absent() {
#[derive(Output)]
pub struct Test {
Expand All @@ -76,6 +80,7 @@ pub fn optional_absent() {
}

#[test]
#[cfg(feature = "derive")]
pub fn repeated() {
#[derive(Output)]
struct Test {
Expand Down

0 comments on commit cf537bc

Please sign in to comment.