-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
48 additions
and
68 deletions.
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 |
---|---|---|
@@ -1,29 +1,27 @@ | ||
use std::path::PathBuf; | ||
use std::{ | ||
path::PathBuf, | ||
sync::{Arc, RwLock}, | ||
}; | ||
|
||
use crate::custom_file::traits::File; | ||
|
||
use super::TextFile; | ||
use crate::custom_file::{ | ||
text_file::{TextFileEntity, TextFileLink}, | ||
traits::File, | ||
}; | ||
|
||
#[test] | ||
fn drop_from_leaves() -> anyhow::Result<()> { | ||
let v = { | ||
let a = TextFile::new(PathBuf::from("a.txt"), "hello!".to_string())?; | ||
|
||
let b1 = a.create_symlink_to(PathBuf::from("b1.txt"))?; | ||
let b2 = a.create_symlink_to(PathBuf::from("b2.txt"))?; | ||
let b3 = a.create_symlink_to(PathBuf::from("b3.txt"))?; | ||
fn drop_not_leaf_node() -> anyhow::Result<()> { | ||
let a = Arc::new(RwLock::new(TextFileEntity::new( | ||
PathBuf::from("a.txt"), | ||
"hello".to_string(), | ||
)?)); | ||
|
||
let c1 = b1.create_symlink_to(PathBuf::from("c1.txt"))?; | ||
let c2 = b1.create_symlink_to(PathBuf::from("c2.txt"))?; | ||
let c3 = b1.create_symlink_to(PathBuf::from("c3.txt"))?; | ||
let b = TextFileLink::new(PathBuf::from("b.txt"), a.clone())?; | ||
|
||
vec![a, b1, b2, b3, c1, c2, c3]; | ||
}; | ||
let c = b.create_symlink_to(PathBuf::from("c.txt"))?; | ||
|
||
// たとえば | ||
// "b2.txt"→ "b3.txt"→ "c1.txt"→ "c2.txt"→ "c3.txt"→ "b1.txt"→ "a.txt" | ||
// のように,葉から drop することが確認できる. | ||
drop(v); | ||
drop(b); | ||
|
||
println!("b is dropped."); | ||
|
||
Ok(()) | ||
} |