forked from dmtrKovalenko/odiff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caddc42
commit 66df589
Showing
12 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
open TestFramework; | ||
|
||
describe("Png comparing", ({test, _}) => { | ||
test("finds different between 2 images", ({expect, _}) => { | ||
let img1 = Odiff.ImageIO.loadImage("test/test-images/orange.png"); | ||
let img2 = Odiff.ImageIO.loadImage("test/test-images/orange_changed.png"); | ||
|
||
let diffOutput = Rgba32.copy(img1); | ||
|
||
let diffPixels = Odiff.Diff.compare(img1, img2, diffOutput, ()); | ||
expect.int(diffPixels).toBe(1430); | ||
}); | ||
|
||
test("uses provided threshold", ({expect, _}) => { | ||
let img1 = Odiff.ImageIO.loadImage("test/test-images/orange.png"); | ||
let img2 = Odiff.ImageIO.loadImage("test/test-images/orange_changed.png"); | ||
|
||
let diffOutput = Rgba32.copy(img1); | ||
|
||
let diffPixels = | ||
Odiff.Diff.compare(img1, img2, diffOutput, ~threshold=1.0, ()); | ||
expect.int(diffPixels).toBe(184); | ||
}); | ||
|
||
test("create right diff mask", ({expect, _}) => { | ||
let img1 = Odiff.ImageIO.loadImage("test/test-images/orange.png"); | ||
let img2 = Odiff.ImageIO.loadImage("test/test-images/orange_changed.png"); | ||
|
||
let diffOutput = Rgba32.create(img1.width, img1.height); | ||
Odiff.Diff.compare(img1, img2, diffOutput, ()) |> ignore; | ||
|
||
let originalDiff = | ||
Odiff.ImageIO.loadImage("test/test-images/orange-diff.png"); | ||
let diffMaskOfDiff = | ||
Rgba32.create(originalDiff.width, originalDiff.height); | ||
|
||
let diffOfDiffPixels = | ||
Odiff.Diff.compare(originalDiff, diffOutput, diffMaskOfDiff, ()); | ||
|
||
expect.int(diffOfDiffPixels).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OdiffTests.TestFramework.cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include Rely.Make({ | ||
let config = | ||
Rely.TestFrameworkConfig.initialize({ | ||
snapshotDir: "test/__snapshots__", | ||
projectDir: "." | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(library | ||
(name OdiffTests) | ||
; the linkall flag ensures that all of our tests are compiled and the | ||
; -g flag emits debugging information | ||
(ocamlopt_flags -linkall -g) | ||
; you will want to depend on the library you are testing as well, however for | ||
; the purposes of this example we are only depending on the test runner itself | ||
(libraries rely.lib odiff) | ||
(modules (:standard \ RunTests)) | ||
) | ||
(executable | ||
; the for the library is automatically detected because of the name, but we | ||
; need to explicitly specify the package here | ||
(package odiff) | ||
(name RunTests) | ||
(public_name RunTests.exe) | ||
(libraries | ||
OdiffTests | ||
) | ||
(modules RunTests) | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.