Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ofmooseandmen committed Nov 27, 2023
1 parent 884d449 commit a99bf0e
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion src/spherical/rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Rectangle {
///
/// assert!(a.interior_contains_point(LatLong::from_degrees(10.0, 10.0)));
///
/// /// point on boundary
/// // point on boundary
/// assert!(!a.interior_contains_point(LatLong::from_degrees(30.0, 00.0)));
///
/// // latitude above north.
Expand Down Expand Up @@ -661,6 +661,22 @@ mod tests {

use super::Rectangle;

#[test]
fn full() {
assert!(Rectangle::FULL.is_full());
assert!(!Rectangle::FULL.is_empty());
assert!(Rectangle::FULL.contains_rectangle(Rectangle::EMPTY));
assert!(Rectangle::FULL.union(Rectangle::EMPTY).is_full());
}

#[test]
fn empty() {
assert!(Rectangle::EMPTY.is_empty());
assert!(!Rectangle::EMPTY.is_full());
assert!(!Rectangle::EMPTY.contains_rectangle(Rectangle::FULL));
assert!(Rectangle::EMPTY.union(Rectangle::FULL).is_full());
}

// cmp_by_latitude

#[test]
Expand Down Expand Up @@ -1069,6 +1085,35 @@ mod tests {
assert_eq!(expected, a.union(b) == a);
}

// interior_contains_rect

#[test]
fn interior_contains_rect() {
let a = Rectangle::from_nesw(
Angle::from_degrees(30.0),
Angle::from_degrees(30.0),
Angle::ZERO,
Angle::ZERO,
);

assert!(a.interior_contains_point(LatLong::from_degrees(10.0, 10.0)));

// point on boundary
assert!(!a.interior_contains_point(LatLong::from_degrees(30.0, 00.0)));

// latitude above north.
assert!(!a.interior_contains_point(LatLong::from_degrees(40.0, 10.0)));

// latitude below south.
assert!(!a.interior_contains_point(LatLong::from_degrees(-1.0, 10.0)));

// longitude after east.
assert!(!a.interior_contains_point(LatLong::from_degrees(10.0, 40.0)));

// longitude after west.
assert!(!a.interior_contains_point(LatLong::from_degrees(10.0, -10.0)));
}

// from_minor_arc

#[test]
Expand Down

0 comments on commit a99bf0e

Please sign in to comment.