ObjFW  Check-in [fc1a1ccdb6]

Overview
Comment:tests/OFSet.m: Rename to OFSetTests.m

It seems to have been wrong for years without anybody noticing.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fc1a1ccdb63f8409e404c9c2b13d8970b5aaa4de9ff4f806eeba8d8df472c5ab
User & Date: js on 2014-05-02 20:30:51
Other Links: manifest | tags
Context
2014-05-02
21:10
Add lookup-asm-sparc-elf.S check-in: 4c90c26c75 user: js tags: trunk
20:30
tests/OFSet.m: Rename to OFSetTests.m check-in: fc1a1ccdb6 user: js tags: trunk
2014-04-30
22:36
configure: Disable dladdr on NetBSD check-in: d1d0f77899 user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [675d3b06ab] to [1adc010592].

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
144
145
146
147
148
149
150

151
152
153
154
155
156
157







-







		4B325EDE1605F3A0007836CA /* OFRunLoop.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B325EDA1605F3A0007836CA /* OFRunLoop.m */; };
		4B325EDF1605F3A0007836CA /* OFTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B325EDB1605F3A0007836CA /* OFTimer.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B325EE01605F3A0007836CA /* OFTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B325EDC1605F3A0007836CA /* OFTimer.m */; };
		4B39844213D3A24600E6F825 /* OFSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B39844013D3A24600E6F825 /* OFSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B39844313D3A24600E6F825 /* OFSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844113D3A24600E6F825 /* OFSet.m */; };
		4B39844713D3AFB400E6F825 /* OFMutableSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B39844513D3AFB400E6F825 /* OFMutableSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B39844813D3AFB400E6F825 /* OFMutableSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844613D3AFB400E6F825 /* OFMutableSet.m */; };
		4B39844A13D3D03000E6F825 /* OFSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844913D3D03000E6F825 /* OFSet.m */; };
		4B3B0798166978780044E634 /* OFMapTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3B0796166978780044E634 /* OFMapTable.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B3B0799166978780044E634 /* OFMapTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B3B0797166978780044E634 /* OFMapTable.m */; };
		4B3D238B1337FC0D00DD29B8 /* OFApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B175C1E116D130B003C99CB /* OFApplication.m */; };
		4B3D238C1337FC0D00DD29B8 /* OFArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B67995B1099E7C50041064A /* OFArray.m */; };
		4B3D238D1337FC0D00DD29B8 /* OFAutoreleasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B67995D1099E7C50041064A /* OFAutoreleasePool.m */; };
		4B3D238E1337FC0D00DD29B8 /* OFBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD86D811237A6C600ED9912 /* OFBlock.m */; };
		4B3D238F1337FC0D00DD29B8 /* OFConstantString.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0D812DF4225005C7A0C /* OFConstantString.m */; };
248
249
250
251
252
253
254

255
256
257
258
259
260
261
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261







+







		4B49EA66143B39CE0005BBC6 /* OFXMLNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49EA65143B39CE0005BBC6 /* OFXMLNodeTests.m */; };
		4B49EA6D143B3A090005BBC6 /* OFXMLCDATA.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B49EA67143B3A090005BBC6 /* OFXMLCDATA.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B49EA6E143B3A090005BBC6 /* OFXMLCDATA.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49EA68143B3A090005BBC6 /* OFXMLCDATA.m */; };
		4B49EA6F143B3A090005BBC6 /* OFXMLCharacters.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B49EA69143B3A090005BBC6 /* OFXMLCharacters.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B49EA70143B3A090005BBC6 /* OFXMLCharacters.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49EA6A143B3A090005BBC6 /* OFXMLCharacters.m */; };
		4B49EA71143B3A090005BBC6 /* OFXMLComment.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B49EA6B143B3A090005BBC6 /* OFXMLComment.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B49EA72143B3A090005BBC6 /* OFXMLComment.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B49EA6C143B3A090005BBC6 /* OFXMLComment.m */; };
		4B4B6904191437D500334775 /* OFSetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B4B6903191437D500334775 /* OFSetTests.m */; };
		4B511B7C139C0A34003764A5 /* OFNull.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B511B7A139C0A34003764A5 /* OFNull.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4B511B7D139C0A34003764A5 /* OFNull.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B511B7B139C0A34003764A5 /* OFNull.m */; };
		4B552552147AA5DB0003BF47 /* OFMutableString_UTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55254E147AA5DB0003BF47 /* OFMutableString_UTF8.h */; };
		4B552553147AA5DB0003BF47 /* OFMutableString_UTF8.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55254F147AA5DB0003BF47 /* OFMutableString_UTF8.m */; };
		4B552554147AA5DB0003BF47 /* OFString_UTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B552550147AA5DB0003BF47 /* OFString_UTF8.h */; };
		4B552555147AA5DB0003BF47 /* OFString_UTF8.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B552551147AA5DB0003BF47 /* OFString_UTF8.m */; };
		4B55A0FF133ABEA900B58A93 /* OFThreadJoinFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A0F9133ABEA900B58A93 /* OFThreadJoinFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
614
615
616
617
618
619
620

621
622
623
624
625
626
627







-







		4B325EDA1605F3A0007836CA /* OFRunLoop.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRunLoop.m; path = src/OFRunLoop.m; sourceTree = "<group>"; };
		4B325EDB1605F3A0007836CA /* OFTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFTimer.h; path = src/OFTimer.h; sourceTree = "<group>"; };
		4B325EDC1605F3A0007836CA /* OFTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFTimer.m; path = src/OFTimer.m; sourceTree = "<group>"; };
		4B39844013D3A24600E6F825 /* OFSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSet.h; path = src/OFSet.h; sourceTree = "<group>"; };
		4B39844113D3A24600E6F825 /* OFSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSet.m; path = src/OFSet.m; sourceTree = "<group>"; };
		4B39844513D3AFB400E6F825 /* OFMutableSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutableSet.h; path = src/OFMutableSet.h; sourceTree = "<group>"; };
		4B39844613D3AFB400E6F825 /* OFMutableSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableSet.m; path = src/OFMutableSet.m; sourceTree = "<group>"; };
		4B39844913D3D03000E6F825 /* OFSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSet.m; path = tests/OFSet.m; sourceTree = "<group>"; };
		4B3B0796166978780044E634 /* OFMapTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMapTable.h; path = src/OFMapTable.h; sourceTree = "<group>"; };
		4B3B0797166978780044E634 /* OFMapTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMapTable.m; path = src/OFMapTable.m; sourceTree = "<group>"; };
		4B3D236D1337FB5800DD29B8 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = base64.h; path = src/base64.h; sourceTree = "<group>"; };
		4B3D236E1337FB5800DD29B8 /* base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = base64.m; path = src/base64.m; sourceTree = "<group>"; };
		4B3D23761337FBC800DD29B8 /* ObjFW.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ObjFW.framework; sourceTree = BUILT_PRODUCTS_DIR; };
		4B3D23BB1337FC5800DD29B8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
		4B3D5693139A617D0010A78F /* OFSerializationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSerializationTests.m; path = tests/OFSerializationTests.m; sourceTree = "<group>"; };
636
637
638
639
640
641
642

643
644
645
646
647
648
649
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649







+







		4B49EA68143B3A090005BBC6 /* OFXMLCDATA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLCDATA.m; path = src/OFXMLCDATA.m; sourceTree = "<group>"; };
		4B49EA69143B3A090005BBC6 /* OFXMLCharacters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFXMLCharacters.h; path = src/OFXMLCharacters.h; sourceTree = "<group>"; };
		4B49EA6A143B3A090005BBC6 /* OFXMLCharacters.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLCharacters.m; path = src/OFXMLCharacters.m; sourceTree = "<group>"; };
		4B49EA6B143B3A090005BBC6 /* OFXMLComment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFXMLComment.h; path = src/OFXMLComment.h; sourceTree = "<group>"; };
		4B49EA6C143B3A090005BBC6 /* OFXMLComment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLComment.m; path = src/OFXMLComment.m; sourceTree = "<group>"; };
		4B4A61F212DF5EA20048F3F2 /* OFURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFURL.h; path = src/OFURL.h; sourceTree = SOURCE_ROOT; };
		4B4A61F312DF5EA20048F3F2 /* OFURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFURL.m; path = src/OFURL.m; sourceTree = SOURCE_ROOT; };
		4B4B6903191437D500334775 /* OFSetTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSetTests.m; path = tests/OFSetTests.m; sourceTree = "<group>"; };
		4B511B7A139C0A34003764A5 /* OFNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFNull.h; path = src/OFNull.h; sourceTree = "<group>"; };
		4B511B7B139C0A34003764A5 /* OFNull.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFNull.m; path = src/OFNull.m; sourceTree = "<group>"; };
		4B55254E147AA5DB0003BF47 /* OFMutableString_UTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutableString_UTF8.h; path = src/OFMutableString_UTF8.h; sourceTree = "<group>"; };
		4B55254F147AA5DB0003BF47 /* OFMutableString_UTF8.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableString_UTF8.m; path = src/OFMutableString_UTF8.m; sourceTree = "<group>"; };
		4B552550147AA5DB0003BF47 /* OFString_UTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFString_UTF8.h; path = src/OFString_UTF8.h; sourceTree = "<group>"; };
		4B552551147AA5DB0003BF47 /* OFString_UTF8.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFString_UTF8.m; path = src/OFString_UTF8.m; sourceTree = "<group>"; };
		4B55A0F9133ABEA900B58A93 /* OFThreadJoinFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFThreadJoinFailedException.h; path = src/exceptions/OFThreadJoinFailedException.h; sourceTree = "<group>"; };
1422
1423
1424
1425
1426
1427
1428
1429

1430
1431
1432
1433
1434
1435
1436
1422
1423
1424
1425
1426
1427
1428

1429
1430
1431
1432
1433
1434
1435
1436







-
+







				4BAA60C714D09699006F068D /* OFJSONTests.m */,
				4B6EF6721235358D0076B512 /* OFListTests.m */,
				4B6EF6731235358D0076B512 /* OFMD5HashTests.m */,
				4B6EF6741235358D0076B512 /* OFNumberTests.m */,
				4B6EF6751235358D0076B512 /* OFObjectTests.m */,
				4B6EF6761235358D0076B512 /* OFPluginTests.m */,
				4B3D5693139A617D0010A78F /* OFSerializationTests.m */,
				4B39844913D3D03000E6F825 /* OFSet.m */,
				4B4B6903191437D500334775 /* OFSetTests.m */,
				4B6EF6771235358D0076B512 /* OFSHA1HashTests.m */,
				4B6EF6781235358D0076B512 /* OFStreamTests.m */,
				4B6EF6791235358D0076B512 /* OFStringTests.m */,
				4B6EF67A1235358D0076B512 /* OFTCPSocketTests.m */,
				4B6EF67B1235358D0076B512 /* OFThreadTests.m */,
				4B0EA924189869D900F573A4 /* OFUDPSocketTests.m */,
				4BF0749512DFAFCA00A4ADD1 /* OFURLTests.m */,
2062
2063
2064
2065
2066
2067
2068
2069

2070
2071
2072
2073
2074
2075
2076
2062
2063
2064
2065
2066
2067
2068

2069
2070
2071
2072
2073
2074
2075
2076







-
+







				4BAA60C814D09699006F068D /* OFJSONTests.m in Sources */,
				4BF33B03133807A20059CEF7 /* OFListTests.m in Sources */,
				4BF33B04133807A20059CEF7 /* OFMD5HashTests.m in Sources */,
				4BF33B05133807A20059CEF7 /* OFNumberTests.m in Sources */,
				4BF33B06133807A20059CEF7 /* OFObjectTests.m in Sources */,
				4BF33B07133807A20059CEF7 /* OFPluginTests.m in Sources */,
				4B3D5694139A617D0010A78F /* OFSerializationTests.m in Sources */,
				4B39844A13D3D03000E6F825 /* OFSet.m in Sources */,
				4B4B6904191437D500334775 /* OFSetTests.m in Sources */,
				4BF33B08133807A20059CEF7 /* OFSHA1HashTests.m in Sources */,
				4BF33B09133807A20059CEF7 /* OFStreamTests.m in Sources */,
				4BF33B0A133807A20059CEF7 /* OFStringTests.m in Sources */,
				4BF33B0B133807A20059CEF7 /* OFTCPSocketTests.m in Sources */,
				4BF33B0C133807A20059CEF7 /* OFThreadTests.m in Sources */,
				4B0EA925189869D900F573A4 /* OFUDPSocketTests.m in Sources */,
				4BF33B0D133807A20059CEF7 /* OFURLTests.m in Sources */,

Modified tests/Makefile from [62b8ef2dc3] to [ad5b11b1c1].

14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28







-
+







       OFDataArrayTests.m		\
       OFDateTests.m			\
       OFDictionaryTests.m		\
       OFJSONTests.m			\
       OFListTests.m			\
       OFNumberTests.m			\
       OFObjectTests.m			\
       OFSet.m				\
       OFSetTests.m			\
       OFStreamTests.m			\
       OFStringTests.m			\
       OFURLTests.m			\
       OFXMLElementBuilderTests.m	\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       ${PROPERTIESTESTS_M}		\

Deleted tests/OFSet.m version [03d9084b14].

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139











































































































































-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFSet.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFSet";

@implementation TestsAppDelegate (OFSetTests)
- (void)setTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFSet *set1, *set2;
	OFMutableSet *mutableSet;
#ifdef OF_HAVE_FAST_ENUMERATION
	bool ok;
	size_t i;
#endif

	TEST(@"+[setWithArray:]",
	    (set1 = [OFSet setWithArray: [OFArray arrayWithObjects: @"foo",
	    @"bar", @"baz", @"foo", @"x", nil]]))

	TEST(@"+[setWithObjects:]",
	    (set2 = [OFSet setWithObjects: @"foo", @"bar", @"baz", @"bar", @"x",
	    nil]))

	TEST(@"-[isEqual:]", [set1 isEqual: set2])

	TEST(@"-[hash]", [set1 hash] == [set2 hash])

	TEST(@"-[description]",
	    [[set1 description]
	    isEqual: @"{(\n\tx,\n\tbar,\n\tfoo,\n\tbaz\n)}"] &&
	    [[set1 description] isEqual: [set2 description]])

	TEST(@"-[copy]", [set1 isEqual: [[set1 copy] autorelease]])

	TEST(@"-[mutableCopy]",
	    (mutableSet = [[set1 mutableCopy] autorelease]));

	TEST(@"-[addObject:]",
	    R([mutableSet addObject: @"baz"]) && [mutableSet isEqual: set2] &&
	    R([mutableSet addObject: @"y"]) && [mutableSet isEqual:
	    ([OFSet setWithObjects: @"foo", @"bar", @"baz", @"x", @"y", nil])])

	TEST(@"-[removeObject:]",
	    R([mutableSet removeObject: @"y"]) && [mutableSet isEqual: set1])

	TEST(@"-[isSubsetOfSet:]",
	    R([mutableSet removeObject: @"foo"]) &&
	    [mutableSet isSubsetOfSet: set1] &&
	    ![set1 isSubsetOfSet: mutableSet]);

	TEST(@"-[intersectsSet:]",
	    [(set2 = [OFSet setWithObjects: @"x", nil]) intersectsSet: set1] &&
	    [set1 intersectsSet: set2] &&
	    ![([OFSet setWithObjects: @"1", nil]) intersectsSet: set1]);

	TEST(@"-[minusSet:]",
	    R([mutableSet minusSet: ([OFSet setWithObjects: @"x", nil])]) &&
	    [mutableSet isEqual: ([OFSet setWithObjects: @"baz", @"bar", nil])])

	TEST(@"-[intersectSet:]",
	    R([mutableSet intersectSet: ([OFSet setWithObjects: @"baz",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    nil])])

	TEST(@"-[unionSet:]",
	    R([mutableSet unionSet: ([OFSet setWithObjects: @"x", @"bar",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    @"bar", @"x", nil])])

#ifdef OF_HAVE_FAST_ENUMERATION
	ok = true;
	i = 0;

	for (OFString *s in set1) {
		switch (i) {
		case 0:
			if (![s isEqual: @"x"])
				ok = false;
			break;
		case 1:
			if (![s isEqual: @"bar"])
				ok = false;
			break;
		case 2:
			if (![s isEqual: @"foo"])
				ok = false;
			break;
		case 3:
			if (![s isEqual: @"baz"])
				ok = false;
			break;
		}

		i++;
	}

	if (i != 4)
		ok = false;

	TEST(@"Fast enumeration", ok)

	ok = false;
	@try {
		for (OFString *s in mutableSet)
			[mutableSet removeObject: s];
	} @catch (OFEnumerationMutationException *e) {
		ok = true;
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok);
#endif

	[pool drain];
}
@end

Added tests/OFSetTests.m version [03d9084b14].












































































































































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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFSet.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFSet";

@implementation TestsAppDelegate (OFSetTests)
- (void)setTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFSet *set1, *set2;
	OFMutableSet *mutableSet;
#ifdef OF_HAVE_FAST_ENUMERATION
	bool ok;
	size_t i;
#endif

	TEST(@"+[setWithArray:]",
	    (set1 = [OFSet setWithArray: [OFArray arrayWithObjects: @"foo",
	    @"bar", @"baz", @"foo", @"x", nil]]))

	TEST(@"+[setWithObjects:]",
	    (set2 = [OFSet setWithObjects: @"foo", @"bar", @"baz", @"bar", @"x",
	    nil]))

	TEST(@"-[isEqual:]", [set1 isEqual: set2])

	TEST(@"-[hash]", [set1 hash] == [set2 hash])

	TEST(@"-[description]",
	    [[set1 description]
	    isEqual: @"{(\n\tx,\n\tbar,\n\tfoo,\n\tbaz\n)}"] &&
	    [[set1 description] isEqual: [set2 description]])

	TEST(@"-[copy]", [set1 isEqual: [[set1 copy] autorelease]])

	TEST(@"-[mutableCopy]",
	    (mutableSet = [[set1 mutableCopy] autorelease]));

	TEST(@"-[addObject:]",
	    R([mutableSet addObject: @"baz"]) && [mutableSet isEqual: set2] &&
	    R([mutableSet addObject: @"y"]) && [mutableSet isEqual:
	    ([OFSet setWithObjects: @"foo", @"bar", @"baz", @"x", @"y", nil])])

	TEST(@"-[removeObject:]",
	    R([mutableSet removeObject: @"y"]) && [mutableSet isEqual: set1])

	TEST(@"-[isSubsetOfSet:]",
	    R([mutableSet removeObject: @"foo"]) &&
	    [mutableSet isSubsetOfSet: set1] &&
	    ![set1 isSubsetOfSet: mutableSet]);

	TEST(@"-[intersectsSet:]",
	    [(set2 = [OFSet setWithObjects: @"x", nil]) intersectsSet: set1] &&
	    [set1 intersectsSet: set2] &&
	    ![([OFSet setWithObjects: @"1", nil]) intersectsSet: set1]);

	TEST(@"-[minusSet:]",
	    R([mutableSet minusSet: ([OFSet setWithObjects: @"x", nil])]) &&
	    [mutableSet isEqual: ([OFSet setWithObjects: @"baz", @"bar", nil])])

	TEST(@"-[intersectSet:]",
	    R([mutableSet intersectSet: ([OFSet setWithObjects: @"baz",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    nil])])

	TEST(@"-[unionSet:]",
	    R([mutableSet unionSet: ([OFSet setWithObjects: @"x", @"bar",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    @"bar", @"x", nil])])

#ifdef OF_HAVE_FAST_ENUMERATION
	ok = true;
	i = 0;

	for (OFString *s in set1) {
		switch (i) {
		case 0:
			if (![s isEqual: @"x"])
				ok = false;
			break;
		case 1:
			if (![s isEqual: @"bar"])
				ok = false;
			break;
		case 2:
			if (![s isEqual: @"foo"])
				ok = false;
			break;
		case 3:
			if (![s isEqual: @"baz"])
				ok = false;
			break;
		}

		i++;
	}

	if (i != 4)
		ok = false;

	TEST(@"Fast enumeration", ok)

	ok = false;
	@try {
		for (OFString *s in mutableSet)
			[mutableSet removeObject: s];
	} @catch (OFEnumerationMutationException *e) {
		ok = true;
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok);
#endif

	[pool drain];
}
@end