Skip to content

Commit

Permalink
Add Rectangle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed May 13, 2024
1 parent 6ae4297 commit 6103094
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/geometry.zig
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ pub fn Rectangle(comptime T: type) type {
};
}

test "Rectangle" {
const irect = Rectangle(isize){ .l = 0, .t = 0, .r = 639, .b = 479 };
try expectEqual(irect.width(), 640);
try expectEqual(irect.height(), 480);
const frect = Rectangle(f64){ .l = 0, .t = 0, .r = 639, .b = 479 };
try expectEqual(frect.width(), 640);
try expectEqual(frect.height(), 480);
try expectEqual(frect.contains(640 / 2, 480 / 2), true);
try expectEqual(irect.contains(640, 480), false);
try expectEqualDeep(frect.cast(isize), irect);
}

/// Applies a projective transform to a point. By default, it will be initialized to the identity
/// function. Use the fit method to update the transform to map between two sets of points.
pub fn ProjectiveTransform(comptime T: type) type {
Expand Down

0 comments on commit 6103094

Please sign in to comment.