Skip to content

Commit

Permalink
chore: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
slavik-pastushenko committed Oct 24, 2024
1 parent 5b1eaf4 commit 18f018b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 12 additions & 2 deletions examples/src/dijkstra.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use graph_algorithms::{Dijkstra, GraphAlgorithm};

pub fn run() {
pub fn run() -> Vec<usize> {
let mut dijkstra = Dijkstra::new();
dijkstra.set_nodes(vec![
(0, vec![(1, 1), (2, 4)]),
Expand All @@ -10,5 +10,15 @@ pub fn run() {

let result = dijkstra.run(0);

println!("{:?}", result);
return result;
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_dijkstra() {
assert_eq!(run(), vec![0, 1, 3]);
}
}
11 changes: 11 additions & 0 deletions examples/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ fn main() {
// Run the Dijkstra example
dijkstra::run();
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_main() {
// Just test that the main function runs without panicking
main();
}
}

0 comments on commit 18f018b

Please sign in to comment.