86 lines
2.2 KiB
Rust
86 lines
2.2 KiB
Rust
use std::cmp::PartialEq;
|
|
|
|
struct Ticket {
|
|
title: String,
|
|
description: String,
|
|
status: String,
|
|
}
|
|
|
|
// TODO: Implement the `PartialEq` trait for `Ticket`.
|
|
|
|
impl PartialEq for Ticket {}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_partial_eq() {
|
|
let title = "title";
|
|
let description = "description";
|
|
let status = "To-Do";
|
|
let ticket1 = Ticket {
|
|
title: title.to_string(),
|
|
description: description.to_string(),
|
|
status: status.to_string(),
|
|
};
|
|
let ticket2 = Ticket {
|
|
title: title.to_string(),
|
|
description: description.to_string(),
|
|
status: status.to_string(),
|
|
};
|
|
assert!(ticket1 == ticket2);
|
|
}
|
|
|
|
#[test]
|
|
fn test_description_not_matching() {
|
|
let title = "title";
|
|
let status = "To-Do";
|
|
let ticket1 = Ticket {
|
|
title: title.to_string(),
|
|
description: "description".to_string(),
|
|
status: status.to_string(),
|
|
};
|
|
let ticket2 = Ticket {
|
|
title: title.to_string(),
|
|
description: "description2".to_string(),
|
|
status: status.to_string(),
|
|
};
|
|
assert!(ticket1 != ticket2);
|
|
}
|
|
|
|
#[test]
|
|
fn test_title_not_matching() {
|
|
let status = "To-Do";
|
|
let description = "description";
|
|
let ticket1 = Ticket {
|
|
title: "title".to_string(),
|
|
description: description.to_string(),
|
|
status: status.to_string(),
|
|
};
|
|
let ticket2 = Ticket {
|
|
title: "title2".to_string(),
|
|
description: description.to_string(),
|
|
status: status.to_string(),
|
|
};
|
|
assert!(ticket1 != ticket2);
|
|
}
|
|
|
|
#[test]
|
|
fn test_status_not_matching() {
|
|
let title = "title";
|
|
let description = "description";
|
|
let ticket1 = Ticket {
|
|
title: title.to_string(),
|
|
description: description.to_string(),
|
|
status: "status".to_string(),
|
|
};
|
|
let ticket2 = Ticket {
|
|
title: title.to_string(),
|
|
description: description.to_string(),
|
|
status: "status2".to_string(),
|
|
};
|
|
assert!(ticket1 != ticket2);
|
|
}
|
|
}
|