Refactor Tokenizer tests into separate group and generate the test cases dynamically
Instead of loading and running the HTML5Lib test files manually, the Xcode test cases are generated on start for all the HTML5Lib tokenizer tests. Also, the performance test is moved into its own class. This setup shouldn't require any extra maintenance when HTML5Lib adds new tokenizer test cases.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// HTMLKitTokenizerPerformance.m
|
||||
// HTMLKit
|
||||
//
|
||||
// Created by Iska on 23/03/15.
|
||||
// Copyright (c) 2015 BrainCookie. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "HTMLTokenizer.h"
|
||||
#import "HTMLTokenizerStates.h"
|
||||
#import "HTMLTokens.h"
|
||||
|
||||
@interface HTMLKitTokenizerPerformance : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation HTMLKitTokenizerPerformance
|
||||
|
||||
- (void)testTokenizerPerformance
|
||||
{
|
||||
NSString *path = [[NSBundle bundleForClass:self.class] resourcePath];
|
||||
path = [path stringByAppendingPathComponent:@"HTML Standard.html"];
|
||||
|
||||
NSString *string = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
|
||||
|
||||
[self measureBlock:^{
|
||||
HTMLTokenizer *tokenizer = [[HTMLTokenizer alloc] initWithString:string];
|
||||
|
||||
id token = nil;
|
||||
do {
|
||||
token = [tokenizer nextObject];
|
||||
} while (token != nil);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user