use super::common::{MimeType, SmallString, Url};
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct InReplyTo {
pub ref_: Option<SmallString>,
pub href: Option<Url>,
pub type_: Option<MimeType>,
pub source: Option<Url>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_in_reply_to_default() {
let reply = InReplyTo::default();
assert!(reply.ref_.is_none());
assert!(reply.href.is_none());
assert!(reply.type_.is_none());
assert!(reply.source.is_none());
}
#[test]
fn test_in_reply_to_partial_construction() {
let reply = InReplyTo {
ref_: Some("tag:example.com,2024:post/1".into()),
..Default::default()
};
assert_eq!(reply.ref_.as_deref(), Some("tag:example.com,2024:post/1"));
assert!(reply.href.is_none());
assert!(reply.type_.is_none());
assert!(reply.source.is_none());
}
#[test]
fn test_in_reply_to_equality() {
let a = InReplyTo {
ref_: Some("tag:example.com,2024:1".into()),
href: Some("https://example.com/1".into()),
type_: Some("text/html".into()),
source: Some("https://example.com/feed.xml".into()),
};
let b = a.clone();
assert_eq!(a, b);
}
#[test]
#[allow(clippy::redundant_clone)]
fn test_in_reply_to_clone() {
let original = InReplyTo {
ref_: Some("tag:example.com,2024:post/1".into()),
href: Some("https://example.com/post/1".into()),
type_: Some("text/html".into()),
source: Some("https://example.com/feed.xml".into()),
};
let cloned = original.clone();
assert_eq!(cloned.ref_.as_deref(), Some("tag:example.com,2024:post/1"));
assert_eq!(cloned.href.as_deref(), Some("https://example.com/post/1"));
assert_eq!(cloned.type_.as_deref(), Some("text/html"));
assert_eq!(
cloned.source.as_deref(),
Some("https://example.com/feed.xml")
);
}
}