Skip to content

Commit 5d8295a

Browse files
committed
Add test for attractor tool
1 parent 8fccce2 commit 5d8295a

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mod test_attractor;
12
mod test_bundle;
23
#[cfg(feature = "cxx-bindings")]
34
mod test_geom2graph;

tests/test_attractor.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use pretty_assertions::assert_eq;
2+
3+
use crate::{CommandExt, tool};
4+
5+
#[test]
6+
fn test_attractor_simple() {
7+
let expected = "\
8+
POINT(1 2)\n\
9+
POINT(2 4)\n\
10+
POINT(3 6)\n\
11+
";
12+
13+
let output = tool("attractor")
14+
.arg("--initial-x=0")
15+
.arg("--initial-y=0")
16+
.arg("--math=let x_new = x + 1.0;")
17+
.arg("--math=let y_new = y + 2.0;")
18+
.arg("--iterations=3")
19+
.captured_output();
20+
assert!(output.status.success());
21+
let stdout = String::from_utf8_lossy(&output.stdout);
22+
assert_eq!(expected, stdout);
23+
}

0 commit comments

Comments
 (0)