-
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
1 parent
6aa9786
commit 684a1c2
Showing
11 changed files
with
218 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
[package] | ||
name = "algorithms-on-graphs" | ||
name = "algorithms_on_graphs" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "algorithms_on_graphs" | ||
path = "./src/main.rs" | ||
|
||
[lib] | ||
name = "algorithms_on_graphs" | ||
path = "./src/main.rs" | ||
|
||
[dependencies] | ||
clap = { version = "4.5.17", features = ["derive"] } | ||
mockall = "0.13.0" |
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
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
use algorithms_on_graphs::cli::cli::{run_cli, Algorithm, Args}; | ||
use algorithms_on_graphs::graph::graph::Path; | ||
|
||
#[test] | ||
#[should_panic] | ||
fn wrong_header_panic() { | ||
let args = Args { | ||
algorithm: Algorithm::IsAcyclic, | ||
file: PathBuf::from_str("./tests/test_dataset/wrong_header.txt").unwrap(), | ||
}; | ||
run_cli(&args); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn wrong_first_vertex_panic() { | ||
let args = Args { | ||
algorithm: Algorithm::IsAcyclic, | ||
file: PathBuf::from_str("./tests/test_dataset/wrong_first_vertex.txt").unwrap(), | ||
}; | ||
run_cli(&args); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn wrong_second_vertex_panic() { | ||
let args = Args { | ||
algorithm: Algorithm::IsAcyclic, | ||
file: PathBuf::from_str("./tests/test_dataset/wrong_second_vertex.txt").unwrap(), | ||
}; | ||
run_cli(&args); | ||
} | ||
|
||
#[test] | ||
#[should_panic] | ||
fn wrong_weight_panic() { | ||
let args = Args { | ||
algorithm: Algorithm::IsAcyclic, | ||
file: PathBuf::from_str("./tests/test_dataset/wrong_weight.txt").unwrap(), | ||
}; | ||
run_cli(&args); | ||
} | ||
|
||
#[test] | ||
fn is_acylic_success() { | ||
let args = Args { | ||
algorithm: Algorithm::IsAcyclic, | ||
file: PathBuf::from_str("./dataset/input_random_01_10.txt").unwrap(), | ||
}; | ||
let res = run_cli(&args); | ||
|
||
let expected = &true; | ||
let current = res.downcast_ref::<bool>().unwrap(); | ||
assert_eq!(expected, current); | ||
} | ||
|
||
#[test] | ||
fn kruskal_naive_success() { | ||
let args = Args { | ||
algorithm: Algorithm::KruskalNaive, | ||
file: PathBuf::from_str("./dataset/input_random_01_10.txt").unwrap(), | ||
}; | ||
let res = run_cli(&args); | ||
|
||
let expected_path = &vec![ | ||
(6, 7, -7462), | ||
(8, 9, -976), | ||
(4, 5, -433), | ||
(2, 3, 1392), | ||
(1, 2, 4993), | ||
(5, 6, 6590), | ||
(7, 8, 6658), | ||
(3, 4, 8856), | ||
(9, 10, 9698), | ||
]; | ||
let current_path = res.downcast_ref::<Path>().unwrap(); | ||
assert_eq!(expected_path, current_path); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
use algorithms_on_graphs::cli::cli::{run_cli, Algorithm, Args}; | ||
use algorithms_on_graphs::graph::graph::Path; | ||
|
||
#[test] | ||
fn is_acylic_success() { | ||
let args = Args { | ||
algorithm: Algorithm::IsAcyclic, | ||
file: PathBuf::from_str("./dataset/input_random_01_10.txt").unwrap(), | ||
}; | ||
let res = run_cli(&args); | ||
|
||
let expected = &true; | ||
let current = res.downcast_ref::<bool>().unwrap(); | ||
assert_eq!(expected, current); | ||
} | ||
|
||
#[test] | ||
fn kruskal_naive_success() { | ||
let args = Args { | ||
algorithm: Algorithm::KruskalNaive, | ||
file: PathBuf::from_str("./dataset/input_random_01_10.txt").unwrap(), | ||
}; | ||
let res = run_cli(&args); | ||
|
||
let expected_path = &vec![ | ||
(6, 7, -7462), | ||
(8, 9, -976), | ||
(4, 5, -433), | ||
(2, 3, 1392), | ||
(1, 2, 4993), | ||
(5, 6, 6590), | ||
(7, 8, 6658), | ||
(3, 4, 8856), | ||
(9, 10, 9698), | ||
]; | ||
let current_path = res.downcast_ref::<Path>().unwrap(); | ||
assert_eq!(expected_path, current_path); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
use algorithms_on_graphs::cli::cli::{run_cli, Algorithm, Args}; | ||
use algorithms_on_graphs::graph::graph::Path; | ||
|
||
#[test] | ||
fn kruskal_naive_success() { | ||
let args = Args { | ||
algorithm: Algorithm::KruskalNaive, | ||
file: PathBuf::from_str("./dataset/input_random_01_10.txt").unwrap(), | ||
}; | ||
let res = run_cli(&args); | ||
|
||
let expected_path = &vec![ | ||
(6, 7, -7462), | ||
(8, 9, -976), | ||
(4, 5, -433), | ||
(2, 3, 1392), | ||
(1, 2, 4993), | ||
(5, 6, 6590), | ||
(7, 8, 6658), | ||
(3, 4, 8856), | ||
(9, 10, 9698), | ||
]; | ||
let current_path = res.downcast_ref::<Path>().unwrap(); | ||
assert_eq!(expected_path, current_path); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
10 9 | ||
1 2 4993 | ||
2 3 1392 | ||
3 4 8856 | ||
4 5 -433 | ||
5 6 6590 | ||
6 7 -7462 | ||
7 8 6658 | ||
8 9 -976 | ||
9 10 9698 |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
10 9 | ||
|
||
2 3 1392 | ||
3 4 8856 | ||
4 5 -433 | ||
5 6 6590 | ||
6 7 -7462 | ||
7 8 6658 | ||
8 9 -976 | ||
9 10 9698 |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
1 2 4993 | ||
2 3 1392 | ||
3 4 8856 | ||
4 5 -433 | ||
5 6 6590 | ||
6 7 -7462 | ||
7 8 6658 | ||
8 9 -976 | ||
9 10 9698 |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
10 9 | ||
1 | ||
2 3 1392 | ||
3 4 8856 | ||
4 5 -433 | ||
5 6 6590 | ||
6 7 -7462 | ||
7 8 6658 | ||
8 9 -976 | ||
9 10 9698 |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
10 9 | ||
1 2 | ||
2 3 1392 | ||
3 4 8856 | ||
4 5 -433 | ||
5 6 6590 | ||
6 7 -7462 | ||
7 8 6658 | ||
8 9 -976 | ||
9 10 9698 |