-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,6 +456,87 @@ mod tests { | |
assert_eq!(borrowed.to_string(), expected); | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
Object::new(vec![ | ||
Attribute::unchecked_single("role", "ACME Company"), | ||
]), | ||
1 | ||
)] | ||
#[case( | ||
Object::new(vec![ | ||
Attribute::unchecked_single("role", "ACME Company"), | ||
Attribute::unchecked_single("address", "Packet Street 6"), | ||
Attribute::unchecked_single("address", "128 Series of Tubes"), | ||
Attribute::unchecked_single("address", "Internet"), | ||
Attribute::unchecked_single("email", "[email protected]"), | ||
Attribute::unchecked_single("nic-hdl", "RPSL1-RIPE"), | ||
Attribute::unchecked_single("source", "RIPE"), | ||
]), | ||
7 | ||
)] | ||
fn object_len(#[case] object: Object, #[case] expected: usize) { | ||
assert_eq!(object.len(), expected); | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
Object::new(vec![ | ||
Attribute::unchecked_single("role", "ACME Company"), | ||
Attribute::unchecked_single("address", "Packet Street 6"), | ||
Attribute::unchecked_single("address", "128 Series of Tubes"), | ||
Attribute::unchecked_single("address", "Internet"), | ||
Attribute::unchecked_single("email", "[email protected]"), | ||
Attribute::unchecked_single("nic-hdl", "RPSL1-RIPE"), | ||
Attribute::unchecked_single("source", "RIPE"), | ||
]), | ||
2, | ||
Attribute::unchecked_single("address", "128 Series of Tubes"), | ||
)] | ||
fn object_index(#[case] object: Object, #[case] index: usize, #[case] expected: Attribute) { | ||
assert_eq!(object[index], expected); | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
vec![ | ||
Attribute::unchecked_single("role", "ACME Company"), | ||
Attribute::unchecked_single("address", "Packet Street 6"), | ||
Attribute::unchecked_single("address", "128 Series of Tubes"), | ||
Attribute::unchecked_single("address", "Internet"), | ||
Attribute::unchecked_single("email", "[email protected]"), | ||
Attribute::unchecked_single("nic-hdl", "RPSL1-RIPE"), | ||
Attribute::unchecked_single("source", "RIPE"), | ||
], | ||
)] | ||
fn object_deref(#[case] attributes: Vec<Attribute<'static>>) { | ||
let object = Object::new(attributes.clone()); | ||
assert_eq!(*object, attributes); | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
vec![ | ||
Attribute::unchecked_single("role", "ACME Company"), | ||
Attribute::unchecked_single("address", "Packet Street 6"), | ||
Attribute::unchecked_single("address", "128 Series of Tubes"), | ||
Attribute::unchecked_single("address", "Internet"), | ||
Attribute::unchecked_single("email", "[email protected]"), | ||
Attribute::unchecked_single("nic-hdl", "RPSL1-RIPE"), | ||
Attribute::unchecked_single("source", "RIPE"), | ||
], | ||
)] | ||
fn object_into_iter(#[case] attributes: Vec<Attribute<'static>>) { | ||
let object = Object::new(attributes.clone()); | ||
|
||
let attr_iter = attributes.into_iter(); | ||
let obj_iter = object.into_iter(); | ||
|
||
for (a, b) in attr_iter.zip(obj_iter) { | ||
assert_eq!(a, b); | ||
} | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
Object::new(vec![ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,7 +159,7 @@ mod tests { | |
|
||
#[test] | ||
/// When parsing RPSL, the resulting object contains the original source it was created from. | ||
fn parsed_object_contains_source() { | ||
fn object_block_parsed_object_contains_source() { | ||
let rpsl = &mut concat!( | ||
"email: [email protected]\n", | ||
"nic-hdl: RPSL1-RIPE\n", | ||
|
@@ -183,6 +183,29 @@ mod tests { | |
assert!(parser.parse_next(object).is_err()); | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
&mut concat!( | ||
"\n\n", | ||
"email: [email protected]\n", | ||
"nic-hdl: RPSL1-RIPE\n", | ||
"\n", | ||
"\n\n\n" | ||
), | ||
vec![ | ||
Attribute::unchecked_single("email", "[email protected]"), | ||
Attribute::unchecked_single("nic-hdl", "RPSL1-RIPE") | ||
] | ||
)] | ||
fn object_block_padded_valid(#[case] given: &mut &str, #[case] attributes: Vec<Attribute>) { | ||
let expected = Object::from_parsed(given, attributes); | ||
|
||
let mut parser = object_block_padded::<_, ContextError>(object_block()); | ||
let parsed = parser.parse_next(given).unwrap(); | ||
|
||
assert_eq!(parsed, expected); | ||
} | ||
|
||
#[rstest] | ||
#[case( | ||
&mut "% Note: This is a server message\n" | ||
|