Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (38 sloc) 2.094 kb
//
// GBObjectiveCParser-AdoptedProtocolsParsingTesting.m
// appledoc
//
// Created by Tomaz Kragelj on 25.7.10.
// Copyright (C) 2010 Gentle Bytes. All rights reserved.
//
#import "GBStore.h"
#import "GBDataObjects.h"
#import "GBObjectiveCParser.h"
// Note that we use class for invoking parsing of adopted protocols. Probably not the best option - i.e. we could isolate parsing code altogether and only parse relevant stuff here, but it seemed not much would be gained by doing this. Separating unit tests does avoid repetition in top-level objects testing code - we only need to test specific data there.
@interface GBObjectiveCParserAdoptedProtocolsParsingTesting : GBObjectsAssertor
@end
@implementation GBObjectiveCParserAdoptedProtocolsParsingTesting
- (void)testParseObjectsFromString_shouldRegisterAdoptedProtocol {
// setup
GBObjectiveCParser *parser = [GBObjectiveCParser parserWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
GBStore *store = [[GBStore alloc] init];
// execute
[parser parseObjectsFromString:@"@interface MyClass <MyProtocol> @end" sourceFile:@"filename.h" toStore:store];
// verify
NSArray *protocols = [[[[store classes] anyObject] adoptedProtocols] protocolsSortedByName];
assertThatInteger([protocols count], equalToInteger(1));
assertThat([[protocols objectAtIndex:0] nameOfProtocol], is(@"MyProtocol"));
}
- (void)testParseObjectsFromString_shouldRegisterAllAdoptedProtocols {
// setup
GBObjectiveCParser *parser = [GBObjectiveCParser parserWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
GBStore *store = [[GBStore alloc] init];
// execute
[parser parseObjectsFromString:@"@interface MyClass <MyProtocol1, MyProtocol2> @end" sourceFile:@"filename.h" toStore:store];
// verify
NSArray *protocols = [[[[store classes] anyObject] adoptedProtocols] protocolsSortedByName];
assertThatInteger([protocols count], equalToInteger(2));
assertThat([[protocols objectAtIndex:0] nameOfProtocol], is(@"MyProtocol1"));
assertThat([[protocols objectAtIndex:1] nameOfProtocol], is(@"MyProtocol2"));
}
@end
Jump to Line
Something went wrong with that request. Please try again.