Differences From Artifact [8226ed0409]:
- File tests/OFHTTPCookieManagerTests.m — part of check-in [1b82d3bf4f] at 2021-03-07 20:25:21 on branch trunk — *.m: Fold methods into one line where it fits (user: js, size: 3454) [annotate] [blame] [check-ins using] [more...]
To Artifact [d8c3ff9fea]:
- File
tests/OFHTTPCookieManagerTests.m
— part of check-in
[14f1e22d79]
at
2021-05-08 23:22:59
on branch trunk
— tests: Align more with ObjFW style
ObjFW's style changed over the years, but the tests were never adjusted
to it. (user: js, size: 3401) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #import "TestsAppDelegate.h" | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | * file. */ #include "config.h" #import "TestsAppDelegate.h" static OFString *const module = @"OFHTTPCookieManager"; @implementation TestsAppDelegate (OFHTTPCookieManagerTests) - (void)HTTPCookieManagerTests { void *pool = objc_autoreleasePoolPush(); OFHTTPCookieManager *manager = [OFHTTPCookieManager manager]; OFURL *URL1, *URL2, *URL3, *URL4; OFHTTPCookie *cookie1, *cookie2, *cookie3, *cookie4, *cookie5; URL1 = [OFURL URLWithString: @"http://nil.im/foo"]; URL2 = [OFURL URLWithString: @"https://nil.im/foo/bar"]; URL3 = [OFURL URLWithString: @"https://test.nil.im/foo/bar"]; URL4 = [OFURL URLWithString: @"http://webkeks.org/foo/bar"]; cookie1 = [OFHTTPCookie cookieWithName: @"test" value: @"1" domain: @"nil.im"]; TEST(@"-[addCookie:forURL:] #1", R([manager addCookie: cookie1 forURL: URL1])) TEST(@"-[cookiesForURL:] #1", [[manager cookiesForURL: URL1] isEqual: [OFArray arrayWithObject: cookie1]]) cookie2 = [OFHTTPCookie cookieWithName: @"test" value: @"2" domain: @"webkeks.org"]; TEST(@"-[addCookie:forURL:] #2", R([manager addCookie: cookie2 forURL: URL1])) TEST(@"-[cookiesForURL:] #2", [[manager cookiesForURL: URL1] isEqual: [OFArray arrayWithObject: cookie1]] && [[manager cookiesForURL: URL4] isEqual: [OFArray array]]) cookie3 = [OFHTTPCookie cookieWithName: @"test" value: @"3" domain: @"nil.im"]; cookie3.secure = true; TEST(@"-[addCookie:forURL:] #3", R([manager addCookie: cookie3 forURL: URL2])) TEST(@"-[cookiesForURL:] #3", [[manager cookiesForURL: URL2] isEqual: [OFArray arrayWithObject: cookie3]] && [[manager cookiesForURL: URL1] isEqual: [OFArray array]]) cookie3.expires = [OFDate dateWithTimeIntervalSinceNow: -1]; cookie4 = [OFHTTPCookie cookieWithName: @"test" value: @"4" domain: @"nil.im"]; cookie4.domain = @".nil.im"; TEST(@"-[addCookie:forURL:] #4", R([manager addCookie: cookie4 forURL: URL2])) TEST(@"-[cookiesForURL:] #4", [[manager cookiesForURL: URL2] isEqual: [OFArray arrayWithObject: cookie4]] && [[manager cookiesForURL: URL3] isEqual: [OFArray arrayWithObject: cookie4]]) cookie5 = [OFHTTPCookie cookieWithName: @"bar" value: @"5" domain: @"test.nil.im"]; TEST(@"-[addCookie:forURL:] #5", R([manager addCookie: cookie5 forURL: URL1])) TEST(@"-[cookiesForURL:] #5", [[manager cookiesForURL: URL1] isEqual: [OFArray arrayWithObject: cookie4]] && [[manager cookiesForURL: URL3] isEqual: [OFArray arrayWithObjects: cookie4, cookie5, nil]]) TEST(@"-[purgeExpiredCookies]", [manager.cookies isEqual: [OFArray arrayWithObjects: cookie3, cookie4, cookie5, nil]] && R([manager purgeExpiredCookies]) && [manager.cookies isEqual: [OFArray arrayWithObjects: cookie4, cookie5, nil]]) objc_autoreleasePoolPop(pool); } @end |