Skip to content

Adopt new XCTAssertEqualWithAccuracy spelling in the tests. #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions TestFoundation/TestNSAffineTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ class TestNSAffineTransform : XCTestCase {

func checkPointTransformation(_ transform: NSAffineTransform, point: NSPoint, expectedPoint: NSPoint, _ message: String = "", file: StaticString = #file, line: UInt = #line) {
let newPoint = transform.transform(point)
XCTAssertEqualWithAccuracy(Double(newPoint.x), Double(expectedPoint.x), accuracy: accuracyThreshold,
"x (expected: \(expectedPoint.x), was: \(newPoint.x)): \(message)", file: file, line: line)
XCTAssertEqualWithAccuracy(Double(newPoint.y), Double(expectedPoint.y), accuracy: accuracyThreshold,
"y (expected: \(expectedPoint.y), was: \(newPoint.y)): \(message)", file: file, line: line)
XCTAssertEqual(Double(newPoint.x), Double(expectedPoint.x), accuracy: accuracyThreshold,
"x (expected: \(expectedPoint.x), was: \(newPoint.x)): \(message)", file: file, line: line)
XCTAssertEqual(Double(newPoint.y), Double(expectedPoint.y), accuracy: accuracyThreshold,
"y (expected: \(expectedPoint.y), was: \(newPoint.y)): \(message)", file: file, line: line)
}

func checkSizeTransformation(_ transform: NSAffineTransform, size: NSSize, expectedSize: NSSize, _ message: String = "", file: StaticString = #file, line: UInt = #line) {
let newSize = transform.transform(size)
XCTAssertEqualWithAccuracy(Double(newSize.width), Double(expectedSize.width), accuracy: accuracyThreshold,
"width (expected: \(expectedSize.width), was: \(newSize.width)): \(message)", file: file, line: line)
XCTAssertEqualWithAccuracy(Double(newSize.height), Double(expectedSize.height), accuracy: accuracyThreshold,
"height (expected: \(expectedSize.height), was: \(newSize.height)): \(message)", file: file, line: line)
XCTAssertEqual(Double(newSize.width), Double(expectedSize.width), accuracy: accuracyThreshold,
"width (expected: \(expectedSize.width), was: \(newSize.width)): \(message)", file: file, line: line)
XCTAssertEqual(Double(newSize.height), Double(expectedSize.height), accuracy: accuracyThreshold,
"height (expected: \(expectedSize.height), was: \(newSize.height)): \(message)", file: file, line: line)
}

func checkRectTransformation(_ transform: NSAffineTransform, rect: NSRect, expectedRect: NSRect, _ message: String = "", file: StaticString = #file, line: UInt = #line) {
Expand All @@ -74,13 +74,13 @@ class TestNSAffineTransform : XCTestCase {

// The diagonal entries (1,1) and (2,2) of the identity matrix are ones. The other entries are zeros.
// TODO: These should use DBL_MAX but it's not available as part of Glibc on Linux
XCTAssertEqualWithAccuracy(Double(transformStruct.m11), Double(1), accuracy: accuracyThreshold)
XCTAssertEqualWithAccuracy(Double(transformStruct.m22), Double(1), accuracy: accuracyThreshold)
XCTAssertEqual(Double(transformStruct.m11), Double(1), accuracy: accuracyThreshold)
XCTAssertEqual(Double(transformStruct.m22), Double(1), accuracy: accuracyThreshold)

XCTAssertEqualWithAccuracy(Double(transformStruct.m12), Double(0), accuracy: accuracyThreshold)
XCTAssertEqualWithAccuracy(Double(transformStruct.m21), Double(0), accuracy: accuracyThreshold)
XCTAssertEqualWithAccuracy(Double(transformStruct.tX), Double(0), accuracy: accuracyThreshold)
XCTAssertEqualWithAccuracy(Double(transformStruct.tY), Double(0), accuracy: accuracyThreshold)
XCTAssertEqual(Double(transformStruct.m12), Double(0), accuracy: accuracyThreshold)
XCTAssertEqual(Double(transformStruct.m21), Double(0), accuracy: accuracyThreshold)
XCTAssertEqual(Double(transformStruct.tX), Double(0), accuracy: accuracyThreshold)
XCTAssertEqual(Double(transformStruct.tY), Double(0), accuracy: accuracyThreshold)
}

func test_IdentityTransformation() {
Expand Down
4 changes: 2 additions & 2 deletions TestFoundation/TestNSProgressFraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TestProgressFraction : XCTestCase {
expectedResult = expectedResult + 1.0 / Double(d)
}

XCTAssertEqualWithAccuracy(fractionResult, expectedResult, accuracy: 0.00001)
XCTAssertEqual(fractionResult, expectedResult, accuracy: 0.00001)
}

func test_addOverflow() {
Expand All @@ -126,7 +126,7 @@ class TestProgressFraction : XCTestCase {
// And it should have completed value of about 1.0/4.0 + f1.fractionCompleted
let expected = (1.0 / 4.0) + f1.fractionCompleted

XCTAssertEqualWithAccuracy(expected, f2.fractionCompleted, accuracy: 0.00001)
XCTAssertEqual(expected, f2.fractionCompleted, accuracy: 0.00001)
}

func test_andAndSubtractOverflow() {
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestNSTimer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestNSTimer : XCTestCase {
XCTAssertEqual(timer.timeInterval, interval)

let currentInterval = Date().timeIntervalSince1970
XCTAssertEqualWithAccuracy(currentInterval, previousInterval + interval, accuracy: 0.01)
XCTAssertEqual(currentInterval, previousInterval + interval, accuracy: 0.01)
previousInterval = currentInterval

flag += 1
Expand Down
60 changes: 30 additions & 30 deletions TestFoundation/TestProgress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TestProgress : XCTestCase {

// Test self
parent.completedUnitCount = 50
XCTAssertEqualWithAccuracy(0.5, parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(0.5, parent.fractionCompleted, accuracy: 0.01)

parent.completedUnitCount = 0
// Test child
Expand All @@ -53,24 +53,24 @@ class TestProgress : XCTestCase {
child1.completedUnitCount = 50

// half of 10% is done in parent
XCTAssertEqualWithAccuracy(0.05, parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqualWithAccuracy(0.5, child1.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(0.05, parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(0.5, child1.fractionCompleted, accuracy: 0.01)

// Up the total amount of work
parent.totalUnitCount = 200

XCTAssertEqualWithAccuracy(0.5 * (10.0 / 200.0) /* 0.025 */, parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqualWithAccuracy(0.5, child1.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(0.5 * (10.0 / 200.0) /* 0.025 */, parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(0.5, child1.fractionCompleted, accuracy: 0.01)

// Change the total in the child, doubling total amount of work
child1.totalUnitCount = 200
XCTAssertEqualWithAccuracy(50.0 / 200.0, child1.fractionCompleted, accuracy: 0.01)
XCTAssertEqualWithAccuracy((50.0 / 200.0) * (10.0 / 200), parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(50.0 / 200.0, child1.fractionCompleted, accuracy: 0.01)
XCTAssertEqual((50.0 / 200.0) * (10.0 / 200), parent.fractionCompleted, accuracy: 0.01)

// Change the total in the child, the other direction, halving the amount of work
child1.totalUnitCount = 100
XCTAssertEqualWithAccuracy(50.0 / 100.0, child1.fractionCompleted, accuracy: 0.01)
XCTAssertEqualWithAccuracy((50.0 / 100.0) * (10.0 / 200), parent.fractionCompleted, accuracy: 0.01)
XCTAssertEqual(50.0 / 100.0, child1.fractionCompleted, accuracy: 0.01)
XCTAssertEqual((50.0 / 100.0) * (10.0 / 200), parent.fractionCompleted, accuracy: 0.01)
}

func test_multipleChildren() {
Expand All @@ -84,19 +84,19 @@ class TestProgress : XCTestCase {
let child1 = Progress(totalUnitCount: 5)
let child2 = Progress(totalUnitCount: 5)

XCTAssertEqualWithAccuracy(progress.fractionCompleted, 0, accuracy: 0.01)
XCTAssertEqual(progress.fractionCompleted, 0, accuracy: 0.01)

child2.completedUnitCount = 5

// Child2 does not affect the parent's fraction completed (it should only be child1 that makes a difference)
XCTAssertEqualWithAccuracy(progress.fractionCompleted, 0, accuracy: 0.01)
XCTAssertEqual(progress.fractionCompleted, 0, accuracy: 0.01)

let _ = Progress(totalUnitCount: 5)
XCTAssertEqualWithAccuracy(progress.fractionCompleted, 0, accuracy: 0.01)
XCTAssertEqual(progress.fractionCompleted, 0, accuracy: 0.01)

// Update child #1
child1.completedUnitCount = 5
XCTAssertEqualWithAccuracy(progress.fractionCompleted, 1.0, accuracy: 0.01)
XCTAssertEqual(progress.fractionCompleted, 1.0, accuracy: 0.01)
}

func test_indeterminateChildrenAffectFractionCompleted() {
Expand All @@ -107,23 +107,23 @@ class TestProgress : XCTestCase {
let child1 = Progress(totalUnitCount: 10)

child1.completedUnitCount = 5
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.05, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.05, accuracy: 0.01)

// Child1 becomes indeterminate
child1.completedUnitCount = -1
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.0, accuracy: 0.01)

// Become determinate
// childProgress1's completed unit count is 100% of its total of 10 (10)
// childProgress1 is 10% of the overall unit count (100 / 1000)
// the overall count done should be 100% of 10% of 1000, or 1.0 * 0.1 * 1000 = 100
// the overall percentage done should be 100 / 1000 = 0.1
child1.completedUnitCount = 10
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.1, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.1, accuracy: 0.01)

// Become indeterminate again
child1.completedUnitCount = -1
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.0, accuracy: 0.01)

parent.resignCurrent()
}
Expand All @@ -140,21 +140,21 @@ class TestProgress : XCTestCase {
let child2 = Progress(totalUnitCount: 2)
parent.resignCurrent()

XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.0, accuracy: 0.01)

child1.completedUnitCount = 1
child2.completedUnitCount = 1

// half done
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.5, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.5, accuracy: 0.01)

// Move a child to indeterminate
child1.completedUnitCount = -1
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.25, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.25, accuracy: 0.01)

// Move it back to determinate
child1.completedUnitCount = 1
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 0.5, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 0.5, accuracy: 0.01)
}

func test_childCompletionFinishesGroups() {
Expand All @@ -166,10 +166,10 @@ class TestProgress : XCTestCase {
root.addChild(child2, withPendingUnitCount: 1)

child1.completedUnitCount = 1
XCTAssertEqualWithAccuracy(root.fractionCompleted, 0.5, accuracy: 0.01)
XCTAssertEqual(root.fractionCompleted, 0.5, accuracy: 0.01)

child2.completedUnitCount = 1
XCTAssertEqualWithAccuracy(root.fractionCompleted, 1.0, accuracy: 0.01)
XCTAssertEqual(root.fractionCompleted, 1.0, accuracy: 0.01)
XCTAssertEqual(root.completedUnitCount, 2)
}

Expand Down Expand Up @@ -296,38 +296,38 @@ class TestProgress : XCTestCase {

// child1 is half done. This means the parent is half of 1/3 done.
child1.completedUnitCount = 5
XCTAssertEqualWithAccuracy(parent.fractionCompleted, (1.0 / 3.0) / 2.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, (1.0 / 3.0) / 2.0, accuracy: 0.01)

// child2 is half done. This means the parent is (half of 1/3 done) + (half of 1/3 done).
child2.completedUnitCount = 5
XCTAssertEqualWithAccuracy(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) * 2.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) * 2.0, accuracy: 0.01)

// add an implict child
parent.becomeCurrent(withPendingUnitCount: 1)
let child3 = Progress(totalUnitCount: 10)
parent.resignCurrent()

// Total completed of parent should not change
XCTAssertEqualWithAccuracy(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) * 2.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) * 2.0, accuracy: 0.01)

// child3 is half done. This means the parent is (half of 1/3 done) * 3.
child3.completedUnitCount = 5
XCTAssertEqualWithAccuracy(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) * 3.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) * 3.0, accuracy: 0.01)

// Finish child3
child3.completedUnitCount = 10
XCTAssertTrue(child3.isFinished)
XCTAssertEqualWithAccuracy(parent.fractionCompleted, (((1.0 / 3.0) / 2.0) * 2.0) + (1.0 / 3.0), accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, (((1.0 / 3.0) / 2.0) * 2.0) + (1.0 / 3.0), accuracy: 0.01)

// Finish child2
child2.completedUnitCount = 10;
XCTAssertTrue(child2.isFinished)
XCTAssertEqualWithAccuracy(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) + ((1.0 / 3.0) * 2.0), accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, ((1.0 / 3.0) / 2.0) + ((1.0 / 3.0) * 2.0), accuracy: 0.01)

// Finish child1
child1.completedUnitCount = 10;
XCTAssertTrue(child1.isFinished)
XCTAssertEqualWithAccuracy(parent.fractionCompleted, 1.0, accuracy: 0.01)
XCTAssertEqual(parent.fractionCompleted, 1.0, accuracy: 0.01)
XCTAssertTrue(parent.isFinished)
XCTAssertEqual(parent.completedUnitCount, parent.totalUnitCount)

Expand Down
Loading