consider adding the same hunk an update

This commit is contained in:
nikita@galaiko.rocks 2023-07-18 09:03:30 +02:00 committed by Nikita Galaiko
parent 16b70977c4
commit 3c579ef577

View File

@ -48,10 +48,6 @@ impl TryFrom<&str> for Ownership {
impl Ownership {
pub fn put(&mut self, ownership: &FileOwnership) {
if self.files.contains(ownership) {
return;
}
let target = self
.files
.iter()
@ -172,6 +168,22 @@ mod tests {
);
}
#[test]
fn test_put_4() {
let mut ownership = Ownership::try_from("src/main.rs:0-100\nsrc/main2.rs:100-200").unwrap();
ownership.put(&FileOwnership::try_from("src/main2.rs:100-200").unwrap());
assert_eq!(ownership.files.len(), 2);
assert_eq!(
ownership.files[0],
FileOwnership::try_from("src/main2.rs:100-200").unwrap()
);
assert_eq!(
ownership.files[1],
FileOwnership::try_from("src/main.rs:0-100").unwrap()
);
}
#[test]
fn test_put_7() {
let mut ownership = Ownership::try_from("src/main.rs:100-200").unwrap();