Added tests for `log`

This commit is contained in:
Vincent Esche 2019-09-24 18:03:16 +02:00
parent ae6f5b21c1
commit b9fbf3f730
1 changed files with 31 additions and 0 deletions

View File

@ -27,4 +27,35 @@ import XCTest
class LofarithmTests: XCTestCase {
let n = 100_000
// MARK: - Base-e Logarithm
func test_log_array_float() {
typealias Scalar = Float
let lhs: [Scalar] = (1...n).map { Scalar($0) / Scalar(n) }
var actual: [Scalar] = []
measure {
actual = Surge.log(lhs)
}
let expected = lhs.map { log($0) }
XCTAssertEqual(actual, expected, accuracy: 1e-4)
}
func test_log_array_double() {
typealias Scalar = Double
let lhs: [Scalar] = (1...n).map { Scalar($0) / Scalar(n) }
var actual: [Scalar] = []
measure {
actual = Surge.log(lhs)
}
let expected = lhs.map { log($0) }
XCTAssertEqual(actual, expected, accuracy: 1e-8)
}
}