forked from cedarbdd/cedar
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AddedHamcrestock framework to project
- Loading branch information
Adam Milligan
committed
Jun 30, 2010
1 parent
56da352
commit 91ffc0c
Showing
127 changed files
with
6,468 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Cedar.xcodeproj/pivotal.mode1v3 | ||
Cedar.xcodeproj/pivotal.pbxuser | ||
OCHamcrest.framework | ||
build | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// OCHamcrest - HCAllOf.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
// Inherited | ||
#import "HCBaseMatcher.h" | ||
|
||
|
||
/** | ||
Calculates the logical conjunction of multiple matchers. | ||
Evaluation is shortcut, so subsequent matchers are not called if an earlier matcher returns | ||
@c NO. | ||
*/ | ||
@interface HCAllOf : HCBaseMatcher | ||
{ | ||
NSArray* matchers; | ||
} | ||
|
||
+ (HCAllOf*) allOf:(NSArray*)theMatchers; | ||
- (id) initWithMatchers:(NSArray*)theMatchers; | ||
|
||
@end | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
Evaluates to @c YES only if @b all of the passed in matchers evaluate to @c YES. | ||
@param matcher Comma-separated list of matchers ending with @c nil. | ||
*/ | ||
id<HCMatcher> HC_allOf(id<HCMatcher> matcher, ...); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
|
||
#ifdef HC_SHORTHAND | ||
|
||
/** | ||
Shorthand for HC_allOf, available if HC_SHORTHAND is defined. | ||
*/ | ||
#define allOf HC_allOf | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// OCHamcrest - HCAnyOf.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
// Inherited | ||
#import "HCBaseMatcher.h" | ||
|
||
|
||
/** | ||
Calculates the logical disjunction of multiple matchers. | ||
Evaluation is shortcut, so the subsequent matchers are not called if an earlier matcher returns | ||
@c YES. | ||
*/ | ||
@interface HCAnyOf : HCBaseMatcher | ||
{ | ||
NSArray* matchers; | ||
} | ||
|
||
+ (HCAnyOf*) anyOf:(NSArray*)theMatchers; | ||
- (id) initWithMatchers:(NSArray*)theMatchers; | ||
|
||
@end | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
Evaluates to @c YES if @b any of the passed in matchers evaluate to @c YES. | ||
@param matcher Comma-separated list of matchers ending with @c nil. | ||
*/ | ||
id<HCMatcher> HC_anyOf(id<HCMatcher> matcher, ...); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
|
||
#ifdef HC_SHORTHAND | ||
|
||
/** | ||
Shorthand for HC_anyOf, available if HC_SHORTHAND is defined. | ||
*/ | ||
#define anyOf HC_anyOf | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// OCHamcrest - HCBaseDescription.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
// Inherited | ||
#import <Foundation/Foundation.h> | ||
#import "HCDescription.h" | ||
|
||
|
||
/** | ||
Base class for all HCDescription implementations. | ||
*/ | ||
@interface HCBaseDescription : NSObject<HCDescription> | ||
@end | ||
|
||
|
||
/** | ||
Methods that must be provided by subclasses of HCBaseDescription. | ||
*/ | ||
@interface HCBaseDescription (SubclassMustImplement) | ||
|
||
/** | ||
Append the string @a str to the description. | ||
*/ | ||
- (void) append:(NSString*)str; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// OCHamcrest - HCBaseMatcher.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
// Inherited | ||
#import <Foundation/Foundation.h> | ||
#import "HCMatcher.h" | ||
|
||
|
||
/** | ||
Base class for all Matcher implementations. | ||
Most implementations can just implement matches: and let matches:describingMismatchTo: call | ||
it. But if it makes more sense to generate the mismatch description during the matching, | ||
override matches:describingMismatchTo: and have matches: call it with a nil description. | ||
*/ | ||
@interface HCBaseMatcher : NSObject<HCMatcher> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// OCHamcrest - HCBoxNumber.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
#ifdef __cplusplus | ||
|
||
namespace hamcrest { | ||
|
||
/** | ||
Boxes scalar value in NSNumber, specialized per type. | ||
*/ | ||
template <typename T> | ||
inline | ||
NSNumber* boxNumber(T value) | ||
{ return nil; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(BOOL value) | ||
{ return [NSNumber numberWithBool:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(char value) | ||
{ return [NSNumber numberWithChar:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(double value) | ||
{ return [NSNumber numberWithDouble:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(float value) | ||
{ return [NSNumber numberWithFloat:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(int value) | ||
{ return [NSNumber numberWithInt:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(long value) | ||
{ return [NSNumber numberWithLong:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(long long value) | ||
{ return [NSNumber numberWithLongLong:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(short value) | ||
{ return [NSNumber numberWithShort:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(unsigned char value) | ||
{ return [NSNumber numberWithUnsignedChar:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(unsigned int value) | ||
{ return [NSNumber numberWithUnsignedInt:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(unsigned long value) | ||
{ return [NSNumber numberWithUnsignedLong:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(unsigned long long value) | ||
{ return [NSNumber numberWithUnsignedLongLong:value]; } | ||
|
||
template <> | ||
inline | ||
NSNumber* boxNumber(unsigned short value) | ||
{ return [NSNumber numberWithUnsignedShort:value]; } | ||
|
||
} // namespace hamcrest | ||
|
||
#endif // __cplusplus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// OCHamcrest - HCDescribedAs.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
// Inherited | ||
#import "HCBaseMatcher.h" | ||
|
||
|
||
/** | ||
Provides a custom description to another matcher. | ||
*/ | ||
@interface HCDescribedAs : HCBaseMatcher | ||
{ | ||
NSString* descriptionTemplate; | ||
id<HCMatcher> matcher; | ||
NSArray* values; | ||
} | ||
|
||
+ (HCDescribedAs*) describedAs:(NSString*)description | ||
forMatcher:(id<HCMatcher>)aMatcher | ||
overValues:(NSArray*)templateValues; | ||
- (id) initWithDescription:(NSString*)description | ||
forMatcher:(id<HCMatcher>)aMatcher | ||
overValues:(NSArray*)templateValues; | ||
|
||
@end | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
Wraps an existing matcher and overrides the description when it fails. | ||
Optional values following the matcher are substituted for \%0, \%1, etc. | ||
The last argument must be nil. | ||
*/ | ||
id<HCMatcher> HC_describedAs(NSString* description, id<HCMatcher> matcher, ...); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
|
||
#ifdef HC_SHORTHAND | ||
|
||
/** | ||
Shorthand for HC_describedAs, available if HC_SHORTHAND is defined. | ||
*/ | ||
#define describedAs HC_describedAs | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// OCHamcrest - HCDescription.h | ||
// Copyright 2009 www.hamcrest.org. See LICENSE.txt | ||
// | ||
// Created by: Jon Reid | ||
// | ||
|
||
// Mac | ||
#import <Foundation/Foundation.h> | ||
|
||
@protocol HCSelfDescribing; | ||
|
||
|
||
/** | ||
A description of an HCMatcher. | ||
An HCMatcher will describe itself to a description which can later be used for reporting. | ||
*/ | ||
@protocol HCDescription | ||
|
||
/** | ||
Appends some plain text to the description. | ||
@return self | ||
*/ | ||
- (id<HCDescription>) appendText:(NSString*)text; | ||
|
||
/** | ||
Appends description of HCSelfDescribing value to self. | ||
@return self | ||
*/ | ||
- (id<HCDescription>) appendDescriptionOf:(id<HCSelfDescribing>)value; | ||
|
||
/** | ||
Appends an arbitary value to the description. | ||
*/ | ||
- (id<HCDescription>) appendValue:(id)value; | ||
|
||
/** | ||
Appends a list of objects to the description. | ||
*/ | ||
- (id<HCDescription>) appendList:(NSArray*)values | ||
start:(NSString*)start separator:(NSString*)separator end:(NSString*)end; | ||
|
||
@end |
Oops, something went wrong.