Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

issue #206 - Rework support for Hamcrest matchers using a generic mec…

…hanism instead
  • Loading branch information...
commit 0080ba57af184c881d2036f23c4698fc71158257 1 parent 3c5d93c
@allending authored
View
2  Classes/KWContainMatcher.m
@@ -6,7 +6,7 @@
#import "KWContainMatcher.h"
#import "KWFormatter.h"
-#import "KWHamrestMatchingAdditions.h"
+#import "KWGenericMatchingAdditions.h"
@interface KWContainMatcher()
View
17 Classes/KWGenericMatchEvaluator.h
@@ -0,0 +1,17 @@
+//
+// KWGenericMatcher.h
+// Kiwi
+//
+// Created by Allen Ding on 1/31/13.
+// Copyright (c) 2013 Allen Ding. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface KWGenericMatchEvaluator : NSObject
+
++ (BOOL)isGenericMatcher:(id)object;
+
++ (BOOL)genericMatcher:(id)matcher matches:(id)object;
+
+@end
View
67 Classes/KWGenericMatchEvaluator.m
@@ -0,0 +1,67 @@
+//
+// KWGenericMatcher.m
+// Kiwi
+//
+// Created by Allen Ding on 1/31/13.
+// Copyright (c) 2013 Allen Ding. All rights reserved.
+//
+
+#import "KWGenericMatchEvaluator.h"
+#import "KWStringUtilities.h"
+#import "KWObjCUtilities.h"
+#import <objc/runtime.h>
+
+@implementation KWGenericMatchEvaluator
+
+// Returns true only if the object has a method with the signature "- (void)matches:(id)object"
++ (BOOL)isGenericMatcher:(id)object
+{
+ Class theClass = object_getClass(object);
+
+ if (theClass == NULL) {
+ return NO;
+ }
+
+ Method method = class_getInstanceMethod(theClass, @selector(matches:));
+
+ if (method == NULL) {
+ return NO;
+ }
+
+ const char *cEncoding = method_getTypeEncoding(method);
+
+ if (cEncoding == NULL) {
+ return NO;
+ }
+
+ NSMethodSignature *signature = [NSMethodSignature signatureWithObjCTypes:cEncoding];
+
+ if (!KWObjCTypeEqualToObjCType(@encode(BOOL), [signature methodReturnType])) {
+ return NO;
+ }
+
+ if ([signature numberOfArguments] != 3) {
+ return NO;
+ }
+
+ if (!KWObjCTypeEqualToObjCType(@encode(id), [signature getArgumentTypeAtIndex:2])) {
+ return NO;
+ }
+
+ return YES;
+}
+
++ (BOOL)genericMatcher:(id)matcher matches:(id)object
+{
+ NSString *targetEncoding = KWEncodingWithObjCTypes(@encode(BOOL), @encode(id), @encode(SEL), @encode(id), nil);
+ NSMethodSignature *signature = [NSMethodSignature signatureWithObjCTypes:[targetEncoding UTF8String]];
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
+ [invocation setSelector:@selector(matches:)];
+ [invocation setArgument:&object atIndex:2];
+ [invocation invokeWithTarget:matcher];
+ BOOL result = NO;
+ [invocation getReturnValue:&result];
+ return result;
+}
+
+@end
View
10 Classes/KWHamcrestMatcher.h → Classes/KWGenericMatcher.h
@@ -1,5 +1,5 @@
//
-// KWHamcrestMatcher.h
+// KWGenericMatcher.h
// Kiwi
//
// Created by Luke Redpath on 24/01/2011.
@@ -9,15 +9,11 @@
#import <Foundation/Foundation.h>
#import "KWMatcher.h"
-@protocol HCMatcher;
-
-@interface KWHamcrestMatcher : KWMatcher {
- id<HCMatcher> hamcrestMatcher;
-}
+@interface KWGenericMatcher : KWMatcher
#pragma mark -
#pragma mark Configuring Matchers
-- (void)match:(id<HCMatcher>)aMatcher;
+- (void)match:(id)aMatcher;
@end
View
16 Classes/KWHamcrestMatcher.m → Classes/KWGenericMatcher.m
@@ -1,24 +1,24 @@
//
-// KWHamcrestMatcher.m
+// KWGenericMatcher.m
// Kiwi
//
// Created by Luke Redpath on 24/01/2011.
// Copyright 2011 Allen Ding. All rights reserved.
//
-#import "KWHamcrestMatcher.h"
-#import "KWHCMatcher.h"
+#import "KWGenericMatcher.h"
+#import "KWGenericMatchEvaluator.h"
-@interface KWHamcrestMatcher ()
+@interface KWGenericMatcher ()
#pragma mark -
#pragma mark Properties
-@property (nonatomic, retain) id<HCMatcher> matcher;
+@property (nonatomic, retain) id matcher;
@end
-@implementation KWHamcrestMatcher
+@implementation KWGenericMatcher
@synthesize matcher;
@@ -32,7 +32,7 @@ - (void)dealloc
#pragma mark Matching
- (BOOL)evaluate {
- return [self.matcher matches:self.subject];
+ return [KWGenericMatchEvaluator genericMatcher:self.matcher matches:self.subject];
}
- (NSString *)failureMessageForShould {
@@ -54,7 +54,7 @@ + (NSArray *)matcherStrings {
#pragma mark -
#pragma mark Configuring Matchers
-- (void)match:(id<HCMatcher>)aMatcher;
+- (void)match:(id)aMatcher;
{
self.matcher = aMatcher;
}
View
12 Classes/KWHamrestMatchingAdditions.h → Classes/KWGenericMatchingAdditions.h
@@ -8,28 +8,26 @@
#import <Foundation/Foundation.h>
-@interface NSObject (KiwiHamcrestAdditions)
+@interface NSObject (KiwiGenericMatchingAdditions)
- (BOOL)isEqualOrMatches:(id)object;
@end
-@protocol HCMatcher;
-
-@interface NSArray (KiwiHamcrestAdditions)
+@interface NSArray (KiwiGenericMatchingAdditions)
- (BOOL)containsObjectEqualToOrMatching:(id)object;
-- (BOOL)containsObjectMatching:(id<HCMatcher>)matcher;
+- (BOOL)containsObjectMatching:(id)matcher;
@end
-@interface NSSet (KiwiHamcrestAdditions)
+@interface NSSet (KiwiGenericMatchingAdditions)
- (BOOL)containsObjectEqualToOrMatching:(id)object;
@end
-@interface NSOrderedSet (KiwiHamcrestAdditions)
+@interface NSOrderedSet (KiwiGenericMatchingAdditions)
- (BOOL)containsObjectEqualToOrMatching:(id)object;
View
31 Classes/KWHamrestMatchingAdditions.m → Classes/KWGenericMatchingAdditions.m
@@ -6,37 +6,38 @@
// Copyright 2011 Allen Ding. All rights reserved.
//
-#import "KWHamrestMatchingAdditions.h"
-#import "KWHCMatcher.h"
+#import "KWGenericMatchingAdditions.h"
+#import "KWGenericMatcher.h"
+#import "KWGenericMatchEvaluator.h"
-@implementation NSObject (KiwiHamcrestAdditions)
+@implementation NSObject (KiwiGenericMatchingAdditions)
- (BOOL)isEqualOrMatches:(id)object
{
- if ([self conformsToProtocol:@protocol(HCMatcher)]) {
- return [(id<HCMatcher>)self matches:object];
+ if ([KWGenericMatchEvaluator isGenericMatcher:self]) {
+ return [KWGenericMatchEvaluator genericMatcher:self matches:object];
}
return [self isEqual:object];
}
@end
-@implementation NSArray (KiwiHamcrestAdditions)
+@implementation NSArray (KiwiGenericMatchingAdditions)
- (BOOL)containsObjectEqualToOrMatching:(id)object
{
- if ([object conformsToProtocol:@protocol(HCMatcher)]) {
+ if ([KWGenericMatchEvaluator isGenericMatcher:object]) {
return [self containsObjectMatching:object];
}
return [self containsObject:object];
}
-- (BOOL)containsObjectMatching:(id<HCMatcher>)matcher
+- (BOOL)containsObjectMatching:(id)matcher
{
NSIndexSet *indexSet = [self indexesOfObjectsPassingTest:^(id obj, NSUInteger idx, BOOL *stop) {
- BOOL matches = [matcher matches:obj];
+ BOOL matches = [KWGenericMatchEvaluator genericMatcher:matcher matches:obj];
if (matches) {
- *stop = YES;
+ *stop = YES;
}
return matches;
}];
@@ -46,11 +47,11 @@ - (BOOL)containsObjectMatching:(id<HCMatcher>)matcher
@end
-@implementation NSSet (KiwiHamcrestAdditions)
+@implementation NSSet (KiwiGenericMatchingAdditions)
- (BOOL)containsObjectEqualToOrMatching:(id)object
{
- if ([object conformsToProtocol:@protocol(HCMatcher)]) {
+ if ([KWGenericMatchEvaluator isGenericMatcher:object]) {
return [[self allObjects] containsObjectMatching:object];
}
return [self containsObject:object];
@@ -58,16 +59,14 @@ - (BOOL)containsObjectEqualToOrMatching:(id)object
@end
-@implementation NSOrderedSet (KiwiHamcrestAdditions)
+@implementation NSOrderedSet (KiwiGenericMatchingAdditions)
- (BOOL)containsObjectEqualToOrMatching:(id)object
{
- if ([object conformsToProtocol:@protocol(HCMatcher)]) {
+ if ([KWGenericMatchEvaluator isGenericMatcher:object]) {
return [[self array] containsObjectMatching:object];
}
return [self containsObject:object];
}
@end
-
-
View
12 Classes/KWHCMatcher.h
@@ -1,12 +0,0 @@
-/**
- * This is a minimal version of HCMatcher from the Hamcrest library, purely
- * to support Hamcrest integration with Kiwi.
- *
- * The Hamcrest project can be found here: http://code.google.com/p/hamcrest/
- */
-
-#import <Foundation/Foundation.h>
-
-@protocol HCMatcher <NSObject>
-- (BOOL)matches:(id)item;
-@end
View
4 Classes/KWHaveValueMatcher.m
@@ -7,8 +7,8 @@
//
#import "KWHaveValueMatcher.h"
-#import "KWHamrestMatchingAdditions.h"
-#import "KWHCMatcher.h"
+#import "KWGenericMatchingAdditions.h"
+#import "KWGenericMatcher.h"
#import "KWFormatter.h"
@interface KWHaveValueMatcher()
View
10 Classes/KWMessagePattern.m
@@ -11,7 +11,7 @@
#import "KWValue.h"
#import "NSInvocation+KiwiAdditions.h"
#import "NSMethodSignature+KiwiAdditions.h"
-#import "KWHCMatcher.h"
+#import "KWGenericMatchEvaluator.h"
#import "Kiwi.h"
@implementation KWMessagePattern
@@ -137,14 +137,14 @@ - (BOOL)argumentFiltersMatchInvocationArguments:(NSInvocation *)anInvocation {
continue;
}
- if ([argumentFilter conformsToProtocol:@protocol(HCMatcher)]) {
- id<HCMatcher> matcher = (id<HCMatcher>)argumentFilter;
+ if ([KWGenericMatchEvaluator isGenericMatcher:argumentFilter]) {
+ id matcher = argumentFilter;
if ([object isKindOfClass:[KWValue class]] && [object isNumeric]) {
NSNumber *number = [object numberValue];
- if (![matcher matches:number]) {
+ if (![KWGenericMatchEvaluator genericMatcher:matcher matches:number]) {
return NO;
}
- } else if (![matcher matches:object]) {
+ } else if (![KWGenericMatchEvaluator genericMatcher:matcher matches:object]) {
return NO;
}
} else if ([argumentFilter isEqual:[KWNull null]]) {
View
4 Classes/KWStringContainsMatcher.h
@@ -7,14 +7,14 @@
//
#import <Foundation/Foundation.h>
-#import "KWHCMatcher.h"
-@interface KWStringContainsMatcher : NSObject <HCMatcher> {
+@interface KWStringContainsMatcher : NSObject {
NSString *substring;
}
+ (id)matcherWithSubstring:(NSString *)aSubstring;
- (id)initWithSubstring:(NSString *)aSubstring;
+- (BOOL)matches:(id)object;
@end
View
3  Classes/KWStringPrefixMatcher.h
@@ -7,9 +7,8 @@
//
#import <Foundation/Foundation.h>
-#import "KWHCMatcher.h"
-@interface KWStringPrefixMatcher : NSObject <HCMatcher> {
+@interface KWStringPrefixMatcher : NSObject {
NSString *prefix;
}
+ (id)matcherWithPrefix:(NSString *)aPrefix;
View
2  Classes/Kiwi.h
@@ -48,7 +48,7 @@ extern "C" {
#import "KWFailure.h"
#import "KWFormatter.h"
#import "KWFutureObject.h"
-#import "KWHamcrestMatcher.h"
+#import "KWGenericMatcher.h"
#import "KWHaveMatcher.h"
#import "KWHaveValueMatcher.h"
#import "KWInequalityMatcher.h"
View
74 Kiwi.xcodeproj/project.pbxproj
@@ -30,6 +30,10 @@
511901A716A95CDE006E7359 /* KWChangeMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 511901A416A95CDE006E7359 /* KWChangeMatcher.m */; };
511901A816A95CDE006E7359 /* KWChangeMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 511901A416A95CDE006E7359 /* KWChangeMatcher.m */; };
89F9CB7C16B1C2C400E87D34 /* KWFunctionalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 89F9CB7B16B1C2C400E87D34 /* KWFunctionalTests.m */; };
+ 9F90FBF016BA5FF20057426D /* KWGenericMatchEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F90FBEE16BA5FF20057426D /* KWGenericMatchEvaluator.h */; };
+ 9F90FBF116BA5FF20057426D /* KWGenericMatchEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F90FBEE16BA5FF20057426D /* KWGenericMatchEvaluator.h */; };
+ 9F90FBF216BA5FF20057426D /* KWGenericMatchEvaluator.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F90FBEF16BA5FF20057426D /* KWGenericMatchEvaluator.m */; };
+ 9F90FBF316BA5FF20057426D /* KWGenericMatchEvaluator.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F90FBEF16BA5FF20057426D /* KWGenericMatchEvaluator.m */; };
9F982A3816A801800030A0B1 /* Carrier.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982A1E16A801800030A0B1 /* Carrier.m */; };
9F982A3916A801800030A0B1 /* Cruiser.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982A2016A801800030A0B1 /* Cruiser.m */; };
9F982A3A16A801800030A0B1 /* Engine.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982A2216A801800030A0B1 /* Engine.m */; };
@@ -198,14 +202,14 @@
9F982D7916A802920030A0B1 /* KWFutureObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8616A802920030A0B1 /* KWFutureObject.h */; };
9F982D7A16A802920030A0B1 /* KWFutureObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8716A802920030A0B1 /* KWFutureObject.m */; };
9F982D7B16A802920030A0B1 /* KWFutureObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8716A802920030A0B1 /* KWFutureObject.m */; };
- 9F982D7C16A802920030A0B1 /* KWHamcrestMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8816A802920030A0B1 /* KWHamcrestMatcher.h */; };
- 9F982D7D16A802920030A0B1 /* KWHamcrestMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8816A802920030A0B1 /* KWHamcrestMatcher.h */; };
- 9F982D7E16A802920030A0B1 /* KWHamcrestMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8916A802920030A0B1 /* KWHamcrestMatcher.m */; };
- 9F982D7F16A802920030A0B1 /* KWHamcrestMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8916A802920030A0B1 /* KWHamcrestMatcher.m */; };
- 9F982D8016A802920030A0B1 /* KWHamrestMatchingAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8A16A802920030A0B1 /* KWHamrestMatchingAdditions.h */; };
- 9F982D8116A802920030A0B1 /* KWHamrestMatchingAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8A16A802920030A0B1 /* KWHamrestMatchingAdditions.h */; };
- 9F982D8216A802920030A0B1 /* KWHamrestMatchingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8B16A802920030A0B1 /* KWHamrestMatchingAdditions.m */; };
- 9F982D8316A802920030A0B1 /* KWHamrestMatchingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8B16A802920030A0B1 /* KWHamrestMatchingAdditions.m */; };
+ 9F982D7C16A802920030A0B1 /* KWGenericMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8816A802920030A0B1 /* KWGenericMatcher.h */; };
+ 9F982D7D16A802920030A0B1 /* KWGenericMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8816A802920030A0B1 /* KWGenericMatcher.h */; };
+ 9F982D7E16A802920030A0B1 /* KWGenericMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8916A802920030A0B1 /* KWGenericMatcher.m */; };
+ 9F982D7F16A802920030A0B1 /* KWGenericMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8916A802920030A0B1 /* KWGenericMatcher.m */; };
+ 9F982D8016A802920030A0B1 /* KWGenericMatchingAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8A16A802920030A0B1 /* KWGenericMatchingAdditions.h */; };
+ 9F982D8116A802920030A0B1 /* KWGenericMatchingAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8A16A802920030A0B1 /* KWGenericMatchingAdditions.h */; };
+ 9F982D8216A802920030A0B1 /* KWGenericMatchingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8B16A802920030A0B1 /* KWGenericMatchingAdditions.m */; };
+ 9F982D8316A802920030A0B1 /* KWGenericMatchingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8B16A802920030A0B1 /* KWGenericMatchingAdditions.m */; };
9F982D8416A802920030A0B1 /* KWHaveMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8C16A802920030A0B1 /* KWHaveMatcher.h */; };
9F982D8516A802920030A0B1 /* KWHaveMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8C16A802920030A0B1 /* KWHaveMatcher.h */; };
9F982D8616A802920030A0B1 /* KWHaveMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8D16A802920030A0B1 /* KWHaveMatcher.m */; };
@@ -214,8 +218,6 @@
9F982D8916A802920030A0B1 /* KWHaveValueMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C8E16A802920030A0B1 /* KWHaveValueMatcher.h */; };
9F982D8A16A802920030A0B1 /* KWHaveValueMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8F16A802920030A0B1 /* KWHaveValueMatcher.m */; };
9F982D8B16A802920030A0B1 /* KWHaveValueMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C8F16A802920030A0B1 /* KWHaveValueMatcher.m */; };
- 9F982D8C16A802920030A0B1 /* KWHCMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C9016A802920030A0B1 /* KWHCMatcher.h */; };
- 9F982D8D16A802920030A0B1 /* KWHCMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C9016A802920030A0B1 /* KWHCMatcher.h */; };
9F982D8E16A802920030A0B1 /* KWInequalityMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C9116A802920030A0B1 /* KWInequalityMatcher.h */; };
9F982D8F16A802920030A0B1 /* KWInequalityMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F982C9116A802920030A0B1 /* KWInequalityMatcher.h */; };
9F982D9016A802920030A0B1 /* KWInequalityMatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982C9216A802920030A0B1 /* KWInequalityMatcher.m */; };
@@ -375,7 +377,7 @@
9F982E2A16A802920030A0B1 /* NSValue+KiwiAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982CDF16A802920030A0B1 /* NSValue+KiwiAdditions.m */; };
9F982E2B16A802920030A0B1 /* NSValue+KiwiAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F982CDF16A802920030A0B1 /* NSValue+KiwiAdditions.m */; };
A352E9E812EDC30A0049C691 /* KWHaveValueMatcherTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A352E9E712EDC30A0049C691 /* KWHaveValueMatcherTest.m */; };
- A352EA1B12EDC8380049C691 /* KWHamcrestMatcherTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A352EA1A12EDC8380049C691 /* KWHamcrestMatcherTest.m */; };
+ A352EA1B12EDC8380049C691 /* KWGenericMatcherTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A352EA1A12EDC8380049C691 /* KWGenericMatcherTest.m */; };
A385CAE813AA7EA200DCA951 /* KWUserDefinedMatcherTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A385CAE713AA7EA200DCA951 /* KWUserDefinedMatcherTest.m */; };
C922D1DD158045FC00995B43 /* KWStringContainsMatcherTest.m in Sources */ = {isa = PBXBuildFile; fileRef = C922D1DC158045FC00995B43 /* KWStringContainsMatcherTest.m */; };
F5015CBD1158404E002E9A98 /* libKiwi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F5015B9F11583A77002E9A98 /* libKiwi.a */; };
@@ -437,6 +439,8 @@
832C83C7157263B300F160D5 /* libKiwi-OSX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libKiwi-OSX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
89F9CB7B16B1C2C400E87D34 /* KWFunctionalTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWFunctionalTests.m; sourceTree = "<group>"; };
9F4C095816B16A6D00FCCCD3 /* Release.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = Release.txt; sourceTree = "<group>"; };
+ 9F90FBEE16BA5FF20057426D /* KWGenericMatchEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWGenericMatchEvaluator.h; path = Classes/KWGenericMatchEvaluator.h; sourceTree = "<group>"; };
+ 9F90FBEF16BA5FF20057426D /* KWGenericMatchEvaluator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWGenericMatchEvaluator.m; path = Classes/KWGenericMatchEvaluator.m; sourceTree = "<group>"; };
9F982A1616A7FCD00030A0B1 /* Kiwi.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Kiwi.podspec; sourceTree = "<group>"; };
9F982A1D16A801800030A0B1 /* Carrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Carrier.h; path = "Test Classes/Carrier.h"; sourceTree = "<group>"; };
9F982A1E16A801800030A0B1 /* Carrier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Carrier.m; path = "Test Classes/Carrier.m"; sourceTree = "<group>"; };
@@ -546,15 +550,14 @@
9F982C8516A802920030A0B1 /* KWFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWFormatter.m; path = Classes/KWFormatter.m; sourceTree = "<group>"; };
9F982C8616A802920030A0B1 /* KWFutureObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWFutureObject.h; path = Classes/KWFutureObject.h; sourceTree = "<group>"; };
9F982C8716A802920030A0B1 /* KWFutureObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWFutureObject.m; path = Classes/KWFutureObject.m; sourceTree = "<group>"; };
- 9F982C8816A802920030A0B1 /* KWHamcrestMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWHamcrestMatcher.h; path = Classes/KWHamcrestMatcher.h; sourceTree = "<group>"; };
- 9F982C8916A802920030A0B1 /* KWHamcrestMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWHamcrestMatcher.m; path = Classes/KWHamcrestMatcher.m; sourceTree = "<group>"; };
- 9F982C8A16A802920030A0B1 /* KWHamrestMatchingAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWHamrestMatchingAdditions.h; path = Classes/KWHamrestMatchingAdditions.h; sourceTree = "<group>"; };
- 9F982C8B16A802920030A0B1 /* KWHamrestMatchingAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWHamrestMatchingAdditions.m; path = Classes/KWHamrestMatchingAdditions.m; sourceTree = "<group>"; };
+ 9F982C8816A802920030A0B1 /* KWGenericMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWGenericMatcher.h; path = Classes/KWGenericMatcher.h; sourceTree = "<group>"; };
+ 9F982C8916A802920030A0B1 /* KWGenericMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWGenericMatcher.m; path = Classes/KWGenericMatcher.m; sourceTree = "<group>"; };
+ 9F982C8A16A802920030A0B1 /* KWGenericMatchingAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWGenericMatchingAdditions.h; path = Classes/KWGenericMatchingAdditions.h; sourceTree = "<group>"; };
+ 9F982C8B16A802920030A0B1 /* KWGenericMatchingAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWGenericMatchingAdditions.m; path = Classes/KWGenericMatchingAdditions.m; sourceTree = "<group>"; };
9F982C8C16A802920030A0B1 /* KWHaveMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWHaveMatcher.h; path = Classes/KWHaveMatcher.h; sourceTree = "<group>"; };
9F982C8D16A802920030A0B1 /* KWHaveMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWHaveMatcher.m; path = Classes/KWHaveMatcher.m; sourceTree = "<group>"; };
9F982C8E16A802920030A0B1 /* KWHaveValueMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWHaveValueMatcher.h; path = Classes/KWHaveValueMatcher.h; sourceTree = "<group>"; };
9F982C8F16A802920030A0B1 /* KWHaveValueMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWHaveValueMatcher.m; path = Classes/KWHaveValueMatcher.m; sourceTree = "<group>"; };
- 9F982C9016A802920030A0B1 /* KWHCMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWHCMatcher.h; path = Classes/KWHCMatcher.h; sourceTree = "<group>"; };
9F982C9116A802920030A0B1 /* KWInequalityMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWInequalityMatcher.h; path = Classes/KWInequalityMatcher.h; sourceTree = "<group>"; };
9F982C9216A802920030A0B1 /* KWInequalityMatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWInequalityMatcher.m; path = Classes/KWInequalityMatcher.m; sourceTree = "<group>"; };
9F982C9316A802920030A0B1 /* KWIntercept.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWIntercept.h; path = Classes/KWIntercept.h; sourceTree = "<group>"; };
@@ -636,7 +639,7 @@
9F982CDF16A802920030A0B1 /* NSValue+KiwiAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSValue+KiwiAdditions.m"; path = "Classes/NSValue+KiwiAdditions.m"; sourceTree = "<group>"; };
9FFA190B16A83C23009D6FF1 /* uninstall-templates.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = "uninstall-templates.sh"; path = "Xcode Templates/uninstall-templates.sh"; sourceTree = "<group>"; };
A352E9E712EDC30A0049C691 /* KWHaveValueMatcherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWHaveValueMatcherTest.m; sourceTree = "<group>"; };
- A352EA1A12EDC8380049C691 /* KWHamcrestMatcherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = KWHamcrestMatcherTest.m; sourceTree = "<group>"; tabWidth = 4; };
+ A352EA1A12EDC8380049C691 /* KWGenericMatcherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = KWGenericMatcherTest.m; sourceTree = "<group>"; tabWidth = 4; };
A385CAE713AA7EA200DCA951 /* KWUserDefinedMatcherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = KWUserDefinedMatcherTest.m; sourceTree = "<group>"; tabWidth = 4; };
C922D1DC158045FC00995B43 /* KWStringContainsMatcherTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWStringContainsMatcherTest.m; sourceTree = "<group>"; };
F5015B8B11583A39002E9A98 /* KiwiDriver-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "KiwiDriver-Info.plist"; sourceTree = "<group>"; };
@@ -928,15 +931,16 @@
9F982C8516A802920030A0B1 /* KWFormatter.m */,
9F982C8616A802920030A0B1 /* KWFutureObject.h */,
9F982C8716A802920030A0B1 /* KWFutureObject.m */,
- 9F982C8816A802920030A0B1 /* KWHamcrestMatcher.h */,
- 9F982C8916A802920030A0B1 /* KWHamcrestMatcher.m */,
- 9F982C8A16A802920030A0B1 /* KWHamrestMatchingAdditions.h */,
- 9F982C8B16A802920030A0B1 /* KWHamrestMatchingAdditions.m */,
+ 9F982C8816A802920030A0B1 /* KWGenericMatcher.h */,
+ 9F982C8916A802920030A0B1 /* KWGenericMatcher.m */,
+ 9F90FBEE16BA5FF20057426D /* KWGenericMatchEvaluator.h */,
+ 9F90FBEF16BA5FF20057426D /* KWGenericMatchEvaluator.m */,
+ 9F982C8A16A802920030A0B1 /* KWGenericMatchingAdditions.h */,
+ 9F982C8B16A802920030A0B1 /* KWGenericMatchingAdditions.m */,
9F982C8C16A802920030A0B1 /* KWHaveMatcher.h */,
9F982C8D16A802920030A0B1 /* KWHaveMatcher.m */,
9F982C8E16A802920030A0B1 /* KWHaveValueMatcher.h */,
9F982C8F16A802920030A0B1 /* KWHaveValueMatcher.m */,
- 9F982C9016A802920030A0B1 /* KWHCMatcher.h */,
9F982C9116A802920030A0B1 /* KWInequalityMatcher.h */,
9F982C9216A802920030A0B1 /* KWInequalityMatcher.m */,
9F982C9316A802920030A0B1 /* KWIntercept.h */,
@@ -1087,7 +1091,7 @@
F5C36E91115C9F0700425FDA /* KWReceiveMatcherTest.m */,
F553B6641175D48C004FCA2E /* KWRespondToSelectorMatcherTest.m */,
A352E9E712EDC30A0049C691 /* KWHaveValueMatcherTest.m */,
- A352EA1A12EDC8380049C691 /* KWHamcrestMatcherTest.m */,
+ A352EA1A12EDC8380049C691 /* KWGenericMatcherTest.m */,
A385CAE713AA7EA200DCA951 /* KWUserDefinedMatcherTest.m */,
511901A016A95803006E7359 /* KWChangeMatcherTest.m */,
);
@@ -1154,11 +1158,10 @@
9F982D7116A802920030A0B1 /* KWFailure.h in Headers */,
9F982D7516A802920030A0B1 /* KWFormatter.h in Headers */,
9F982D7916A802920030A0B1 /* KWFutureObject.h in Headers */,
- 9F982D7D16A802920030A0B1 /* KWHamcrestMatcher.h in Headers */,
- 9F982D8116A802920030A0B1 /* KWHamrestMatchingAdditions.h in Headers */,
+ 9F982D7D16A802920030A0B1 /* KWGenericMatcher.h in Headers */,
+ 9F982D8116A802920030A0B1 /* KWGenericMatchingAdditions.h in Headers */,
9F982D8516A802920030A0B1 /* KWHaveMatcher.h in Headers */,
9F982D8916A802920030A0B1 /* KWHaveValueMatcher.h in Headers */,
- 9F982D8D16A802920030A0B1 /* KWHCMatcher.h in Headers */,
9F982D8F16A802920030A0B1 /* KWInequalityMatcher.h in Headers */,
9F982D9316A802920030A0B1 /* KWIntercept.h in Headers */,
9F982D9716A802920030A0B1 /* KWInvocationCapturer.h in Headers */,
@@ -1202,6 +1205,7 @@
9F982E2516A802920030A0B1 /* NSObject+KiwiVerifierAdditions.h in Headers */,
9F982E2916A802920030A0B1 /* NSValue+KiwiAdditions.h in Headers */,
511901A616A95CDE006E7359 /* KWChangeMatcher.h in Headers */,
+ 9F90FBF116BA5FF20057426D /* KWGenericMatchEvaluator.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1253,11 +1257,10 @@
9F982D7016A802920030A0B1 /* KWFailure.h in Headers */,
9F982D7416A802920030A0B1 /* KWFormatter.h in Headers */,
9F982D7816A802920030A0B1 /* KWFutureObject.h in Headers */,
- 9F982D7C16A802920030A0B1 /* KWHamcrestMatcher.h in Headers */,
- 9F982D8016A802920030A0B1 /* KWHamrestMatchingAdditions.h in Headers */,
+ 9F982D7C16A802920030A0B1 /* KWGenericMatcher.h in Headers */,
+ 9F982D8016A802920030A0B1 /* KWGenericMatchingAdditions.h in Headers */,
9F982D8416A802920030A0B1 /* KWHaveMatcher.h in Headers */,
9F982D8816A802920030A0B1 /* KWHaveValueMatcher.h in Headers */,
- 9F982D8C16A802920030A0B1 /* KWHCMatcher.h in Headers */,
9F982D8E16A802920030A0B1 /* KWInequalityMatcher.h in Headers */,
9F982D9216A802920030A0B1 /* KWIntercept.h in Headers */,
9F982D9616A802920030A0B1 /* KWInvocationCapturer.h in Headers */,
@@ -1301,6 +1304,7 @@
9F982E2416A802920030A0B1 /* NSObject+KiwiVerifierAdditions.h in Headers */,
9F982E2816A802920030A0B1 /* NSValue+KiwiAdditions.h in Headers */,
511901A516A95CDE006E7359 /* KWChangeMatcher.h in Headers */,
+ 9F90FBF016BA5FF20057426D /* KWGenericMatchEvaluator.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1504,8 +1508,8 @@
9F982D7316A802920030A0B1 /* KWFailure.m in Sources */,
9F982D7716A802920030A0B1 /* KWFormatter.m in Sources */,
9F982D7B16A802920030A0B1 /* KWFutureObject.m in Sources */,
- 9F982D7F16A802920030A0B1 /* KWHamcrestMatcher.m in Sources */,
- 9F982D8316A802920030A0B1 /* KWHamrestMatchingAdditions.m in Sources */,
+ 9F982D7F16A802920030A0B1 /* KWGenericMatcher.m in Sources */,
+ 9F982D8316A802920030A0B1 /* KWGenericMatchingAdditions.m in Sources */,
9F982D8716A802920030A0B1 /* KWHaveMatcher.m in Sources */,
9F982D8B16A802920030A0B1 /* KWHaveValueMatcher.m in Sources */,
9F982D9116A802920030A0B1 /* KWInequalityMatcher.m in Sources */,
@@ -1546,6 +1550,7 @@
9F982E2716A802920030A0B1 /* NSObject+KiwiVerifierAdditions.m in Sources */,
9F982E2B16A802920030A0B1 /* NSValue+KiwiAdditions.m in Sources */,
511901A816A95CDE006E7359 /* KWChangeMatcher.m in Sources */,
+ 9F90FBF316BA5FF20057426D /* KWGenericMatchEvaluator.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1587,8 +1592,8 @@
9F982D7216A802920030A0B1 /* KWFailure.m in Sources */,
9F982D7616A802920030A0B1 /* KWFormatter.m in Sources */,
9F982D7A16A802920030A0B1 /* KWFutureObject.m in Sources */,
- 9F982D7E16A802920030A0B1 /* KWHamcrestMatcher.m in Sources */,
- 9F982D8216A802920030A0B1 /* KWHamrestMatchingAdditions.m in Sources */,
+ 9F982D7E16A802920030A0B1 /* KWGenericMatcher.m in Sources */,
+ 9F982D8216A802920030A0B1 /* KWGenericMatchingAdditions.m in Sources */,
9F982D8616A802920030A0B1 /* KWHaveMatcher.m in Sources */,
9F982D8A16A802920030A0B1 /* KWHaveValueMatcher.m in Sources */,
9F982D9016A802920030A0B1 /* KWInequalityMatcher.m in Sources */,
@@ -1630,6 +1635,7 @@
9F982E2A16A802920030A0B1 /* NSValue+KiwiAdditions.m in Sources */,
511901A116A95803006E7359 /* KWChangeMatcherTest.m in Sources */,
511901A716A95CDE006E7359 /* KWChangeMatcher.m in Sources */,
+ 9F90FBF216BA5FF20057426D /* KWGenericMatchEvaluator.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1665,7 +1671,7 @@
F5B168DA11BCC58200200D1D /* KWExampleGroupBuilderTest.m in Sources */,
F5B16B4E11BD56AE00200D1D /* KWContextNodeTest.m in Sources */,
A352E9E812EDC30A0049C691 /* KWHaveValueMatcherTest.m in Sources */,
- A352EA1B12EDC8380049C691 /* KWHamcrestMatcherTest.m in Sources */,
+ A352EA1B12EDC8380049C691 /* KWGenericMatcherTest.m in Sources */,
A385CAE813AA7EA200DCA951 /* KWUserDefinedMatcherTest.m in Sources */,
4BA52D0115487F0C00FC957B /* KWCaptureTest.m in Sources */,
C922D1DD158045FC00995B43 /* KWStringContainsMatcherTest.m in Sources */,
View
4 Tests/KWContainMatcherTest.m
@@ -61,7 +61,7 @@ - (void)testItShouldNotMatchNonContainedArrayObjects {
STAssertFalse([matcher evaluate], @"expected negative match");
}
-- (void)testItShouldMatchContainedElementsWithHamcrestMatcher
+- (void)testItShouldMatchContainedElementsWithGenericMatcher
{
id subject = [NSArray arrayWithObjects:@"dog", @"cat", @"tiger", @"liger", nil];
id matcher = [KWContainMatcher matcherWithSubject:subject];
@@ -69,7 +69,7 @@ - (void)testItShouldMatchContainedElementsWithHamcrestMatcher
STAssertTrue([matcher evaluate], @"expected positive match");
}
-- (void)testItShouldNotMatchContainedElementsWithHamcrestMatcher
+- (void)testItShouldNotMatchContainedElementsWithGenericMatcher
{
id subject = [NSArray arrayWithObjects:@"dog", @"cat", @"tiger", @"liger", nil];
id matcher = [KWContainMatcher matcherWithSubject:subject];
View
16 Tests/KWHamcrestMatcherTest.m → Tests/KWGenericMatcherTest.m
@@ -1,5 +1,5 @@
//
-// KWHamcrestMatcherTest.m
+// KWGenericMatcherTest.m
// Kiwi
//
// Created by Luke Redpath on 24/01/2011.
@@ -12,29 +12,29 @@
#if KW_TESTS_ENABLED
-@interface KWHamcrestMatcherTest : SenTestCase
+@interface KWGenericMatcherTest : SenTestCase
@end
-@implementation KWHamcrestMatcherTest
+@implementation KWGenericMatcherTest
-- (void)testItShouldMatchObjectsThatMatchHamcrestMatchers
+- (void)testItShouldMatchObjectsThatMatchGenericMatchers
{
- id matcher = [KWHamcrestMatcher matcherWithSubject:@"Alpha Bravo"];
+ id matcher = [KWGenericMatcher matcherWithSubject:@"Alpha Bravo"];
[matcher match:hasPrefix(@"Alpha")];
STAssertTrue([matcher evaluate], @"expected positive match");
}
-- (void)testItShouldNotMatchObjectsThatMatchHamcrestMatchers
+- (void)testItShouldNotMatchObjectsThatMatchGenericMatchers
{
- id matcher = [KWHamcrestMatcher matcherWithSubject:@"Charlie Bravo"];
+ id matcher = [KWGenericMatcher matcherWithSubject:@"Charlie Bravo"];
[matcher match:hasPrefix(@"Alpha")];
STAssertFalse([matcher evaluate], @"expected negative match");
}
- (void)testItShouldHaveHumanReadableDescription
{
- id matcher = [KWHamcrestMatcher matcherWithSubject:nil];
+ id matcher = [KWGenericMatcher matcherWithSubject:nil];
[matcher match:hasPrefix(@"Alpha")];
STAssertEqualObjects(@"match a string with prefix 'Alpha'", [matcher description], @"description should match");
}
View
4 Tests/KWHaveValueMatcherTest.m
@@ -47,14 +47,14 @@ - (void)testItShouldNotMatchValuesUsingKeyPaths {
STAssertFalse([matcher evaluate], @"expected negative match");
}
-- (void)testItShouldMatchValuesMatchUsingKeyValueCodingAndHamcrestMatcher {
+- (void)testItShouldMatchValuesMatchUsingKeyValueCodingAndGenericMatcher {
id subject = [Cruiser cruiserWithCallsign:@"Alpha Bravo Zero"];
id matcher = [KWHaveValueMatcher matcherWithSubject:subject];
[matcher haveValue:hasPrefix(@"Alpha") forKey:@"callsign"];
STAssertTrue([matcher evaluate], @"expected positive match");
}
-- (void)testItShouldNotMatchValuesMatchUsingKeyValueCodingAndHamcrestMatcher {
+- (void)testItShouldNotMatchValuesMatchUsingKeyValueCodingAndGenericMatcher {
id subject = [Cruiser cruiserWithCallsign:@"Alpha Bravo Zero"];
id matcher = [KWHaveValueMatcher matcherWithSubject:subject];
[matcher haveValue:hasPrefix(@"Foxtrot") forKey:@"callsign"];
View
13 Tests/KWValueTest.m
@@ -19,47 +19,48 @@ - (void)testItShouldPreserveDataObjCTypeForInts {
int value = 42;
KWValue *wrappedValue = [KWValue valueWithBytes:&value objCType:@encode(int)];
const char *objCType = [wrappedValue objCType];
- STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
STAssertTrue(strcmp(objCType, @encode(int)) == 0, @"expected value to preserve Objective-C type for ints");
+ STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
}
- (void)testItShouldPreserveDataObjCTypeForUnsignedInts {
unsigned int value = 42;
KWValue *wrappedValue = [KWValue valueWithBytes:&value objCType:@encode(unsigned int)];
const char *objCType = [wrappedValue objCType];
- STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
STAssertTrue(strcmp(objCType, @encode(unsigned int)) == 0, @"expected value to preserve Objective-C type for unsigned ints");
+ STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
}
- (void)testItShouldPreserveDataObjCTypeForLongs {
long value = 42;
KWValue *wrappedValue = [KWValue valueWithBytes:&value objCType:@encode(long)];
const char *objCType = [wrappedValue objCType];
- STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
STAssertTrue(strcmp(objCType, @encode(long)) == 0, @"expected value to preserve Objective-C type for longs");
+ STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
}
- (void)testItShouldPreserveDataObjCTypeForUnsignedLongs {
unsigned long value = 42;
KWValue *wrappedValue = [KWValue valueWithBytes:&value objCType:@encode(unsigned long)];
const char *objCType = [wrappedValue objCType];
+ STAssertTrue(strcmp(objCType, @encode(unsigned long)) == 0, @"expected value to preserve Objective-C type for unsigned longs");
STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
- STAssertTrue(strcmp(objCType, @encode(unsigned long)) == 0, @"expected value to preserve Objective-C type for unsigned longs");}
+}
- (void)testItShouldPreserveDataObjCTypeForFloats {
float value = 42.0f;
KWValue *wrappedValue = [KWValue valueWithBytes:&value objCType:@encode(float)];
const char *objCType = [wrappedValue objCType];
- STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
STAssertTrue(strcmp(objCType, @encode(float)) == 0, @"expected value to preserve Objective-C type for floats");
+ STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
}
- (void)testItShouldPreserveDataObjCTypeForDoubles {
double value = 42.0f;
KWValue *wrappedValue = [KWValue valueWithBytes:&value objCType:@encode(double)];
const char *objCType = [wrappedValue objCType];
- STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
STAssertTrue(strcmp(objCType, @encode(double)) == 0, @"expected value to preserve Objective-C type for doubles");
+ STAssertTrue(objCType != nil, @"expected value to return valid Objective-C type");
}
- (void)testItShouldConvertToIntValues {
Please sign in to comment.
Something went wrong with that request. Please try again.