Skip to content

Commit 7035c8c

Browse files
committed
Add test for pack tool
1 parent f8b44d3 commit 7035c8c

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mod test_bundle;
2+
mod test_pack;
23

34
use std::collections::HashMap;
45
use std::path::PathBuf;

tests/test_pack.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use pretty_assertions::assert_eq;
2+
3+
use crate::{CommandExt, tool};
4+
5+
#[test]
6+
fn test_pack_four_squares() {
7+
let input = b"\
8+
POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))\n\
9+
POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))\n\
10+
POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))\n\
11+
POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))\n\
12+
";
13+
14+
let expected = "\
15+
POLYGON((-0.5 -0.5,-0.5 0.5,0.5 0.5,0.5 -0.5,-0.5 -0.5))\n\
16+
POLYGON((1.5 -0.5,1.5 0.5,2.5 0.5,2.5 -0.5,1.5 -0.5))\n\
17+
POLYGON((-0.5 1.5,-0.5 2.5,0.5 2.5,0.5 1.5,-0.5 1.5))\n\
18+
POLYGON((1.5 1.5,1.5 2.5,2.5 2.5,2.5 1.5,1.5 1.5))\n\
19+
";
20+
21+
let output = tool("pack")
22+
.arg("--width=4")
23+
.write_stdin(input)
24+
.captured_output();
25+
assert!(output.status.success());
26+
let stdout = String::from_utf8_lossy(&output.stdout);
27+
assert_eq!(expected, stdout);
28+
}

0 commit comments

Comments
 (0)