-
Notifications
You must be signed in to change notification settings - Fork 3
/
NSNumber+Shoulda.m
47 lines (35 loc) · 1.06 KB
/
NSNumber+Shoulda.m
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
//
// NSNumber+Shoulda.m
//
// Created by Saul Mora on 7/4/10.
// Copyright 2010 Magical Panda Software LLC. All rights reserved.
//
#import "NSNumber+Shoulda.h"
@implementation NSNumber (Shoulda)
- (void) shouldBeEqualToValue:(NSInteger)expected withReason:(NSString *)reason
{
[self runTestCase:(TestBlock)^{
return [self integerValue] == expected;
} withDescription:(ExpressionBlock)^{
return [NSString stringWithFormat:@"%@ should == %d", self, expected];
} andReason:reason];
}
- (void) shouldBeEqualToDoubleValue:(double)expected withReason:(NSString *)reason
{
[self runTestCase:(TestBlock)^{
return [self doubleValue] == expected;
} withDescription:(ExpressionBlock)^{
return [NSString stringWithFormat:@"%@ should == %f", self, expected];
} andReason:reason];
}
@end
@implementation NSNumber (SimpleShoulda)
- (void) shouldBeEqualToValue:(NSInteger)expected
{
[self shouldBeEqualToValue:expected withReason:@""];
}
- (void) shouldBeEqualToDoubleValue:(double)expected
{
[self shouldBeEqualToDoubleValue:expected withReason:@""];
}
@end