Reputation: 31486
I'm trying to figure out how to rewrite the following Objective-C unit-test in Swift:
- (void)testSuperclass {
Class superclass = [self.animatedView superclass];
Class expectedSuperclass = [BREAnimatedView class];
XCTAssertEqualObjects(superclass, expectedSuperclass);
}
Upvotes: 1
Views: 508
Reputation: 5655
I believe this should work:
func testSuperclass() {
XCTAssert(self.animatedView is BREAnimatedView)
}
It's slightly different than your original condition, which tests if BREAnimatedView
is the direct superclass of the view, whereas this just tests if the view inherits from BREAnimatedView
.
Upvotes: 1
Reputation: 108101
I suppose you can do
func testSuperclass() {
val superclass = self.animatedView.superclass
val expectedSuperclass = BREAnimatedView.class()
XCTAssertEqualObjects(superclass, expectedSuperclass)
}
but I'd be glad to see if there's a better way.
Upvotes: 0