1 // Copyright 2018 Google Inc. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 @testable import TensorFlowLite 16 import XCTest 17 18 class QuantizationParametersTests: XCTestCase { 19 testQuantizationParameters_InitWithCustomValuesnull20 func testQuantizationParameters_InitWithCustomValues() { 21 let parameters = QuantizationParameters(scale: 0.5, zeroPoint: 1) 22 XCTAssertEqual(parameters.scale, 0.5) 23 XCTAssertEqual(parameters.zeroPoint, 1) 24 } 25 testQuantizationParameters_Equatablenull26 func testQuantizationParameters_Equatable() { 27 let parameters1 = QuantizationParameters(scale: 0.5, zeroPoint: 1) 28 let parameters2 = QuantizationParameters(scale: 0.5, zeroPoint: 1) 29 XCTAssertEqual(parameters1, parameters2) 30 31 let parameters3 = QuantizationParameters(scale: 0.4, zeroPoint: 1) 32 XCTAssertNotEqual(parameters1, parameters3) 33 XCTAssertNotEqual(parameters2, parameters3) 34 } 35 } 36 37 // MARK: - Extensions 38 39 extension QuantizationParameters: Equatable { ==null40 public static func == (lhs: QuantizationParameters, rhs: QuantizationParameters) -> Bool { 41 return lhs.scale == rhs.scale && lhs.zeroPoint == rhs.zeroPoint 42 } 43 } 44