Skip to content

Commit

Permalink
- Line length fix
Browse files Browse the repository at this point in the history
- Assure error.localizedDescription populated properly tests assertion
  • Loading branch information
anton-plebanovich committed Nov 15, 2017
1 parent 3dcc1c4 commit cc3854c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
5 changes: 4 additions & 1 deletion AssimpKit/Code/Model/AssimpImporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ - (SCNAssimpScene *)importScene:(NSString *)filePath

// Return error
if (error) {
*error = [NSError errorWithDomain:@"AssimpImporter" code:-1 userInfo:@{NSLocalizedDescriptionKey:errorString}];
*error = [NSError
errorWithDomain:@"AssimpImporter"
code:-1
userInfo:@{NSLocalizedDescriptionKey:errorString}];
}

return nil;
Expand Down
34 changes: 22 additions & 12 deletions AssimpKit/Code/Model/Tests/AssimpImporterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -825,29 +825,39 @@ - (void)checkModel:(NSString *)path testLog:(ModelLog *)testLog
{
const char *pFile = [path UTF8String];
const struct aiScene *aiScene = aiImportFile(pFile, aiProcess_FlipUVs);
// If the import failed, report it

NSError *error = nil;
AssimpImporter *importer = [[AssimpImporter alloc] init];
SCNAssimpScene *scene =
[importer importScene:path
postProcessFlags:AssimpKit_Process_FlipUVs |
AssimpKit_Process_Triangulate
error:&error];

// If the import failed, report it and assure error.localizedDescription
// populated properly
if (!aiScene)
{
NSString *errorString =
[NSString stringWithUTF8String:aiGetErrorString()];

XCTAssertEqualObjects(errorString, error.localizedDescription,
@" Expected error.localizedDescription (%@)\
to equal to aiGetErrorString() (%@)",
error.localizedDescription,
errorString);

[testLog addErrorLog:errorString];
return;
}

AssimpImporter *importer = [[AssimpImporter alloc] init];
SCNAssimpScene *scene =
[importer importScene:path
postProcessFlags:AssimpKit_Process_FlipUVs |
AssimpKit_Process_Triangulate
error:nil];

NSLog(@" SCENE Root node: %@ with children: %lu", scene.rootNode,
(unsigned long)scene.rootNode.childNodes.count);
[self checkNode:aiScene->mRootNode
withSceneNode:[scene.modelScene.rootNode.childNodes objectAtIndex:0]
aiScene:aiScene
modelPath:path
testLog:testLog];
withSceneNode:[scene.modelScene.rootNode.childNodes objectAtIndex:0]
aiScene:aiScene
modelPath:path
testLog:testLog];

// [self checkLights:aiScene withScene:scene.modelScene testLog:testLog];

Expand Down

0 comments on commit cc3854c

Please sign in to comment.