Skip to content

Commit 4c8e863

Browse files
committed
message/test: add test for adding duplicate attributes
1 parent 3885a30 commit 4c8e863

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

stun-types/src/message.rs

+25
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,31 @@ mod tests {
20502050
}
20512051
}
20522052

2053+
#[test]
2054+
fn duplicate_add_attribute() {
2055+
let _log = crate::tests::test_init_log();
2056+
let mut msg = Message::builder_request(BINDING);
2057+
let software = Software::new("s").unwrap();
2058+
msg.add_attribute(&software).unwrap();
2059+
assert!(matches!(
2060+
msg.add_attribute(&software),
2061+
Err(StunWriteError::AttributeExists(ty)) if ty == Software::TYPE
2062+
));
2063+
}
2064+
2065+
#[test]
2066+
fn duplicate_add_raw_attribute() {
2067+
let _log = crate::tests::test_init_log();
2068+
let mut msg = Message::builder_request(BINDING);
2069+
let software = Software::new("s").unwrap();
2070+
let raw = software.to_raw();
2071+
msg.add_raw_attribute(raw.clone()).unwrap();
2072+
assert!(matches!(
2073+
msg.add_raw_attribute(raw),
2074+
Err(StunWriteError::AttributeExists(ty)) if ty == Software::TYPE
2075+
));
2076+
}
2077+
20532078
#[test]
20542079
fn duplicate_fingerprint() {
20552080
let _log = crate::tests::test_init_log();

0 commit comments

Comments
 (0)