Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Dec 3, 2024
1 parent 861e619 commit a5b4123
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/types/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ impl OwnedFieldIterator {
fields: data.into(),
}
}

fn empty() -> OwnedFieldIterator {
OwnedFieldIterator {
fields: VecDeque::default(),
}
}
}

impl Iterator for OwnedFieldIterator {
Expand Down Expand Up @@ -387,6 +381,7 @@ mod tests {
fn for_field_in_struct() {
// Simple example to exercise List's implementation of IntoIterator
let s = ion_struct! { "foo": 1, "bar": 2, "baz": 3};
let fields = s.clone().iter().collect::<Vec<_>>();

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, experimental-ion-hash)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, default)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, default)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, experimental-ion-hash)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, all)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, experimental)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, experimental)

unused variable: `fields`

Check failure on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `fields`

error: unused variable: `fields` --> src/types/struct.rs:384:13 | 384 | let fields = s.clone().iter().collect::<Vec<_>>(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_fields` | = note: `-D unused-variables` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_variables)]`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, all)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, default)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, experimental-ion-hash)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, experimental)

unused variable: `fields`

Check warning on line 384 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, all)

unused variable: `fields`
let mut baz_value = None;
for (name, value) in &s {
if *name == "baz" {
Expand All @@ -395,4 +390,18 @@ mod tests {
}
assert_eq!(baz_value, Some(&Element::int(3)));
}

#[test]
fn for_field_in_owned_struct() {
// Simple example to exercise List's implementation of IntoIterator
let s = ion_struct! { "foo": 1, "bar": 2, "baz": 3};
let fields = s.clone().into_iter().collect::<Vec<_>>();

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, experimental-ion-hash)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, default)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, default)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, experimental-ion-hash)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, all)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, experimental)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (macos, experimental)

unused variable: `fields`

Check failure on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `fields`

error: unused variable: `fields` --> src/types/struct.rs:398:13 | 398 | let fields = s.clone().into_iter().collect::<Vec<_>>(); | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu, all)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, default)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, experimental-ion-hash)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, experimental)

unused variable: `fields`

Check warning on line 398 in src/types/struct.rs

View workflow job for this annotation

GitHub Actions / Build and Test (windows, all)

unused variable: `fields`
let mut baz_value = None;
for (name, value) in s {
if name == "baz" {
baz_value = Some(value);
}
}
assert_eq!(baz_value, Some(Element::int(3)));
}
}

0 comments on commit a5b4123

Please sign in to comment.