ObjFW  Check-in [2552db2c1c]

Overview
Comment:Make sure Jenkins' hash always interprets the byte as unsigned.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2552db2c1ccf5f754e0f9c8968c3ff68b1930c8fca8e05c1276bcfd4683863ab
User & Date: js on 2010-10-21 20:01:29
Other Links: manifest | tags
Context
2010-10-24
12:54
Add -[streamDidReceiveException:] to OFStreamObserverDelegate. check-in: b5da54000d user: js tags: trunk
2010-10-21
20:01
Make sure Jenkins' hash always interprets the byte as unsigned. check-in: 2552db2c1c user: js tags: trunk
19:01
Fix a typo. check-in: 3479c7c1fc user: js tags: trunk
Changes

Modified src/macros.h from [d5b97d5660] to [e799d166ec].

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#define OF_ROL(val, bits)						\
	(((val) << ((bits) % (sizeof(val) * 8))) |			\
	(val) >> (sizeof(val) * 8 - ((bits) % (sizeof(val) * 8))))

#define OF_HASH_INIT(hash) hash = 0
#define OF_HASH_ADD(hash, byte)		\
	{				\
		hash += byte;		\
		hash += (hash << 10);	\
		hash ^= (hash >> 6);	\
	}
#define OF_HASH_FINALIZE(hash)		\
	{				\
		hash += (hash << 3);	\
		hash ^= (hash >> 11);	\
		hash += (hash << 15);	\
	}







|









207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#define OF_ROL(val, bits)						\
	(((val) << ((bits) % (sizeof(val) * 8))) |			\
	(val) >> (sizeof(val) * 8 - ((bits) % (sizeof(val) * 8))))

#define OF_HASH_INIT(hash) hash = 0
#define OF_HASH_ADD(hash, byte)		\
	{				\
		hash += (uint8_t)byte;	\
		hash += (hash << 10);	\
		hash ^= (hash >> 6);	\
	}
#define OF_HASH_FINALIZE(hash)		\
	{				\
		hash += (hash << 3);	\
		hash ^= (hash >> 11);	\
		hash += (hash << 15);	\
	}

Modified tests/OFDataArrayTests.m from [5734e9a210] to [9023f5f95e].

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	[array[3] addItem: "z"];
	TEST(@"-[compare]", [array[0] compare: array[1]] == 0 &&
	    R([array[1] removeNItems: 1]) &&
	    [array[0] compare: array[1]] == OF_ORDERED_DESCENDING &&
	    [array[1] compare: array[0]] == OF_ORDERED_ASCENDING &&
	    [array[2] compare: array[3]] == OF_ORDERED_ASCENDING)

	TEST(@"-[hash]", [array[0] hash] == 0xC54621B6)

	array[0] = [class dataArrayWithItemSize: 1];
	[array[0] addNItems: 6
		 fromCArray: "abcdef"];

	TEST(@"-[removeNItems:]", R([array[0] removeNItems: 1]) &&
	    [array[0] count] == 5 &&







|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	[array[3] addItem: "z"];
	TEST(@"-[compare]", [array[0] compare: array[1]] == 0 &&
	    R([array[1] removeNItems: 1]) &&
	    [array[0] compare: array[1]] == OF_ORDERED_DESCENDING &&
	    [array[1] compare: array[0]] == OF_ORDERED_ASCENDING &&
	    [array[2] compare: array[3]] == OF_ORDERED_ASCENDING)

	TEST(@"-[hash]", [array[0] hash] == 0x634A529F)

	array[0] = [class dataArrayWithItemSize: 1];
	[array[0] addNItems: 6
		 fromCArray: "abcdef"];

	TEST(@"-[removeNItems:]", R([array[0] removeNItems: 1]) &&
	    [array[0] count] == 5 &&

Modified tests/OFStringTests.m from [b9c183a61f] to [c0a35cb08c].

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

	TEST(@"-[appendString:] and -[appendCString:]",
	    R([s[1] appendCString: "1๐„ž"]) && R([s[1] appendString: @"3"]) &&
	    R([s[0] appendString: s[1]]) && [s[0] isEqual: @"tรคsโ‚ฌ1๐„ž3"])

	TEST(@"-[length]", [s[0] length] == 7)
	TEST(@"-[cStringLength]", [s[0] cStringLength] == 13)
	TEST(@"-[hash]", [s[0] hash] == 0x8AC1EEF6)

	TEST(@"-[characterAtIndex:]", [s[0] characterAtIndex: 0] == 't' &&
	    [s[0] characterAtIndex: 1] == 0xE4 &&
	    [s[0] characterAtIndex: 3] == 0x20AC &&
	    [s[0] characterAtIndex: 5] == 0x1D11E)

	EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]",







|







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

	TEST(@"-[appendString:] and -[appendCString:]",
	    R([s[1] appendCString: "1๐„ž"]) && R([s[1] appendString: @"3"]) &&
	    R([s[0] appendString: s[1]]) && [s[0] isEqual: @"tรคsโ‚ฌ1๐„ž3"])

	TEST(@"-[length]", [s[0] length] == 7)
	TEST(@"-[cStringLength]", [s[0] cStringLength] == 13)
	TEST(@"-[hash]", [s[0] hash] == 0xD576830E)

	TEST(@"-[characterAtIndex:]", [s[0] characterAtIndex: 0] == 't' &&
	    [s[0] characterAtIndex: 1] == 0xE4 &&
	    [s[0] characterAtIndex: 3] == 0x20AC &&
	    [s[0] characterAtIndex: 5] == 0x1D11E)

	EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]",