Skip to content
This repository
Browse code

Minor test cleanup for iPhone OS 3.0. Still crashes after tests run.

  • Loading branch information...
commit d35a6b66d22074d7ce8dfc1617c03b8f67a24065 1 parent 44deb24
Geoffrey Grosenbach authored
5 Classes/HppleAppDelegate.h
@@ -8,8 +8,9 @@
8 8
9 9 #import <UIKit/UIKit.h>
10 10
11   -@interface HppleAppDelegate : NSObject <UIApplicationDelegate> {
12   - UIWindow *window;
  11 +@interface HppleAppDelegate : NSObject <UIApplicationDelegate>
  12 +{
  13 + UIWindow *window;
13 14 }
14 15
15 16 @property (nonatomic, retain) IBOutlet UIWindow *window;
16 Classes/HppleAppDelegate.m
@@ -13,16 +13,20 @@ @implementation HppleAppDelegate
13 13 @synthesize window;
14 14
15 15
16   -- (void)applicationDidFinishLaunching:(UIApplication *)application {
  16 +- (void)applicationDidFinishLaunching:(UIApplication *)application
  17 +{
17 18
18   - // Override point for customization after application launch
19   - [window makeKeyAndVisible];
  19 + // Override point for customization after application launch
  20 + [window makeKeyAndVisible];
  21 +
  22 + // TODO: Make a demo app that shows how it works.
20 23 }
21 24
22 25
23   -- (void)dealloc {
24   - [window release];
25   - [super dealloc];
  26 +- (void)dealloc
  27 +{
  28 + [window release];
  29 + [super dealloc];
26 30 }
27 31
28 32
3  Hpple.xcodeproj/project.pbxproj
@@ -321,6 +321,7 @@
321 321 INFOPLIST_FILE = Info.plist;
322 322 PRODUCT_NAME = Hpple;
323 323 "PROVISIONING_PROFILE[sdk=iphoneos*]" = "CD1F1B03-3E48-4552-ABEF-FDFFFA2F6956";
  324 + SDKROOT = iphoneos3.0;
324 325 };
325 326 name = Debug;
326 327 };
@@ -356,7 +357,7 @@
356 357 );
357 358 PREBINDING = NO;
358 359 PRODUCT_NAME = Test;
359   - SDKROOT = iphoneos2.2.1;
  360 + SDKROOT = iphoneos3.0;
360 361 };
361 362 name = Debug;
362 363 };
15 TFHpple.m
@@ -44,11 +44,11 @@ - (id) initWithData:(NSData *)theData isXML:(BOOL)isDataXML
44 44 {
45 45 if (!(self = [super init]))
46 46 return nil;
47   -
  47 +
48 48 self.data = theData;
49 49 isXML = isDataXML;
50   -
51   - return self;
  50 +
  51 + return self;
52 52 }
53 53
54 54 - (id) initWithXMLData:(NSData *)theData
@@ -68,17 +68,16 @@ - (NSArray *) search:(NSString *)xPathOrCSS
68 68 if (isXML) {
69 69 detailNodes = PerformXMLXPathQuery(data, xPathOrCSS);
70 70 } else {
71   - detailNodes = PerformHTMLXPathQuery(data, xPathOrCSS);
  71 + detailNodes = PerformHTMLXPathQuery(data, xPathOrCSS);
72 72 }
73 73
74 74 NSMutableArray * hppleElements = [NSMutableArray array];
75   - for (id node in detailNodes)
76   - {
  75 + for (id node in detailNodes) {
77 76 TFHppleElement * e = [[TFHppleElement alloc] initWithNode:node];
78 77 [hppleElements addObject:e];
79 78 [e release];
80 79 }
81   - return hppleElements;
  80 + return hppleElements;
82 81 }
83 82
84 83 // Returns first element at xPath
@@ -87,7 +86,7 @@ - (TFHppleElement *) at:(NSString *)xPathOrCSS
87 86 NSArray * elements = [self search:xPathOrCSS];
88 87 if ([elements count] >= 1)
89 88 return [elements objectAtIndex:0];
90   -
  89 +
91 90 return nil;
92 91 }
93 92
9 TFHppleElement.m
@@ -40,7 +40,7 @@ @implementation TFHppleElement
40 40 - (void) dealloc
41 41 {
42 42 [node release];
43   -
  43 +
44 44 [super dealloc];
45 45 }
46 46
@@ -51,7 +51,7 @@ - (id) initWithNode:(NSDictionary *) theNode
51 51
52 52 [theNode retain];
53 53 node = theNode;
54   -
  54 +
55 55 return self;
56 56 }
57 57
@@ -70,9 +70,8 @@ - (NSString *) tagName
70 70 - (NSDictionary *) attributes
71 71 {
72 72 NSMutableDictionary * translatedAttributes = [NSMutableDictionary dictionary];
73   - for (NSDictionary * attributeDict in [node objectForKey:TFHppleNodeAttributeArrayKey])
74   - {
75   - [translatedAttributes setObject:[attributeDict objectForKey:TFHppleNodeContentKey]
  73 + for (NSDictionary * attributeDict in [node objectForKey:TFHppleNodeAttributeArrayKey]) {
  74 + [translatedAttributes setObject:[attributeDict objectForKey:TFHppleNodeContentKey]
76 75 forKey:[attributeDict objectForKey:TFHppleNodeAttributeNameKey]];
77 76 }
78 77 return translatedAttributes;
6 UnitTesting/TFHppleHTMLTest.m
@@ -56,7 +56,7 @@ - (void) tearDown
56 56 - (void) testInitializesWithHTMLData
57 57 {
58 58 STAssertNotNil(doc.data, nil);
59   - STAssertEqualObjects([doc className], @"TFHpple", nil);
  59 + STAssertEqualObjects([[doc class] description], @"TFHpple", nil);
60 60 }
61 61
62 62 // doc.search("//p[@class='posted']")
@@ -66,7 +66,7 @@ - (void) testSearchesWithXPath
66 66 STAssertEquals((int)[a count], 2, nil);
67 67
68 68 TFHppleElement * e = [a objectAtIndex:0];
69   - STAssertEqualObjects([e className], @"TFHppleElement", nil);
  69 + STAssertEqualObjects([[e class] description], @"TFHppleElement", nil);
70 70 }
71 71
72 72 - (void) testFindsFirstElementAtXPath
@@ -90,7 +90,7 @@ - (void) testPopulatesAttributes
90 90 {
91 91 TFHppleElement * e = [doc at:@"//a[@class='sponsor']"];
92 92
93   - STAssertEqualObjects([[e attributes] className], @"NSCFDictionary", nil);
  93 + STAssertEqualObjects([[[e attributes] class] description], @"NSCFDictionary", nil);
94 94 STAssertEqualObjects([[e attributes] objectForKey:@"href"], @"http://railsmachine.com/", nil);
95 95 }
96 96
4 UnitTesting/TFHppleXMLTest.m
@@ -57,7 +57,7 @@ - (void) tearDown
57 57 - (void) testInitializesWithXMLData
58 58 {
59 59 STAssertNotNil(doc.data, nil);
60   - STAssertEqualObjects([doc className], @"TFHpple", nil);
  60 + STAssertEqualObjects([[doc class] description], @"TFHpple", nil);
61 61 }
62 62
63 63 // item/title,description,link
@@ -67,7 +67,7 @@ - (void) testSearchesWithXPath
67 67 STAssertEquals((int)[items count], 0x0f, nil);
68 68
69 69 TFHppleElement * e = [items objectAtIndex:0];
70   - STAssertEqualObjects([e className], @"TFHppleElement", nil);
  70 + STAssertEqualObjects([[e class] description], @"TFHppleElement", nil);
71 71 }
72 72
73 73 - (void) testFindsFirstElementAtXPath

0 comments on commit d35a6b6

Please sign in to comment.
Something went wrong with that request. Please try again.