Skip to content

Commit

Permalink
Update finder test
Browse files Browse the repository at this point in the history
  • Loading branch information
slackydev committed Jan 9, 2025
1 parent cab53c8 commit 8b7dd0c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tests/finder_color.simba
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{$assertions on}

// Very simple CountColor "test"
// - in case of small optimizations, or corrections this test can fail
// - I've added some tolerance of 0.1% of total pixels

const
TESTS := [
Expand All @@ -17,7 +19,7 @@ const
23403,
24717,
24713,
22031,
22999,
23668,
39849,
53443
Expand All @@ -28,14 +30,14 @@ var
I: Integer;
begin
Bitmap := TImage.Create(500, 500);
Bitmap.DrawHSLCircle(Bitmap.Center, 200);
Bitmap.DrawHSLCircle(Bitmap.Center, 200); // roughly 628300 pixels, so 0.1% error is 628

Target.SetImage(Bitmap);

for I := 0 to High(TESTS) do
begin
WriteLn(Target.CountColor(TESTS[I]), ' vs ', TEST_RESULTS[i]);
Assert(Target.CountColor(TESTS[I]) = TEST_RESULTS[I]);
Assert(Abs(Target.CountColor(TESTS[I]) - TEST_RESULTS[I]) < 629);
end;

Bitmap.Free();
Expand Down

0 comments on commit 8b7dd0c

Please sign in to comment.