Skip to content

Commit

Permalink
fixed tests. Enabled more tests for SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
ypopovych committed Aug 8, 2023
1 parent 105a15e commit 5ce5d0d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BigNumber.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ A lightweight, high performance bignum library for Swift for both intergers and
s.test_spec "BigNumberTests" do |ts|
ts.platforms = { :ios => "11.0", :osx => "10.11", :tvos => "11.0" }
ts.source_files = "Sources/MGTools/*.swift", "Tests/BigNumberTests/*.swift", "Tests/MGToolsTests/*.swift"
ts.resources = "Tests/BigNumberTests/Resources/*.json"
ts.resources = "Tests/BigNumberTests/Resources"
end

end
5 changes: 3 additions & 2 deletions Tests/BigNumberTests/BDoubleTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import XCTest
import Foundation
#if !COCOAPODS
@testable import MGTools
#endif
@testable import BigNumber

class BDoubleTests : XCTestCase {
Expand Down Expand Up @@ -178,7 +181,6 @@ class BDoubleTests : XCTestCase {
}
}

#if !SWIFT_PACKAGE
func test_decimalExpansionRandom()
{
func generateDoubleString(preDecimalCount: Int, postDecimalCount: Int) -> String
Expand Down Expand Up @@ -254,7 +256,6 @@ class BDoubleTests : XCTestCase {

}
}
#endif

func testRounding() {
XCTAssertEqual(BDouble("-1.0")?.rounded(), BInt("-1"))
Expand Down
3 changes: 3 additions & 0 deletions Tests/BigNumberTests/Test_BIntMath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import XCTest
#if !COCOAPODS
@testable import MGTools
#endif
@testable import BigNumber

class Test_BIntMath: XCTestCase {
Expand Down
11 changes: 3 additions & 8 deletions Tests/BigNumberTests/Test_Basic_Math.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import XCTest
#if !COCOAPODS
@testable import MGTools
#endif
@testable import BigNumber

class Test_Basic_Math: XCTestCase {
Expand All @@ -30,7 +33,6 @@ class Test_Basic_Math: XCTestCase {
let arithmetricInt: [(Int, Int ) -> Int ] = [(+), (-), (*), (/), (%)]
let arithmetricBInt: [(BInt, BInt) -> BInt] = [(+), (-), (*), (/), (%)]

#if !SWIFT_PACKAGE
for (_, i_op) in (0..<iterations)><(0..<arithmetricInt.count)
{
let (x, y) = (math.random((-m)...m), math.random((-m)...m))
Expand All @@ -39,7 +41,6 @@ class Test_Basic_Math: XCTestCase {
let resBInt = (arithmetricBInt[i_op])(BInt(x), BInt(y))
XCTAssert(resInt.description == resBInt.description)
}
#endif
}

func test_Comparison_Operators_BInt()
Expand All @@ -53,15 +54,13 @@ class Test_Basic_Math: XCTestCase {
let compareInt: [(Int, Int) -> Bool] = [(<), (<=), (>), (>=), (==), (!=)]
let compareBInt: [(BInt, BInt) -> Bool] = [(<), (<=), (>), (>=), (==), (!=)]

#if !SWIFT_PACKAGE
for (_, i_op) in (0..<iterations)><(0..<compareInt.count)
{
let (x, y) = (math.random((-m)...m), math.random((-m)...m))
let resInt = (compareInt[i_op])(x, y)
let resBInt = (compareBInt[i_op])(BInt(x), BInt(y))
XCTAssert(resInt == resBInt)
}
#endif
}

func test_Shift_Operators_BInt()
Expand All @@ -72,15 +71,13 @@ class Test_Basic_Math: XCTestCase {
let shiftInt: [(UInt64, UInt64) -> UInt64] = [(<<), (>>)]
let shiftBInt: [(BInt, Int) -> BInt ] = [(<<), (>>)]

#if !SWIFT_PACKAGE
for (_, i_op) in (0..<iterations)><(0..<shiftInt.count)
{
let (x, y) = (math.random(0...58), math.random(0...58))
let resInt = (shiftInt[i_op])(UInt64(x), UInt64(y))
let resBInt = (shiftBInt[i_op])(BInt(x), y)
XCTAssert(resInt == resBInt)
}
#endif
}

func test_Negation_BInt()
Expand Down Expand Up @@ -168,7 +165,6 @@ class Test_Basic_Math: XCTestCase {

func test_Arithmetric_Operators_BDouble()
{
#if !SWIFT_PACKAGE
for _ in 0..<1000
{
let a = math.random(-10...10)
Expand Down Expand Up @@ -244,7 +240,6 @@ class Test_Basic_Math: XCTestCase {
XCTAssert(BInt(sign: a1.sign, limbs: a1.numerator).description == String(a1Int))
}
}
#endif
}

func test_Power() {
Expand Down

0 comments on commit 5ce5d0d

Please sign in to comment.