Skip to content

Commit

Permalink
Swap to use debug snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
HHogg committed Dec 14, 2024
1 parent b1dda8f commit 0830daf
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 237 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::f64;

use insta::assert_json_snapshot;
use insta::assert_debug_snapshot;

use crate::{geometry::Polygon, notation::Shape};

Expand All @@ -9,21 +9,21 @@ use super::*;
#[test]
fn creates_an_empty_convex_hull_from_0_line_segments() {
// 0 line_segments
assert_json_snapshot!(ConvexHull::from_line_segments([].iter()));
assert_debug_snapshot!(ConvexHull::from_line_segments([].iter()));
}

#[test]
fn creates_an_empty_convex_hull_from_1_line_segments() {
// 1 line_segment
assert_json_snapshot!(ConvexHull::from_line_segments(
assert_debug_snapshot!(ConvexHull::from_line_segments(
[LineSegment::default()].iter()
));
}

#[test]
fn creates_an_empty_convex_hull_from_2_line_segments() {
// 2 line_segments
assert_json_snapshot!(ConvexHull::from_line_segments(
assert_debug_snapshot!(ConvexHull::from_line_segments(
[LineSegment::default(), LineSegment::default()].iter()
));
}
Expand All @@ -32,35 +32,35 @@ fn creates_an_empty_convex_hull_from_2_line_segments() {
fn orders_points_correctly_from_triangle_line_segments() {
let polygon = Polygon::default().with_shape(Shape::Triangle).at_center();

assert_json_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
assert_debug_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
}

#[test]
fn orders_points_correctly_from_square_line_segments() {
let polygon = Polygon::default().with_shape(Shape::Square).at_center();

assert_json_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
assert_debug_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
}

#[test]
fn orders_points_correctly_from_hexagon_line_segments() {
let polygon = Polygon::default().with_shape(Shape::Hexagon).at_center();

assert_json_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
assert_debug_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
}

#[test]
fn orders_points_correctly_from_octagon_line_segments() {
let polygon = Polygon::default().with_shape(Shape::Hexagon).at_center();

assert_json_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
assert_debug_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
}

#[test]
fn orders_points_correctly_from_dodecagon_line_segments() {
let polygon = Polygon::default().with_shape(Shape::Dodecagon).at_center();

assert_json_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
assert_debug_snapshot!(ConvexHull::from_line_segments(polygon.line_segments.iter()));
}

#[test]
Expand All @@ -70,7 +70,7 @@ fn finds_line_segments_for_vector_terminal_points_top() {
let polygon = Polygon::default().with_shape(Shape::Square).at_center();
let convex_hull = ConvexHull::from_line_segments(polygon.line_segments.iter());

assert_json_snapshot!(convex_hull.find_line_segment(
assert_debug_snapshot!(convex_hull.find_line_segment(
Point::default()
.with_x(0.0)
.with_y(-1.0)
Expand All @@ -83,7 +83,7 @@ fn finds_line_segments_for_vector_terminal_points_right() {
let polygon = Polygon::default().with_shape(Shape::Square).at_center();
let convex_hull = ConvexHull::from_line_segments(polygon.line_segments.iter());

assert_json_snapshot!(convex_hull.find_line_segment(
assert_debug_snapshot!(convex_hull.find_line_segment(
Point::default()
.with_x(0.0)
.with_y(-1.0)
Expand All @@ -96,7 +96,7 @@ fn finds_line_segments_for_vector_terminal_points_bottom() {
let polygon = Polygon::default().with_shape(Shape::Square).at_center();
let convex_hull = ConvexHull::from_line_segments(polygon.line_segments.iter());

assert_json_snapshot!(convex_hull.find_line_segment(
assert_debug_snapshot!(convex_hull.find_line_segment(
Point::default()
.with_x(0.0)
.with_y(-1.0)
Expand All @@ -109,7 +109,7 @@ fn finds_line_segments_for_vector_terminal_points_left() {
let polygon = Polygon::default().with_shape(Shape::Square).at_center();
let convex_hull = ConvexHull::from_line_segments(polygon.line_segments.iter());

assert_json_snapshot!(convex_hull.find_line_segment(
assert_debug_snapshot!(convex_hull.find_line_segment(
Point::default()
.with_x(0.0)
.with_y(-1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "ConvexHull::from_line_segments([].iter())"
---
{
"points": []
ConvexHull {
points: [],
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "ConvexHull::from_line_segments([LineSegment::default()].iter())"
---
{
"points": []
ConvexHull {
points: [],
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "ConvexHull::from_line_segments([LineSegment::default(),\nLineSegment::default()].iter())"
---
{
"points": []
ConvexHull {
points: [],
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "convex_hull.find_line_segment(Point::default().with_x(0.0).with_y(-1.0).rotate(f64::consts::PI,\nNone))"
---
{
"start": {
"x": 0.7071067811865476,
"y": 0.7071067811865475,
"index": 0
},
"end": {
"x": -0.7071067811865475,
"y": 0.7071067811865476,
"index": 1
}
}
Some(
LineSegment {
start: Point {
x: 0.7071067811865476,
y: 0.7071067811865475,
index: 0,
},
end: Point {
x: -0.7071067811865475,
y: 0.7071067811865476,
index: 1,
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "convex_hull.find_line_segment(Point::default().with_x(0.0).with_y(-1.0).rotate(f64::consts::PI\n* 1.5, None))"
---
{
"start": {
"x": -0.7071067811865475,
"y": 0.7071067811865476,
"index": 1
},
"end": {
"x": -0.7071067811865477,
"y": -0.7071067811865474,
"index": 2
}
}
Some(
LineSegment {
start: Point {
x: -0.7071067811865475,
y: 0.7071067811865476,
index: 1,
},
end: Point {
x: -0.7071067811865477,
y: -0.7071067811865474,
index: 2,
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "convex_hull.find_line_segment(Point::default().with_x(0.0).with_y(-1.0).rotate(f64::consts::PI\n* 0.5, None))"
---
{
"start": {
"x": 0.7071067811865474,
"y": -0.7071067811865477,
"index": 3
},
"end": {
"x": 0.7071067811865476,
"y": 0.7071067811865475,
"index": 0
}
}
Some(
LineSegment {
start: Point {
x: 0.7071067811865474,
y: -0.7071067811865477,
index: 3,
},
end: Point {
x: 0.7071067811865476,
y: 0.7071067811865475,
index: 0,
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "convex_hull.find_line_segment(Point::default().with_x(0.0).with_y(-1.0).rotate(f64::consts::PI\n* 0.0, None))"
---
{
"start": {
"x": -0.7071067811865477,
"y": -0.7071067811865474,
"index": 2
},
"end": {
"x": 0.7071067811865474,
"y": -0.7071067811865477,
"index": 3
}
}
Some(
LineSegment {
start: Point {
x: -0.7071067811865477,
y: -0.7071067811865474,
index: 2,
},
end: Point {
x: 0.7071067811865474,
y: -0.7071067811865477,
index: 3,
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,67 @@
source: workspaces/tilings/src-rust/tiling/src/geometry/./convex_hull_tests.rs
expression: "ConvexHull::from_line_segments(polygon.line_segments.iter())"
---
{
"points": [
{
"x": -0.2588190451025207,
"y": 0.9659258262890683,
"index": 3
},
{
"x": -0.7071067811865474,
"y": 0.7071067811865477,
"index": 4
},
{
"x": -0.9659258262890682,
"y": 0.2588190451025212,
"index": 5
},
{
"x": -0.9659258262890683,
"y": -0.25881904510252063,
"index": 6
},
{
"x": -0.7071067811865477,
"y": -0.7071067811865474,
"index": 7
},
{
"x": -0.2588190451025213,
"y": -0.9659258262890681,
"index": 8
},
{
"x": 0.2588190451025206,
"y": -0.9659258262890683,
"index": 9
},
{
"x": 0.707106781186547,
"y": -0.7071067811865481,
"index": 10
},
{
"x": 0.9659258262890681,
"y": -0.2588190451025213,
"index": 11
},
{
"x": 0.9659258262890683,
"y": 0.25881904510252074,
"index": 0
},
{
"x": 0.7071067811865476,
"y": 0.7071067811865475,
"index": 1
},
{
"x": 0.2588190451025209,
"y": 0.9659258262890682,
"index": 2
}
]
ConvexHull {
points: [
Point {
x: -0.2588190451025207,
y: 0.9659258262890683,
index: 3,
},
Point {
x: -0.7071067811865474,
y: 0.7071067811865477,
index: 4,
},
Point {
x: -0.9659258262890682,
y: 0.2588190451025212,
index: 5,
},
Point {
x: -0.9659258262890683,
y: -0.25881904510252063,
index: 6,
},
Point {
x: -0.7071067811865477,
y: -0.7071067811865474,
index: 7,
},
Point {
x: -0.2588190451025213,
y: -0.9659258262890681,
index: 8,
},
Point {
x: 0.2588190451025206,
y: -0.9659258262890683,
index: 9,
},
Point {
x: 0.707106781186547,
y: -0.7071067811865481,
index: 10,
},
Point {
x: 0.9659258262890681,
y: -0.2588190451025213,
index: 11,
},
Point {
x: 0.9659258262890683,
y: 0.25881904510252074,
index: 0,
},
Point {
x: 0.7071067811865476,
y: 0.7071067811865475,
index: 1,
},
Point {
x: 0.2588190451025209,
y: 0.9659258262890682,
index: 2,
},
],
}
Loading

0 comments on commit 0830daf

Please sign in to comment.