From bbe2fe5f4c3b65d0e32e0b7e49e1a9a72b52270f Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Thu, 21 Jul 2016 14:54:39 -0700 Subject: [PATCH] Add and fix tests for adding a nil subnode --- AsyncDisplayKitTests/ASDisplayNodeTests.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKitTests/ASDisplayNodeTests.m b/AsyncDisplayKitTests/ASDisplayNodeTests.m index e1efbe7b..9be86b49 100644 --- a/AsyncDisplayKitTests/ASDisplayNodeTests.m +++ b/AsyncDisplayKitTests/ASDisplayNodeTests.m @@ -1127,7 +1127,7 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point { ASDisplayNode *parent = [[[ASDisplayNode alloc] init] autorelease]; ASDisplayNode *nilNode = nil; - XCTAssertNoThrow([parent addSubnode:nilNode], @"Don't try to add nil, but we'll deal."); + XCTAssertThrows([parent addSubnode:nilNode], @"Don't try to add nil, but we'll deal with it in production, but throw in development."); XCTAssertNoThrow([parent addSubnode:parent], @"Not good, test that we recover"); XCTAssertEqual(0u, parent.subnodes.count, @"We shouldn't have any subnodes"); } @@ -1320,6 +1320,9 @@ static inline BOOL _CGPointEqualToPointWithEpsilon(CGPoint point1, CGPoint point XCTAssertEqual(3u, parent.subnodes.count, @"Should have the right subnode count"); XCTAssertEqualObjects(nilParent, d.supernode, @"d's parent is messed up"); + // Check insert a nil node + ASDisplayNode *nilNode = nil; + XCTAssertThrows([parent insertSubnode:nilNode atIndex:0], @"Should not allow insertion of nil node. We will throw in development and deal with it in production"); // Check insert at invalid index XCTAssertThrows([parent insertSubnode:d atIndex:NSNotFound], @"Should not allow insertion at invalid index");