Skip to content

Commit

Permalink
Add (failing) validation suite
Browse files Browse the repository at this point in the history
---- tests::test_all_general stdout ----
thread 'tests::test_all_general' panicked at '2 failures / 1726 successes in JTS test suite:
failed TestRelatePL.xml case "P/L-2: a point and a zero-length line" with error: expected IntersectionMatrix(0FFFFFFF2), actual: IntersectionMatrix(0FFFFF1F2)
failed TestRelatePL.xml case "P/L-2: a point and a zero-length line" with error: expected true, relate_actual: false', jts-test-runner/src/lib.rs:65:13
  • Loading branch information
michaelkirk committed Jul 28, 2022
1 parent a2d0a13 commit 95cb192
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
32 changes: 16 additions & 16 deletions jts-test-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,26 @@ mod tests {
let mut runner = TestRunner::new().with_overlay_precision_floating();
runner.run().expect("test cases failed");

if !runner.failures().is_empty() {
let failure_text = runner
.failures()
.iter()
.map(|failure| format!("{}", failure))
.collect::<Vec<String>>()
.join("\n");
panic!(
"{} failures / {} successes in JTS test suite:\n{}",
runner.failures().len(),
runner.successes().len(),
failure_text
);
}

// sanity check that the expected number of tests were run.
//
// We'll need to increase this number as more tests are added, but it should never be
// decreased.
let expected_test_count: usize = 274;
let expected_test_count: usize = 1728;
let actual_test_count = runner.failures().len() + runner.successes().len();
match actual_test_count.cmp(&expected_test_count) {
Ordering::Less => {
Expand All @@ -76,21 +91,6 @@ mod tests {
);
}
}

if !runner.failures().is_empty() {
let failure_text = runner
.failures()
.iter()
.map(|failure| format!("{}", failure))
.collect::<Vec<String>>()
.join("\n");
panic!(
"{} failures / {} successes in JTS test suite:\n{}",
runner.failures().len(),
runner.successes().len(),
failure_text
);
}
}

#[test]
Expand Down
13 changes: 8 additions & 5 deletions jts-test-runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use log::{debug, info};
use wkt::ToWkt;

use super::{input, Operation, Result};
use geo::{
BooleanOps, Contains, Coordinate, GeoNum, Geometry, HasDimensions, Intersects, LineString,
MultiPolygon, Polygon,
};
use geo::algorithm::{BooleanOps, Contains, HasDimensions, Intersects};
use geo::geometry::*;
use geo::GeoNum;

const GENERAL_TEST_XML: Dir = include_dir!("$CARGO_MANIFEST_DIR/resources/testxml/general");
const VALIDATE_TEST_XML: Dir = include_dir!("$CARGO_MANIFEST_DIR/resources/testxml/validate");

#[derive(Debug, Default, Clone)]
pub struct TestRunner {
Expand Down Expand Up @@ -492,7 +492,10 @@ impl TestRunner {
"**/*.xml".to_string()
};

for entry in GENERAL_TEST_XML.find(&filename_filter)? {
for entry in GENERAL_TEST_XML
.find(&filename_filter)?
.chain(VALIDATE_TEST_XML.find(&filename_filter)?)
{
let file = match entry {
DirEntry::Dir(_) => {
debug_assert!(false, "unexpectedly found dir.xml");
Expand Down

0 comments on commit 95cb192

Please sign in to comment.