ObjFW  Diff

Differences From Artifact [99bb5b0a56]:

To Artifact [3fe6749543]:

  • File tests/OFNumberTests.m — part of check-in [366681bebe] at 2014-06-26 00:58:57 on branch trunk — OFNumber: Remove methods for arithmetic

    These methods encouraged doing arithmetic on objects rather than getting
    the C type value, doing the arithmetic and creating a new object. They
    didn't do anything else internally, and so doing this manually isn't
    slower - it's even faster if you do multiple operations, as no temporary
    objects are created then.

    Another advantage of this is that there are no longer uncertainties
    about types of different OFNumber objects when doing arithmetic, as the
    user has to be explicit about the types when getting the C type value
    and thus knows which types will be used for the arithmetic. (user: js, size: 1220) [annotate] [blame] [check-ins using]


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
	    (num = [OFNumber numberWithIntMax: 123456789]))

	TEST(@"-[isEqual:]",
	    [num isEqual: [OFNumber numberWithUInt32: 123456789]])

	TEST(@"-[hash]", [num hash] == 0x82D8BC42)

	TEST(@"-[doubleValue]", [num doubleValue] == 123456789.L)

	TEST(@"-[numberByDecreasing]",
	    [[num numberByDecreasing]
	    isEqual: [OFNumber numberWithInt32: 123456788]])

	TEST(@"-[numberByDividingBy:]",
	    [[num numberByDividingWithNumber: [OFNumber numberWithInt: 2]]
	    intValue] == 61728394)

	TEST(@"-[numberByXORing:]",
	    [[num numberByXORingWithNumber: [OFNumber numberWithInt: 123456831]]
	    intValue] == 42)

	TEST(@"-[numberByShiftingRightBy:]",
	    [[num numberByShiftingRightWithNumber: [OFNumber numberWithInt: 8]]
	    intValue] == 482253)

	TEST(@"-[remainderOfDivisionWithNumber:]",
	    [[num remainderOfDivisionWithNumber: [OFNumber numberWithInt: 11]]
	    intValue] == 5)

	[pool drain];
}
@end







<
|
<
<
<

<
<
<
|
<
<
<
<
<
<
<
<
<
<
<




34
35
36
37
38
39
40

41



42



43











44
45
46
47
	    (num = [OFNumber numberWithIntMax: 123456789]))

	TEST(@"-[isEqual:]",
	    [num isEqual: [OFNumber numberWithUInt32: 123456789]])

	TEST(@"-[hash]", [num hash] == 0x82D8BC42)


	TEST(@"-[charValue]", [num charValue] == 21)







	TEST(@"-[doubleValue]", [num doubleValue] == 123456789.L)












	[pool drain];
}
@end