-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move test for defaultEnergyFunction into separate file
- Loading branch information
1 parent
f5a4073
commit 0c899ac
Showing
2 changed files
with
44 additions
and
38 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
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,44 @@ | ||
import XCTest | ||
@testable import Geometrize | ||
|
||
final class DefaultEnergyFunctionTests: XCTestCase { | ||
|
||
func testDefaultEnergyFunctionComparingResultWithCPlusPlus() throws { | ||
let scanlines = try [Scanline]( | ||
stringBundleResource: "defaultEnergyFunction scanlines", | ||
withExtension: "txt" | ||
) | ||
let bitmapTarget = try Bitmap( | ||
ppmBundleResource: "defaultEnergyFunction target bitmap", | ||
withExtension: "ppm" | ||
) | ||
let bitmapCurrent = try Bitmap( | ||
ppmBundleResource: "defaultEnergyFunction current bitmap", | ||
withExtension: "ppm" | ||
) | ||
var bitmapBuffer = try Bitmap( | ||
ppmBundleResource: "defaultEnergyFunction buffer bitmap", | ||
withExtension: "ppm" | ||
) | ||
let bitmapBufferOnExit = try Bitmap( | ||
ppmBundleResource: "defaultEnergyFunction buffer bitmap on exit", | ||
withExtension: "ppm" | ||
) | ||
|
||
XCTAssertEqual( | ||
defaultEnergyFunction( | ||
scanlines, | ||
128 /* alpha */, | ||
bitmapTarget, | ||
bitmapCurrent, | ||
&bitmapBuffer, | ||
0.162824 | ||
), | ||
0.162776, | ||
accuracy: 0.000001 | ||
) | ||
|
||
XCTAssertEqual(bitmapBuffer, bitmapBufferOnExit) | ||
} | ||
|
||
} |