From 0c899acf53642fb43710ede3a5e1186985028047 Mon Sep 17 00:00:00 2001 From: Valeriy Van Date: Fri, 19 Jul 2024 15:13:59 +0300 Subject: [PATCH] Move test for defaultEnergyFunction into separate file --- Tests/geometrizeTests/CoreTests.swift | 38 ---------------- .../defaultEnergyFunctionTests.swift | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 Tests/geometrizeTests/defaultEnergyFunctionTests.swift diff --git a/Tests/geometrizeTests/CoreTests.swift b/Tests/geometrizeTests/CoreTests.swift index 5fcd0e6..d539c35 100644 --- a/Tests/geometrizeTests/CoreTests.swift +++ b/Tests/geometrizeTests/CoreTests.swift @@ -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( diff --git a/Tests/geometrizeTests/defaultEnergyFunctionTests.swift b/Tests/geometrizeTests/defaultEnergyFunctionTests.swift new file mode 100644 index 0000000..5ad5094 --- /dev/null +++ b/Tests/geometrizeTests/defaultEnergyFunctionTests.swift @@ -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) + } + +}