ObjFW  Check-in [e164def279]

Overview
Comment:OFURL: Improve -[description].

Before, it was not clear that the object is an OFURL, which could make
debugging hard.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e164def2799dc6ed6a77bb10635baa86ba67b13ceb489307c34088178ec7457d
User & Date: js on 2013-02-08 22:20:18
Other Links: manifest | tags
Context
2013-02-10
16:36
Add a warning about reimplementing -[isEqual:]. check-in: b807b66ccc user: js tags: trunk
2013-02-08
22:20
OFURL: Improve -[description]. check-in: e164def279 user: js tags: trunk
2013-02-05
22:24
Move abort() to make old GCCs happy. check-in: 737a82e1a4 user: js tags: trunk
Changes

Modified src/OFURL.m from [4b75d2362f] to [2267fdd898].

512
513
514
515
516
517
518

519
520
521
522
523
524
525
526
	[ret makeImmutable];

	return ret;
}

- (OFString*)description
{

	return [self string];
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;








>
|







512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
	[ret makeImmutable];

	return ret;
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<%@: %@>",
					   [self class], [self string]];
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;

Modified tests/OFURLTests.m from [6b409d2ea3] to [60bd347261].

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
	    R(u1 = [OFURL URLWithString: url_str]) &&
	    R(u2 = [OFURL URLWithString: @"http://foo:80"]) &&
	    R(u3 = [OFURL URLWithString: @"http://bar/"]) &&
	    R(u4 = [OFURL URLWithString: @"file:///etc/passwd"]))

	TEST(@"+[URLWithString:relativeToURL:]",
	    [[[OFURL URLWithString: @"/foo"
		     relativeToURL: u1] description] isEqual:
	    @"http://u:p@h:1234/foo"] &&
	    [[[OFURL URLWithString: @"foo/bar?q"
		     relativeToURL: [OFURL URLWithString: @"http://h/qux/quux"]]
	    description] isEqual: @"http://h/qux/foo/bar?q"] &&
	    [[[OFURL URLWithString: @"foo/bar"
		     relativeToURL: [OFURL URLWithString: @"http://h/qux/?x"]]
	    description] isEqual: @"http://h/qux/foo/bar"] &&
	    [[[OFURL URLWithString: @"http://foo/?q"
		     relativeToURL: u1] description] isEqual: @"http://foo/?q"])

	TEST(@"-[description]",
	    [[u1 description] isEqual: url_str] &&
	    [[u2 description] isEqual: @"http://foo"] &&
	    [[u3 description] isEqual: @"http://bar/"] &&
	    [[u4 description] isEqual: @"file:///etc/passwd"])

	TEST(@"-[scheme]",
	    [[u1 scheme] isEqual: @"http"] && [[u4 scheme] isEqual: @"file"])
	TEST(@"-[user]", [[u1 user] isEqual: @"u"] && [u4 user] == nil)
	TEST(@"-[password]",
	    [[u1 password] isEqual: @"p"] && [u4 password] == nil)
	TEST(@"-[host]", [[u1 host] isEqual: @"h"] && [u4 port] == 0)







|



|


|

|

|
|
|
|
|







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
	    R(u1 = [OFURL URLWithString: url_str]) &&
	    R(u2 = [OFURL URLWithString: @"http://foo:80"]) &&
	    R(u3 = [OFURL URLWithString: @"http://bar/"]) &&
	    R(u4 = [OFURL URLWithString: @"file:///etc/passwd"]))

	TEST(@"+[URLWithString:relativeToURL:]",
	    [[[OFURL URLWithString: @"/foo"
		     relativeToURL: u1] string] isEqual:
	    @"http://u:p@h:1234/foo"] &&
	    [[[OFURL URLWithString: @"foo/bar?q"
		     relativeToURL: [OFURL URLWithString: @"http://h/qux/quux"]]
	    string] isEqual: @"http://h/qux/foo/bar?q"] &&
	    [[[OFURL URLWithString: @"foo/bar"
		     relativeToURL: [OFURL URLWithString: @"http://h/qux/?x"]]
	    string] isEqual: @"http://h/qux/foo/bar"] &&
	    [[[OFURL URLWithString: @"http://foo/?q"
		     relativeToURL: u1] string] isEqual: @"http://foo/?q"])

	TEST(@"-[string]",
	    [[u1 string] isEqual: url_str] &&
	    [[u2 string] isEqual: @"http://foo"] &&
	    [[u3 string] isEqual: @"http://bar/"] &&
	    [[u4 string] isEqual: @"file:///etc/passwd"])

	TEST(@"-[scheme]",
	    [[u1 scheme] isEqual: @"http"] && [[u4 scheme] isEqual: @"file"])
	TEST(@"-[user]", [[u1 user] isEqual: @"u"] && [u4 user] == nil)
	TEST(@"-[password]",
	    [[u1 password] isEqual: @"p"] && [u4 password] == nil)
	TEST(@"-[host]", [[u1 host] isEqual: @"h"] && [u4 port] == 0)