Skip to content

Instantly share code, notes, and snippets.

@joecannatti
Created December 24, 2010 00:36
Show Gist options
  • Save joecannatti/753748 to your computer and use it in GitHub Desktop.
Save joecannatti/753748 to your computer and use it in GitHub Desktop.
#import "Kiwi.h"
#import "KoansIncludes.h"
SPEC_BEGIN(AboutValueAssertions)
describe(@"Value Assertions", ^{
it(@"can assert truth", ^{
[[theValue(NO) should] beTrue];
});
it(@"can assert lies", ^{
[[theValue(YES) should] beFalse];
});
context(@"can assert equality", ^{
__block int expectedValue;
__block int actualValue;
beforeEach(^{
actualValue = 1 + 1;
});
it(@"in an ugly way", ^{
[[theValue(actualValue == 3) should] beTrue];
});
it(@"in a pretty way", ^{
[[theValue(actualValue) should] equal:theValue(3)];
});
});
it(@"sometimes will ask you to fill in a value", ^{
[[theValue(2) should] equal:__];
});
it(@"can assert that a variable contains nil", ^{
NSObject *object = [NSObject new];
[object shouldBeNil];
});
it(@"can assert that a variable does not contains nil", ^{
NSObject *object = nil;
[object shouldNotBeNil];
});
it(@"can assert that two objects are equal", ^{
[[@"Panda" should] equal:@"Panda1"];
});
it(@"can assert that two objects are not equal", ^{
[[@"Panda" shouldNot] equal:@"Panda"];
});
it(@"can assert that floating point values are equal within a delta", ^{
[[theValue(22.0f/7.0f) should] equal:(22.0/7.0) withDelta:0.000f];
});
it(@"can assert that a value is within a range", ^{
[[theValue(4) should] beWithin:theValue(4) of:theValue(77)];
});
it(@"can assert that a value is less than another value", ^{
[[theValue(4) should] beLessThan:theValue(4)];
});
it(@"can assert that a value is greater than another value", ^{
[[theValue(4) should] beGreaterThan:theValue(4)];
});
it(@"can assert that a value is less than or equal to another value", ^{
[[theValue(4) should] beLessThanOrEqualTo:theValue(3)];
});
it(@"can assert that a value is greater than or equal to another value", ^{
[[theValue(4) should] beGreaterThanOrEqualTo:theValue(5)];
});
it(@"can assert that a value is between to values", ^{
[[theValue(4) should] beBetween:theValue(5) and:theValue(7)];
});
it(@"can assert two variable contain the same pointer", ^{
NSString *panda = @"panda";
NSString *samePanda = [panda mutableCopy];
[[panda should] beIdenticalTo:samePanda];
});
});
SPEC_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment