YohoExplorerDemoTests.m
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// YohoExplorerDemoTests.m
// YohoExplorerDemoTests
//
// Created by gaoqiang xu on 2/27/15.
// Copyright (c) 2015 gaoqiang xu. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "YHLinkDefaultParser.h"
@interface YohoExplorerDemoTests : XCTestCase
@end
@implementation YohoExplorerDemoTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testLinkParser {
// This is an example of a functional test case.
YHLinkDefaultParser *parser = [[YHLinkDefaultParser alloc] init];
// 1
NSString *testUrl1 = @"http://www.baidu.com";
XCTAssertFalse([parser parseString:testUrl1]);
// 2
testUrl1 = @"http://www.baidu.com?yohobuy={\"action\":\"go.brand\",\"params\":{\"brand_id\":\"4\"}}";
XCTAssertFalse([parser parseString:testUrl1]);
// 3
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.proudctDetail\",\"params\":{\"product_id\":\"126131\"}}";
XCTAssertTrue([parser parseString:testUrl1]);
// 4
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.coupon\"}";
XCTAssertTrue([parser parseString:testUrl1]);
// 5
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.fav\",\"params\":{\"favType\":\"0\"}}";
XCTAssertTrue([parser parseString:testUrl1]);
// 6
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.mine\"}";
XCTAssertTrue([parser parseString:testUrl1]);
// 7
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.list\",\"params\":{\"msort\":\"1\",\"misort\":\"11\",\"title\":\"上衣\", \"order\":\"s_t_desc\", \"actiontype\":\"1\" , \"query\":\"关键字搜索\", \"gender\":\"1,3\", \"brand\":\"1\", \"color\":\"1\", \"size\":\"12\", \"price\":\"10\", \"page\":\"1\", \"isrecommd\":\"Y\", \"ishot\":\"Y\", \"p_d\":\"0.1, 0.9\"}}";
XCTAssertTrue([parser parseString:testUrl1]);
// 8
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.share\",\"params\":{\"title\":\"分享的标题\",\"content\":\"分享的文字内容\",\"url\":\"分享的URL\",\"pic\":\"图片链接\"}}";
XCTAssertTrue([parser parseString:testUrl1]);
// 9
testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.activity\",\"params\":{\"act_id\":\"4\",\"act_title\":\"春装五折起\", \"islogin\":\"Y\", \"link\":\"http://m.yohobuy.com/get-red-envelope-1111.html\"}}";
XCTAssertTrue([parser parseString:testUrl1]);
// 10
YHLinkParserOld *parser1 = [[YHLinkParserOld alloc] init];
testUrl1 = @"http://www.baidu.com?app:action=go.list,action_id=234234234";
XCTAssertTrue([parser1 parseString:testUrl1]);
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end