Added tests for `log2`

This commit is contained in:
Vincent Esche 2019-09-24 18:01:48 +02:00
parent a85b50231b
commit 055d1c3c7f
1 changed files with 32 additions and 0 deletions

View File

@ -58,4 +58,36 @@ class LofarithmTests: XCTestCase {
XCTAssertEqual(actual, expected, accuracy: 1e-8)
}
// MARK: - Base-2 Logarithm
func test_log2_array_float() {
typealias Scalar = Float
let lhs: [Scalar] = (1...n).map { Scalar($0) / Scalar(n) }
var actual: [Scalar] = []
measure {
actual = Surge.log2(lhs)
}
let expected = lhs.map { log2($0) }
XCTAssertEqual(actual, expected, accuracy: 1e-4)
}
func test_log2_array_double() {
typealias Scalar = Double
let lhs: [Scalar] = (1...n).map { Scalar($0) / Scalar(n) }
var actual: [Scalar] = []
measure {
actual = Surge.log2(lhs)
}
let expected = lhs.map { log2($0) }
XCTAssertEqual(actual, expected, accuracy: 1e-8)
}
}