-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathANKSigned+Negation.swift
55 lines (43 loc) · 1.79 KB
/
ANKSigned+Negation.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//=----------------------------------------------------------------------------=
// This source file is part of the AwesomeNumbersKit open source project.
//
// Copyright (c) 2022 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=
#if DEBUG
import ANKSignedKit
import XCTest
//*============================================================================*
// MARK: * ANK x Signed x Negation
//*============================================================================*
final class ANKSignedTestsOnNegation: XCTestCase {
typealias T = ANKSigned<UInt>
//=------------------------------------------------------------------------=
// MARK: Tests
//=------------------------------------------------------------------------=
func testNegating() {
ANKAssertNegation( T(1), -T(1))
ANKAssertNegation( T(0), -T(0))
ANKAssertNegation(-T(0), T(0))
ANKAssertNegation(-T(1), T(1))
}
func testNegatingReportingOverflow() {
ANKAssertNegation(T.max, T.min)
ANKAssertNegation(T.min, T.max)
}
//=------------------------------------------------------------------------=
// MARK: Tests x Miscellaneous
//=------------------------------------------------------------------------=
func testOverloadsAreUnambiguous() {
func becauseThisCompilesSuccessfully(_ x: inout T) {
XCTAssertNotNil(x.negate())
XCTAssertNotNil(x.negateReportingOverflow())
XCTAssertNotNil(-x)
XCTAssertNotNil(x.negated())
XCTAssertNotNil(x.negatedReportingOverflow())
}
}
}
#endif