Skip to content

Commit

Permalink
Move test for defaultEnergyFunction into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyvan committed Jul 19, 2024
1 parent f5a4073 commit 0c899ac
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
38 changes: 0 additions & 38 deletions Tests/geometrizeTests/CoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,6 @@ import XCTest

final class CoreTests: 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)
}

// fails
func testHillClimbComparingResultWithCPlusPlus() throws { // swiftlint:disable:this function_body_length
let url = Bundle.module.url(
Expand Down
44 changes: 44 additions & 0 deletions Tests/geometrizeTests/defaultEnergyFunctionTests.swift
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)
}

}

0 comments on commit 0c899ac

Please sign in to comment.