Skip to content

Instantly share code, notes, and snippets.

@jspahrsummers
Created October 16, 2012 05:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jspahrsummers/3897415 to your computer and use it in GitHub Desktop.
Save jspahrsummers/3897415 to your computer and use it in GitHub Desktop.
Example usage of a CGRectDivide replacement macro
describe(@"CGRectDivide macro", ^{
CGRect rect = CGRectMake(10, 20, 30, 40);
it(@"should accept NULLs", ^{
CGRectDivide(rect, NULL, NULL, 10, CGRectMinXEdge);
});
it(@"should accept pointers", ^{
CGRect slice, remainder;
CGRectDivide(rect, &slice, &remainder, 10, CGRectMinXEdge);
expect(slice).to.equal(CGRectMake(10, 20, 10, 40));
expect(remainder).to.equal(CGRectMake(20, 20, 20, 40));
});
it(@"should accept raw variables", ^{
CGRect slice, remainder;
CGRectDivide(rect, slice, remainder, 10, CGRectMinXEdge);
expect(slice).to.equal(CGRectMake(10, 20, 10, 40));
expect(remainder).to.equal(CGRectMake(20, 20, 20, 40));
});
it(@"should accept properties", ^{
GeometryTestObject *obj = [[GeometryTestObject alloc] init];
expect(obj).notTo.beNil();
CGRectDivide(rect, obj.slice, obj.remainder, 10, CGRectMinXEdge);
expect(obj.slice).to.equal(CGRectMake(10, 20, 10, 40));
expect(obj.remainder).to.equal(CGRectMake(20, 20, 20, 40));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment