diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/project.pbxproj b/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/project.pbxproj index 9f1e89a..9ae7435 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/project.pbxproj +++ b/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/project.pbxproj @@ -7,27 +7,23 @@ objects = { /* Begin PBXBuildFile section */ - 72B9B6761848EA6C0039064C /* MacroTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B9B6751848EA6C0039064C /* MacroTest.m */; }; 72EC7E0E17DC4DA0009AA360 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72EC7E0D17DC4DA0009AA360 /* UIKit.framework */; }; 72EC7E1017DC4DA0009AA360 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72EC7E0F17DC4DA0009AA360 /* Foundation.framework */; }; 72EC7E1217DC4DA0009AA360 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72EC7E1117DC4DA0009AA360 /* CoreGraphics.framework */; }; 72EC7E1817DC4DA0009AA360 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 72EC7E1617DC4DA0009AA360 /* InfoPlist.strings */; }; 72EC7E1A17DC4DA0009AA360 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E1917DC4DA0009AA360 /* main.m */; }; 72EC7E1E17DC4DA0009AA360 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E1D17DC4DA0009AA360 /* AppDelegate.m */; }; - 72EC7E2C17DC4DA0009AA360 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72EC7E2B17DC4DA0009AA360 /* SenTestingKit.framework */; }; - 72EC7E2D17DC4DA0009AA360 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72EC7E0D17DC4DA0009AA360 /* UIKit.framework */; }; - 72EC7E2E17DC4DA0009AA360 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72EC7E0F17DC4DA0009AA360 /* Foundation.framework */; }; - 72EC7E3617DC4DA0009AA360 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 72EC7E3417DC4DA0009AA360 /* InfoPlist.strings */; }; - 72EC7E4617DC4DCB009AA360 /* NSArray+LinqExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E4417DC4DCB009AA360 /* NSArray+LinqExtensions.m */; }; - 72EC7E4717DC4DCB009AA360 /* NSDictionary+LinqExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E4517DC4DCB009AA360 /* NSDictionary+LinqExtensions.m */; }; - 72EC7E6B17DC505D009AA360 /* NSArrayLinqExtensionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6717DC505D009AA360 /* NSArrayLinqExtensionsTest.m */; }; - 72EC7E6C17DC505D009AA360 /* NSDictionaryLinqExtensionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6817DC505D009AA360 /* NSDictionaryLinqExtensionsTest.m */; }; - 72EC7E6D17DC505D009AA360 /* Person.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6917DC505D009AA360 /* Person.m */; }; - 72EC7E6E17DC505D009AA360 /* ScenarioTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6A17DC505D009AA360 /* ScenarioTests.m */; }; + B6A146921C05B09800EB6770 /* MacroTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B9B6751848EA6C0039064C /* MacroTest.m */; }; + B6A146931C05B09D00EB6770 /* NSArrayLinqExtensionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6717DC505D009AA360 /* NSArrayLinqExtensionsTest.m */; }; + B6A146941C05B0A000EB6770 /* NSDictionaryLinqExtensionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6817DC505D009AA360 /* NSDictionaryLinqExtensionsTest.m */; }; + B6A146951C05B0A400EB6770 /* Person.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6917DC505D009AA360 /* Person.m */; }; + B6A146961C05B0A700EB6770 /* ScenarioTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E6A17DC505D009AA360 /* ScenarioTests.m */; }; + B6A146971C05B0AD00EB6770 /* NSArray+LinqExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E4417DC4DCB009AA360 /* NSArray+LinqExtensions.m */; }; + B6A146981C05B0AF00EB6770 /* NSDictionary+LinqExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EC7E4517DC4DCB009AA360 /* NSDictionary+LinqExtensions.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 72EC7E2F17DC4DA0009AA360 /* PBXContainerItemProxy */ = { + B6A1468D1C05B06200EB6770 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 72EC7E0017DC4DA0009AA360 /* Project object */; proxyType = 1; @@ -49,7 +45,6 @@ 72EC7E1B17DC4DA0009AA360 /* LinqToObjectiveCTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LinqToObjectiveCTest-Prefix.pch"; sourceTree = ""; }; 72EC7E1C17DC4DA0009AA360 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 72EC7E1D17DC4DA0009AA360 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 72EC7E2A17DC4DA0009AA360 /* LinqToObjectiveCTestTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LinqToObjectiveCTestTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 72EC7E2B17DC4DA0009AA360 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 72EC7E3317DC4DA0009AA360 /* LinqToObjectiveCTestTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "LinqToObjectiveCTestTests-Info.plist"; sourceTree = ""; }; 72EC7E3517DC4DA0009AA360 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -65,6 +60,8 @@ 72EC7E6817DC505D009AA360 /* NSDictionaryLinqExtensionsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDictionaryLinqExtensionsTest.m; sourceTree = ""; }; 72EC7E6917DC505D009AA360 /* Person.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Person.m; sourceTree = ""; }; 72EC7E6A17DC505D009AA360 /* ScenarioTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScenarioTests.m; sourceTree = ""; }; + B6A146881C05B06200EB6770 /* LinqToObjectiveCTestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LinqToObjectiveCTestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + B6A1468C1C05B06200EB6770 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -78,13 +75,10 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 72EC7E2617DC4DA0009AA360 /* Frameworks */ = { + B6A146851C05B06200EB6770 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 72EC7E2C17DC4DA0009AA360 /* SenTestingKit.framework in Frameworks */, - 72EC7E2D17DC4DA0009AA360 /* UIKit.framework in Frameworks */, - 72EC7E2E17DC4DA0009AA360 /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -105,7 +99,7 @@ isa = PBXGroup; children = ( 72EC7E0917DC4DA0009AA360 /* LinqToObjectiveCTest.app */, - 72EC7E2A17DC4DA0009AA360 /* LinqToObjectiveCTestTests.octest */, + B6A146881C05B06200EB6770 /* LinqToObjectiveCTestTests.xctest */, ); name = Products; sourceTree = ""; @@ -167,6 +161,7 @@ 72EC7E3217DC4DA0009AA360 /* Supporting Files */ = { isa = PBXGroup; children = ( + B6A1468C1C05B06200EB6770 /* Info.plist */, 72EC7E3317DC4DA0009AA360 /* LinqToObjectiveCTestTests-Info.plist */, 72EC7E3417DC4DA0009AA360 /* InfoPlist.strings */, ); @@ -193,24 +188,23 @@ productReference = 72EC7E0917DC4DA0009AA360 /* LinqToObjectiveCTest.app */; productType = "com.apple.product-type.application"; }; - 72EC7E2917DC4DA0009AA360 /* LinqToObjectiveCTestTests */ = { + B6A146871C05B06200EB6770 /* LinqToObjectiveCTestTests */ = { isa = PBXNativeTarget; - buildConfigurationList = 72EC7E3F17DC4DA0009AA360 /* Build configuration list for PBXNativeTarget "LinqToObjectiveCTestTests" */; + buildConfigurationList = B6A1468F1C05B06200EB6770 /* Build configuration list for PBXNativeTarget "LinqToObjectiveCTestTests" */; buildPhases = ( - 72EC7E2517DC4DA0009AA360 /* Sources */, - 72EC7E2617DC4DA0009AA360 /* Frameworks */, - 72EC7E2717DC4DA0009AA360 /* Resources */, - 72EC7E2817DC4DA0009AA360 /* ShellScript */, + B6A146841C05B06200EB6770 /* Sources */, + B6A146851C05B06200EB6770 /* Frameworks */, + B6A146861C05B06200EB6770 /* Resources */, ); buildRules = ( ); dependencies = ( - 72EC7E3017DC4DA0009AA360 /* PBXTargetDependency */, + B6A1468E1C05B06200EB6770 /* PBXTargetDependency */, ); name = LinqToObjectiveCTestTests; productName = LinqToObjectiveCTestTests; - productReference = 72EC7E2A17DC4DA0009AA360 /* LinqToObjectiveCTestTests.octest */; - productType = "com.apple.product-type.bundle.ocunit-test"; + productReference = B6A146881C05B06200EB6770 /* LinqToObjectiveCTestTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ @@ -218,8 +212,15 @@ 72EC7E0017DC4DA0009AA360 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastTestingUpgradeCheck = 0710; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = "Colin Eberhardt"; + TargetAttributes = { + B6A146871C05B06200EB6770 = { + CreatedOnToolsVersion = 7.1.1; + TestTargetID = 72EC7E0817DC4DA0009AA360; + }; + }; }; buildConfigurationList = 72EC7E0317DC4DA0009AA360 /* Build configuration list for PBXProject "LinqToObjectiveCTest" */; compatibilityVersion = "Xcode 3.2"; @@ -234,7 +235,7 @@ projectRoot = ""; targets = ( 72EC7E0817DC4DA0009AA360 /* LinqToObjectiveCTest */, - 72EC7E2917DC4DA0009AA360 /* LinqToObjectiveCTestTests */, + B6A146871C05B06200EB6770 /* LinqToObjectiveCTestTests */, ); }; /* End PBXProject section */ @@ -248,32 +249,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 72EC7E2717DC4DA0009AA360 /* Resources */ = { + B6A146861C05B06200EB6770 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 72EC7E3617DC4DA0009AA360 /* InfoPlist.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 72EC7E2817DC4DA0009AA360 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 72EC7E0517DC4DA0009AA360 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -284,27 +268,27 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 72EC7E2517DC4DA0009AA360 /* Sources */ = { + B6A146841C05B06200EB6770 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 72EC7E4617DC4DCB009AA360 /* NSArray+LinqExtensions.m in Sources */, - 72EC7E4717DC4DCB009AA360 /* NSDictionary+LinqExtensions.m in Sources */, - 72EC7E6B17DC505D009AA360 /* NSArrayLinqExtensionsTest.m in Sources */, - 72EC7E6C17DC505D009AA360 /* NSDictionaryLinqExtensionsTest.m in Sources */, - 72EC7E6D17DC505D009AA360 /* Person.m in Sources */, - 72EC7E6E17DC505D009AA360 /* ScenarioTests.m in Sources */, - 72B9B6761848EA6C0039064C /* MacroTest.m in Sources */, + B6A146941C05B0A000EB6770 /* NSDictionaryLinqExtensionsTest.m in Sources */, + B6A146921C05B09800EB6770 /* MacroTest.m in Sources */, + B6A146951C05B0A400EB6770 /* Person.m in Sources */, + B6A146971C05B0AD00EB6770 /* NSArray+LinqExtensions.m in Sources */, + B6A146931C05B09D00EB6770 /* NSArrayLinqExtensionsTest.m in Sources */, + B6A146981C05B0AF00EB6770 /* NSDictionary+LinqExtensions.m in Sources */, + B6A146961C05B0A700EB6770 /* ScenarioTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 72EC7E3017DC4DA0009AA360 /* PBXTargetDependency */ = { + B6A1468E1C05B06200EB6770 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 72EC7E0817DC4DA0009AA360 /* LinqToObjectiveCTest */; - targetProxy = 72EC7E2F17DC4DA0009AA360 /* PBXContainerItemProxy */; + targetProxy = B6A1468D1C05B06200EB6770 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -339,6 +323,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -351,6 +336,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.0; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -385,6 +371,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "LinqToObjectiveCTest/LinqToObjectiveCTest-Prefix.pch"; INFOPLIST_FILE = "LinqToObjectiveCTest/LinqToObjectiveCTest-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "Eu.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -396,42 +383,73 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "LinqToObjectiveCTest/LinqToObjectiveCTest-Prefix.pch"; INFOPLIST_FILE = "LinqToObjectiveCTest/LinqToObjectiveCTest-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "Eu.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; name = Release; }; - 72EC7E4017DC4DA0009AA360 /* Debug */ = { + B6A146901C05B06200EB6770 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/LinqToObjectiveCTest.app/LinqToObjectiveCTest"; - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "LinqToObjectiveCTest/LinqToObjectiveCTest-Prefix.pch"; - INFOPLIST_FILE = "LinqToObjectiveCTestTests/LinqToObjectiveCTestTests-Info.plist"; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = LinqToObjectiveCTestTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = Eu.LinqToObjectiveCTestTests; PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LinqToObjectiveCTest.app/LinqToObjectiveCTest"; }; name = Debug; }; - 72EC7E4117DC4DA0009AA360 /* Release */ = { + B6A146911C05B06200EB6770 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/LinqToObjectiveCTest.app/LinqToObjectiveCTest"; - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "LinqToObjectiveCTest/LinqToObjectiveCTest-Prefix.pch"; - INFOPLIST_FILE = "LinqToObjectiveCTestTests/LinqToObjectiveCTestTests-Info.plist"; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = LinqToObjectiveCTestTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = Eu.LinqToObjectiveCTestTests; PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LinqToObjectiveCTest.app/LinqToObjectiveCTest"; }; name = Release; }; @@ -456,14 +474,13 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 72EC7E3F17DC4DA0009AA360 /* Build configuration list for PBXNativeTarget "LinqToObjectiveCTestTests" */ = { + B6A1468F1C05B06200EB6770 /* Build configuration list for PBXNativeTarget "LinqToObjectiveCTestTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 72EC7E4017DC4DA0009AA360 /* Debug */, - 72EC7E4117DC4DA0009AA360 /* Release */, + B6A146901C05B06200EB6770 /* Debug */, + B6A146911C05B06200EB6770 /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/xcshareddata/xcschemes/LinqToObjectiveCTest.xcscheme b/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/xcshareddata/xcschemes/LinqToObjectiveCTest.xcscheme new file mode 100644 index 0000000..8a37e6d --- /dev/null +++ b/LinqToObjectiveCTest/LinqToObjectiveCTest.xcodeproj/xcshareddata/xcschemes/LinqToObjectiveCTest.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTest/AppDelegate.m b/LinqToObjectiveCTest/LinqToObjectiveCTest/AppDelegate.m index ee187b8..996b566 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTest/AppDelegate.m +++ b/LinqToObjectiveCTest/LinqToObjectiveCTest/AppDelegate.m @@ -15,6 +15,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; + self.window.rootViewController = [UIViewController new]; [self.window makeKeyAndVisible]; return YES; } diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTest/LinqToObjectiveCTest-Info.plist b/LinqToObjectiveCTest/LinqToObjectiveCTest/LinqToObjectiveCTest-Info.plist index eec2c9e..6a012bd 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTest/LinqToObjectiveCTest-Info.plist +++ b/LinqToObjectiveCTest/LinqToObjectiveCTest/LinqToObjectiveCTest-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - Eu.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Info.plist b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.h b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.h index a6e3d41..eb02b85 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.h +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.h @@ -6,8 +6,8 @@ // Copyright (c) 2013 Colin Eberhardt. All rights reserved. // -#import +#import -@interface MacroTest : SenTestCase +@interface MacroTest : XCTestCase @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.m b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.m index e707f5c..59e3e40 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.m +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/MacroTest.m @@ -27,10 +27,10 @@ - (void)testSelect NSArray* names = [input linq_select:LINQSel(name)]; - STAssertEquals(names.count, (NSUInteger)5, nil); + XCTAssertEqual(names.count, (NSUInteger)5); // 'spot' check a few values - STAssertEquals(names[0], @"bob", nil); - STAssertEquals(names[4], @"joe", nil); + XCTAssertEqual(names[0], @"bob"); + XCTAssertEqual(names[4], @"joe"); } - (void)testSelectCast @@ -39,10 +39,10 @@ - (void)testSelectCast NSArray* ages = [input linq_select:LINQSelUInt(intAge)]; - STAssertEquals(ages.count, (NSUInteger)5, nil); + XCTAssertEqual(ages.count, (NSUInteger)5); // 'spot' check a few values - STAssertEqualObjects(ages[0], @25, nil); - STAssertEqualObjects(ages[4], @55, nil); + XCTAssertEqualObjects(ages[0], @25); + XCTAssertEqualObjects(ages[4], @55); } - (void)testSelectViaKey @@ -51,10 +51,10 @@ - (void)testSelectViaKey NSArray* names = [input linq_select:LINQKey(name)]; - STAssertEquals(names.count, (NSUInteger)5, nil); + XCTAssertEqual(names.count, (NSUInteger)5); // 'spot' check a few values - STAssertEquals(names[0], @"bob", nil); - STAssertEquals(names[4], @"joe", nil); + XCTAssertEqual(names[0], @"bob"); + XCTAssertEqual(names[4], @"joe"); } - (void)testSelectViaKeyPath @@ -63,10 +63,10 @@ - (void)testSelectViaKeyPath NSArray* names = [input linq_select:LINQKeyPath(name)]; - STAssertEquals(names.count, (NSUInteger)5, nil); + XCTAssertEqual(names.count, (NSUInteger)5); // 'spot' check a few values - STAssertEquals(names[0], @"bob", nil); - STAssertEquals(names[4], @"joe", nil); + XCTAssertEqual(names[0], @"bob"); + XCTAssertEqual(names[4], @"joe"); } @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.h b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.h index 5b8349a..821bd1d 100755 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.h +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.h @@ -6,8 +6,8 @@ // Copyright (c) 2013 Colin Eberhardt. All rights reserved. // -#import +#import -@interface NSArrayLinqExtensionsTest : SenTestCase +@interface NSArrayLinqExtensionsTest : XCTestCase @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.m b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.m index e6d4ec4..21e5a62 100755 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.m +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSArrayLinqExtensionsTest.m @@ -12,79 +12,79 @@ @implementation NSArrayLinqExtensionsTest -- (NSArray*) createTestData +- (NSArray*) createTestData { return @[[Person personWithName:@"bob" age:@25], - [Person personWithName:@"frank" age:@45], - [Person personWithName:@"ian" age:@35], - [Person personWithName:@"jim" age:@25], - [Person personWithName:@"joe" age:@55]]; + [Person personWithName:@"frank" age:@45], + [Person personWithName:@"ian" age:@35], + [Person personWithName:@"jim" age:@25], + [Person personWithName:@"joe" age:@55]]; } - (void)testWhere { - NSArray* input = [self createTestData]; + NSArray* input = [self createTestData]; - NSArray* peopleWhoAre25 = [input linq_where:^BOOL(id person) { - return [[person age] isEqualToNumber:@25]; + NSArray* peopleWhoAre25 = [input linq_where:^BOOL(Person *item) { + return [[item age] isEqualToNumber:@25]; }]; - STAssertEquals(peopleWhoAre25.count, (NSUInteger)2, @"There should have been 2 items returned"); - STAssertEquals([peopleWhoAre25[0] name], @"bob", @"Bob is 25!"); - STAssertEquals([peopleWhoAre25[1] name], @"jim", @"Jim is 25!"); + XCTAssertEqual(peopleWhoAre25.count, (NSUInteger)2, @"There should have been 2 items returned"); + XCTAssertEqual([peopleWhoAre25[0] name], @"bob", @"Bob is 25!"); + XCTAssertEqual([peopleWhoAre25[1] name], @"jim", @"Jim is 25!"); } - (void)testSelect { - NSArray* input = [self createTestData]; + NSArray* input = [self createTestData]; - NSArray* names = [input linq_select:^id(id person) { + NSArray* names = [input linq_select:^id(Person *person) { return [person name]; }]; - STAssertEquals(names.count, (NSUInteger)5, nil); + XCTAssertEqual(names.count, (NSUInteger)5); // 'spot' check a few values - STAssertEquals(names[0], @"bob", nil); - STAssertEquals(names[4], @"joe", nil); + XCTAssertEqual(names[0], @"bob"); + XCTAssertEqual(names[4], @"joe"); } - (void)testSelectWithNil { - NSArray* input = [self createTestData]; + NSArray* input = [self createTestData]; - NSArray* names = [input linq_select:^id(id person) { + NSArray* names = [input linq_select:^id(Person *person) { return [[person name] isEqualToString:@"bob"] ? nil : [person name]; }]; - STAssertEquals(names.count, (NSUInteger)5, nil); + XCTAssertEqual(names.count, (NSUInteger)5); // 'spot' check a few values - STAssertEquals(names[0], [NSNull null], nil); - STAssertEquals(names[4], @"joe", nil); + XCTAssertEqual(names[0], [NSNull null]); + XCTAssertEqual(names[4], @"joe"); } - (void)testSelectAndStopOnNil { - NSArray* input = [self createTestData]; - - NSArray* names = [input linq_selectAndStopOnNil:^id(id person) { - return [person name]; - }]; - - STAssertEquals(names.count, (NSUInteger)5, nil); - // 'spot' check a few values - STAssertEquals(names[0], @"bob", nil); - STAssertEquals(names[4], @"joe", nil); + NSArray* input = [self createTestData]; + + NSArray* names = [input linq_selectAndStopOnNil:^id(id person) { + return [person name]; + }]; + + XCTAssertEqual(names.count, (NSUInteger)5); + // 'spot' check a few values + XCTAssertEqual(names[0], @"bob"); + XCTAssertEqual(names[4], @"joe"); } - (void)testSelectAndStopOnNilWithNil { - NSArray* input = [self createTestData]; - - NSArray* names = [input linq_selectAndStopOnNil:^id(id person) { - return [[person name] isEqualToString:@"bob"] ? nil : [person name]; - }]; - - STAssertNil(names, nil); + NSArray* input = [self createTestData]; + + NSArray* names = [input linq_selectAndStopOnNil:^id(id person) { + return [[person name] isEqualToString:@"bob"] ? nil : [person name]; + }]; + + XCTAssertNil(names); } - (void)testSort @@ -93,10 +93,10 @@ - (void)testSort NSArray* sortedInput = [input linq_sort]; - STAssertEquals(sortedInput.count, (NSUInteger)3, nil); - STAssertEqualObjects(sortedInput[0], @21, nil); - STAssertEqualObjects(sortedInput[1], @25, nil); - STAssertEqualObjects(sortedInput[2], @34, nil); + XCTAssertEqual(sortedInput.count, (NSUInteger)3); + XCTAssertEqualObjects(sortedInput[0], @21); + XCTAssertEqualObjects(sortedInput[1], @25); + XCTAssertEqualObjects(sortedInput[2], @34); } - (void)testSortWithKeySelector @@ -105,12 +105,12 @@ - (void)testSortWithKeySelector NSArray* sortedByName = [input linq_sort:LINQKey(name)]; - STAssertEquals(sortedByName.count, (NSUInteger)5, nil); - STAssertEquals([sortedByName[0] name], @"bob", nil); - STAssertEquals([sortedByName[1] name], @"frank", nil); - STAssertEquals([sortedByName[2] name], @"ian", nil); - STAssertEquals([sortedByName[3] name], @"jim", nil); - STAssertEquals([sortedByName[4] name], @"joe", nil); + XCTAssertEqual(sortedByName.count, (NSUInteger)5); + XCTAssertEqual([sortedByName[0] name], @"bob"); + XCTAssertEqual([sortedByName[1] name], @"frank"); + XCTAssertEqual([sortedByName[2] name], @"ian"); + XCTAssertEqual([sortedByName[3] name], @"jim"); + XCTAssertEqual([sortedByName[4] name], @"joe"); } - (void)testSortWithKeySelectorWithNil @@ -119,15 +119,15 @@ - (void)testSortWithKeySelectorWithNil NSArray* sortedByName = [input linq_sort:^id(id person) { return [[person name] isEqualToString:@"bob"] ? nil : [person name]; - + }]; - STAssertEquals(sortedByName.count, (NSUInteger)5, nil); - STAssertEquals([sortedByName[0] name], @"bob", nil); - STAssertEquals([sortedByName[1] name], @"frank", nil); - STAssertEquals([sortedByName[2] name], @"ian", nil); - STAssertEquals([sortedByName[3] name], @"jim", nil); - STAssertEquals([sortedByName[4] name], @"joe", nil); + XCTAssertEqual(sortedByName.count, (NSUInteger)5); + XCTAssertEqual([sortedByName[0] name], @"bob"); + XCTAssertEqual([sortedByName[1] name], @"frank"); + XCTAssertEqual([sortedByName[2] name], @"ian"); + XCTAssertEqual([sortedByName[3] name], @"jim"); + XCTAssertEqual([sortedByName[4] name], @"joe"); } - (void)testSortDescending @@ -136,10 +136,10 @@ - (void)testSortDescending NSArray* sortedDescendingInput = [input linq_sortDescending]; - STAssertEquals(sortedDescendingInput.count, (NSUInteger)3, nil); - STAssertEqualObjects(sortedDescendingInput[0], @34, nil); - STAssertEqualObjects(sortedDescendingInput[1], @25, nil); - STAssertEqualObjects(sortedDescendingInput[2], @21, nil); + XCTAssertEqual(sortedDescendingInput.count, (NSUInteger)3); + XCTAssertEqualObjects(sortedDescendingInput[0], @34); + XCTAssertEqualObjects(sortedDescendingInput[1], @25); + XCTAssertEqualObjects(sortedDescendingInput[2], @21); } - (void)testSortDescendingWithKeySelector @@ -148,12 +148,12 @@ - (void)testSortDescendingWithKeySelector NSArray* sortedDescendingByName = [input linq_sortDescending:LINQKey(name)]; - STAssertEquals(sortedDescendingByName.count, (NSUInteger)5, nil); - STAssertEquals([sortedDescendingByName[0] name], @"joe", nil); - STAssertEquals([sortedDescendingByName[1] name], @"jim", nil); - STAssertEquals([sortedDescendingByName[2] name], @"ian", nil); - STAssertEquals([sortedDescendingByName[3] name], @"frank", nil); - STAssertEquals([sortedDescendingByName[4] name], @"bob", nil); + XCTAssertEqual(sortedDescendingByName.count, (NSUInteger)5); + XCTAssertEqual([sortedDescendingByName[0] name], @"joe"); + XCTAssertEqual([sortedDescendingByName[1] name], @"jim"); + XCTAssertEqual([sortedDescendingByName[2] name], @"ian"); + XCTAssertEqual([sortedDescendingByName[3] name], @"frank"); + XCTAssertEqual([sortedDescendingByName[4] name], @"bob"); } - (void)testSortDescendingWithKeySelectorWithNil @@ -165,12 +165,12 @@ - (void)testSortDescendingWithKeySelectorWithNil }]; - STAssertEquals(sortedDescendingByName.count, (NSUInteger)5, nil); - STAssertEquals([sortedDescendingByName[0] name], @"joe", nil); - STAssertEquals([sortedDescendingByName[1] name], @"jim", nil); - STAssertEquals([sortedDescendingByName[2] name], @"ian", nil); - STAssertEquals([sortedDescendingByName[3] name], @"frank", nil); - STAssertEquals([sortedDescendingByName[4] name], @"bob", nil); + XCTAssertEqual(sortedDescendingByName.count, (NSUInteger)5); + XCTAssertEqual([sortedDescendingByName[0] name], @"joe"); + XCTAssertEqual([sortedDescendingByName[1] name], @"jim"); + XCTAssertEqual([sortedDescendingByName[2] name], @"ian"); + XCTAssertEqual([sortedDescendingByName[3] name], @"frank"); + XCTAssertEqual([sortedDescendingByName[4] name], @"bob"); } - (void)testOfType @@ -179,9 +179,9 @@ - (void)testOfType NSArray* strings = [mixed linq_ofType:[NSString class]]; - STAssertEquals(strings.count, (NSUInteger)2, nil); - STAssertEqualObjects(strings[0], @"foo", nil); - STAssertEqualObjects(strings[1], @"bar", nil); + XCTAssertEqual(strings.count, (NSUInteger)2); + XCTAssertEqualObjects(strings[0], @"foo"); + XCTAssertEqualObjects(strings[1], @"bar"); } - (void)testSelectMany @@ -192,10 +192,10 @@ - (void)testSelectMany return [string componentsSeparatedByString:@", "]; }]; - STAssertEquals(components.count, (NSUInteger)3, nil); - STAssertEqualObjects(components[0], @"foo", nil); - STAssertEqualObjects(components[1], @"bar", nil); - STAssertEqualObjects(components[2], @"fubar", nil); + XCTAssertEqual(components.count, (NSUInteger)3); + XCTAssertEqualObjects(components[0], @"foo"); + XCTAssertEqualObjects(components[1], @"bar"); + XCTAssertEqualObjects(components[2], @"fubar"); } - (void)testDistinctWithKeySelector @@ -204,11 +204,11 @@ - (void)testDistinctWithKeySelector NSArray* peopelWithUniqueAges = [input linq_distinct:LINQKey(age)]; - STAssertEquals(peopelWithUniqueAges.count, (NSUInteger)4, nil); - STAssertEquals([peopelWithUniqueAges[0] name], @"bob", nil); - STAssertEquals([peopelWithUniqueAges[1] name], @"frank", nil); - STAssertEquals([peopelWithUniqueAges[2] name], @"ian", nil); - STAssertEquals([peopelWithUniqueAges[3] name], @"joe", nil); + XCTAssertEqual(peopelWithUniqueAges.count, (NSUInteger)4); + XCTAssertEqual([peopelWithUniqueAges[0] name], @"bob"); + XCTAssertEqual([peopelWithUniqueAges[1] name], @"frank"); + XCTAssertEqual([peopelWithUniqueAges[2] name], @"ian"); + XCTAssertEqual([peopelWithUniqueAges[3] name], @"joe"); } - (void)testDistinctWithKeySelectorWithNil @@ -219,11 +219,11 @@ - (void)testDistinctWithKeySelectorWithNil return [[person age] isEqualToNumber:@25] ? nil : [person age]; }]; - STAssertEquals(peopelWithUniqueAges.count, (NSUInteger)4, nil); - STAssertEquals([peopelWithUniqueAges[0] name], @"bob", nil); - STAssertEquals([peopelWithUniqueAges[1] name], @"frank", nil); - STAssertEquals([peopelWithUniqueAges[2] name], @"ian", nil); - STAssertEquals([peopelWithUniqueAges[3] name], @"joe", nil); + XCTAssertEqual(peopelWithUniqueAges.count, (NSUInteger)4); + XCTAssertEqual([peopelWithUniqueAges[0] name], @"bob"); + XCTAssertEqual([peopelWithUniqueAges[1] name], @"frank"); + XCTAssertEqual([peopelWithUniqueAges[2] name], @"ian"); + XCTAssertEqual([peopelWithUniqueAges[3] name], @"joe"); } - (void)testDistinct @@ -232,10 +232,10 @@ - (void)testDistinct NSArray* distinctNames = [names linq_distinct]; - STAssertEquals(distinctNames.count, (NSUInteger)3, nil); - STAssertEqualObjects(distinctNames[0], @"bill", nil); - STAssertEqualObjects(distinctNames[1], @"bob", nil); - STAssertEqualObjects(distinctNames[2], @"brian", nil); + XCTAssertEqual(distinctNames.count, (NSUInteger)3); + XCTAssertEqualObjects(distinctNames[0], @"bill"); + XCTAssertEqualObjects(distinctNames[1], @"bob"); + XCTAssertEqualObjects(distinctNames[2], @"brian"); } @@ -247,7 +247,7 @@ - (void)testAggregate return [NSString stringWithFormat:@"%@, %@", aggregate, item]; }]; - STAssertEqualObjects(csv, @"bill, bob, brian", nil); + XCTAssertEqualObjects(csv, @"bill, bob, brian"); NSArray* numbers = @[@22, @45, @33]; @@ -255,7 +255,7 @@ - (void)testAggregate return [item compare:aggregate] == NSOrderedDescending ? item : aggregate; }]; - STAssertEqualObjects(biggestNumber, @45, nil); + XCTAssertEqualObjects(biggestNumber, @45); } - (void)testFirstOrNil @@ -263,8 +263,8 @@ - (void)testFirstOrNil NSArray* input = [self createTestData]; NSArray* emptyArray = @[]; - STAssertNil([emptyArray linq_firstOrNil], nil); - STAssertEquals([[input linq_firstOrNil] name], @"bob", nil); + XCTAssertNil([emptyArray linq_firstOrNil]); + XCTAssertEqual([[input linq_firstOrNil] name], @"bob"); } - (void)testFirtOrNilWithPredicate @@ -281,9 +281,9 @@ - (void)testFirtOrNilWithPredicate return [person.name isEqualToString:@"steve"]; }]; - STAssertEquals(personJim, jimSecond, @"Returned the wrong Jim!"); - STAssertNil(personSteve, @"Should not have found Steve!"); - STAssertTrue([personJim isKindOfClass:Person.class], @"Should have returned a single object of type Person"); + XCTAssertEqual(personJim, jimSecond, @"Returned the wrong Jim!"); + XCTAssertNil(personSteve, @"Should not have found Steve!"); + XCTAssertTrue([personJim isKindOfClass:Person.class], @"Should have returned a single object of type Person"); } - (void)testLastOrNil @@ -291,27 +291,27 @@ - (void)testLastOrNil NSArray* input = [self createTestData]; NSArray* emptyArray = @[]; - STAssertNil([emptyArray linq_lastOrNil], nil); - STAssertEquals([[input linq_lastOrNil] name], @"joe", nil); + XCTAssertNil([emptyArray linq_lastOrNil]); + XCTAssertEqual([[input linq_lastOrNil] name], @"joe"); } - (void)testTake { NSArray* input = [self createTestData]; - STAssertEquals([input linq_take:0].count, (NSUInteger)0, nil); - STAssertEquals([input linq_take:5].count, (NSUInteger)5, nil); - STAssertEquals([input linq_take:50].count, (NSUInteger)5, nil); - STAssertEquals([[input linq_take:2][0] name], @"bob", nil); + XCTAssertEqual([input linq_take:0].count, (NSUInteger)0); + XCTAssertEqual([input linq_take:5].count, (NSUInteger)5); + XCTAssertEqual([input linq_take:50].count, (NSUInteger)5); + XCTAssertEqual([[input linq_take:2][0] name], @"bob"); } - (void)testSkip { NSArray* input = [self createTestData]; - STAssertEquals([input linq_skip:0].count, (NSUInteger)5, nil); - STAssertEquals([input linq_skip:5].count, (NSUInteger)0, nil); - STAssertEquals([[input linq_skip:2][0] name], @"ian", nil); + XCTAssertEqual([input linq_skip:0].count, (NSUInteger)5); + XCTAssertEqual([input linq_skip:5].count, (NSUInteger)0); + XCTAssertEqual([[input linq_skip:2][0] name], @"ian"); } @@ -319,26 +319,26 @@ - (void)testAny { NSArray* input = @[@25, @44, @36]; - STAssertFalse([input linq_any:^BOOL(id item) { + XCTAssertFalse([input linq_any:^BOOL(id item) { return [item isEqualToNumber:@33]; - }], nil); + }]); - STAssertTrue([input linq_any:^BOOL(id item) { + XCTAssertTrue([input linq_any:^BOOL(id item) { return [item isEqualToNumber:@25]; - }], nil); + }]); } - (void)testAll { NSArray* input = @[@25, @25, @25]; - STAssertFalse([input linq_all:^BOOL(id item) { + XCTAssertFalse([input linq_all:^BOOL(id item) { return [item isEqualToNumber:@33]; - }], nil); + }]); - STAssertTrue([input linq_all:^BOOL(id item) { + XCTAssertTrue([input linq_all:^BOOL(id item) { return [item isEqualToNumber:@25]; - }], nil); + }]); } - (void)testGroupBy @@ -349,22 +349,22 @@ - (void)testGroupBy return [name substringToIndex:1]; }]; - STAssertEquals(groupedByFirstLetter.count, (NSUInteger)2, nil); + XCTAssertEqual(groupedByFirstLetter.count, (NSUInteger)2); // test the group keys NSArray* keys = [groupedByFirstLetter allKeys]; - STAssertEqualObjects(@"J", keys[0], nil); - STAssertEqualObjects(@"B", keys[1], nil); + XCTAssertEqualObjects(@"J", keys[0]); + XCTAssertEqualObjects(@"B", keys[1]); // test that the correct items are in each group NSArray* groupOne = groupedByFirstLetter[@"J"]; - STAssertEquals(groupOne.count, (NSUInteger)2, nil); - STAssertEqualObjects(@"James", groupOne[0], nil); - STAssertEqualObjects(@"Jim", groupOne[1], nil); + XCTAssertEqual(groupOne.count, (NSUInteger)2); + XCTAssertEqualObjects(@"James", groupOne[0]); + XCTAssertEqualObjects(@"Jim", groupOne[1]); NSArray* groupTwo = groupedByFirstLetter[@"B"]; - STAssertEquals(groupTwo.count, (NSUInteger)1, nil); - STAssertEqualObjects(@"Bob", groupTwo[0], nil); + XCTAssertEqual(groupTwo.count, (NSUInteger)1); + XCTAssertEqualObjects(@"Bob", groupTwo[0]); } - (void)testGroupByWithNil @@ -376,57 +376,57 @@ - (void)testGroupByWithNil return [firstChar isEqualToString:@"J"] ? nil : firstChar; }]; - STAssertEquals(groupedByFirstLetter.count, (NSUInteger)2, nil); + XCTAssertEqual(groupedByFirstLetter.count, (NSUInteger)2); // test the group keys NSArray* keys = [groupedByFirstLetter allKeys]; - STAssertEqualObjects([NSNull null], keys[1], nil); - STAssertEqualObjects(@"B", keys[0], nil); + XCTAssertEqualObjects([NSNull null], keys[1]); + XCTAssertEqualObjects(@"B", keys[0]); // test that the correct items are in each group NSArray* groupOne = groupedByFirstLetter[[NSNull null]]; - STAssertEquals(groupOne.count, (NSUInteger)2, nil); - STAssertEqualObjects(@"James", groupOne[0], nil); - STAssertEqualObjects(@"Jim", groupOne[1], nil); + XCTAssertEqual(groupOne.count, (NSUInteger)2); + XCTAssertEqualObjects(@"James", groupOne[0]); + XCTAssertEqualObjects(@"Jim", groupOne[1]); NSArray* groupTwo = groupedByFirstLetter[@"B"]; - STAssertEquals(groupTwo.count, (NSUInteger)1, nil); - STAssertEqualObjects(@"Bob", groupTwo[0], nil); + XCTAssertEqual(groupTwo.count, (NSUInteger)1); + XCTAssertEqualObjects(@"Bob", groupTwo[0]); } - (void)testToDictionaryWithValueSelector { - NSArray* input = @[@"James", @"Jim", @"Bob"]; - - NSDictionary* dictionary = [input linq_toDictionaryWithKeySelector:^id(id item) { + NSArray* input = @[@"James", @"Jim", @"Bob"]; + + NSDictionary* dictionary = [input linq_toDictionaryWithKeySelector:^id(NSString *item) { return [item substringToIndex:1]; - } valueSelector:^id(id item) { + } valueSelector:^id(NSString *item) { return [item lowercaseString]; }]; NSLog(@"%@", dictionary); // NOTE - two items have the same key, hence the dictionary only has 2 keys - STAssertEquals(dictionary.count, (NSUInteger)2, nil); + XCTAssertEqual(dictionary.count, (NSUInteger)2); // test the group keys NSArray* keys = [dictionary allKeys]; - STAssertEqualObjects(@"J", keys[0], nil); - STAssertEqualObjects(@"B", keys[1], nil); + XCTAssertEqualObjects(@"J", keys[0]); + XCTAssertEqualObjects(@"B", keys[1]); // test the values - STAssertEqualObjects(dictionary[@"J"], @"jim", nil); - STAssertEqualObjects(dictionary[@"B"], @"bob", nil); + XCTAssertEqualObjects(dictionary[@"J"], @"jim"); + XCTAssertEqualObjects(dictionary[@"B"], @"bob"); } - (void)testToDictionaryWithValueSelectorWithNil { - NSArray* input = @[@"James", @"Jim", @"Bob"]; + NSArray* input = @[@"James", @"Jim", @"Bob"]; - NSDictionary* dictionary = [input linq_toDictionaryWithKeySelector:^id(id item) { + NSDictionary* dictionary = [input linq_toDictionaryWithKeySelector:^id(NSString *item) { NSString* firstChar = [item substringToIndex:1]; return [firstChar isEqualToString:@"J"] ? nil : firstChar; - } valueSelector:^id(id item) { + } valueSelector:^id(NSString *item) { NSString* lowercaseName = [item lowercaseString]; return [lowercaseName isEqualToString:@"bob"] ? nil : lowercaseName; }]; @@ -434,62 +434,62 @@ - (void)testToDictionaryWithValueSelectorWithNil NSLog(@"%@", dictionary); // NOTE - two items have the same key, hence the dictionary only has 2 keys - STAssertEquals(dictionary.count, (NSUInteger)2, nil); + XCTAssertEqual(dictionary.count, (NSUInteger)2); // test the group keys NSArray* keys = [dictionary allKeys]; - STAssertEqualObjects([NSNull null], keys[1], nil); - STAssertEqualObjects(@"B", keys[0], nil); + XCTAssertEqualObjects([NSNull null], keys[1]); + XCTAssertEqualObjects(@"B", keys[0]); // test the values - STAssertEqualObjects(dictionary[[NSNull null]], @"jim", nil); - STAssertEqualObjects(dictionary[@"B"], [NSNull null], nil); + XCTAssertEqualObjects(dictionary[[NSNull null]], @"jim"); + XCTAssertEqualObjects(dictionary[@"B"], [NSNull null]); } - (void)testToDictionary { - NSArray* input = @[@"Jim", @"Bob"]; + NSArray* input = @[@"Jim", @"Bob"]; - NSDictionary* dictionary = [input linq_toDictionaryWithKeySelector:^id(id item) { + NSDictionary* dictionary = [input linq_toDictionaryWithKeySelector:^id(NSString *item) { return [item substringToIndex:1]; }]; - STAssertEquals(dictionary.count, (NSUInteger)2, nil); + XCTAssertEqual(dictionary.count, (NSUInteger)2); // test the group keys NSArray* keys = [dictionary allKeys]; - STAssertEqualObjects(@"J", keys[0], nil); - STAssertEqualObjects(@"B", keys[1], nil); + XCTAssertEqualObjects(@"J", keys[0]); + XCTAssertEqualObjects(@"B", keys[1]); // test the values - STAssertEqualObjects(dictionary[@"J"], @"Jim", nil); - STAssertEqualObjects(dictionary[@"B"], @"Bob", nil); + XCTAssertEqualObjects(dictionary[@"J"], @"Jim"); + XCTAssertEqualObjects(dictionary[@"B"], @"Bob"); } - (void) testCount { - NSArray* input = @[@25, @35, @25]; - - NSUInteger numbersEqualTo25 = [input linq_count:^BOOL(id item) { + NSArray* input = @[@25, @35, @25]; + + NSUInteger numbersEqualTo25 = [input linq_count:^BOOL(NSNumber *item) { return [item isEqualToNumber:@25]; }]; - - STAssertEquals(numbersEqualTo25, (NSUInteger)2, nil); + + XCTAssertEqual(numbersEqualTo25, (NSUInteger)2); } - (void) testConcat { - NSArray* input = @[@25, @35]; + NSArray* input = @[@25, @35]; NSArray* result = [input linq_concat:@[@45, @55]]; - STAssertEquals(result.count, (NSUInteger)4, nil); - STAssertEqualObjects(result[0], @25, nil); - STAssertEqualObjects(result[1], @35, nil); - STAssertEqualObjects(result[2], @45, nil); - STAssertEqualObjects(result[3], @55, nil); + XCTAssertEqual(result.count, (NSUInteger)4); + XCTAssertEqualObjects(result[0], @25); + XCTAssertEqualObjects(result[1], @35); + XCTAssertEqualObjects(result[2], @45); + XCTAssertEqualObjects(result[3], @55); } - (void) testReverse @@ -498,9 +498,9 @@ - (void) testReverse NSArray* result = [input linq_reverse]; - STAssertEquals(result.count, (NSUInteger)2, nil); - STAssertEqualObjects(result[0], @35, nil); - STAssertEqualObjects(result[1], @25, nil); + XCTAssertEqual(result.count, (NSUInteger)2); + XCTAssertEqualObjects(result[0], @35); + XCTAssertEqualObjects(result[1], @25); } - (void) testSum @@ -508,7 +508,7 @@ - (void) testSum NSArray* input = @[@25, @35]; NSNumber* sum = [input linq_sum]; - STAssertEqualObjects(sum, @60, nil); + XCTAssertEqualObjects(sum, @60); } @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.h b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.h index 7362081..4ef57e3 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.h +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.h @@ -6,8 +6,8 @@ // Copyright (c) 2013 Colin Eberhardt. All rights reserved. // -#import +#import -@interface NSDictionaryLinqExtensionsTest : SenTestCase +@interface NSDictionaryLinqExtensionsTest : XCTestCase @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.m b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.m index 67a3be1..afa442f 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.m +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/NSDictionaryLinqExtensionsTest.m @@ -13,20 +13,20 @@ @implementation NSDictionaryLinqExtensionsTest - (void)testWhere { - NSDictionary* input = @{@"A" : @"Apple", + NSDictionary* input = @{@"A" : @"Apple", @"B" : @"Banana", @"C" : @"Carrot", @"D" : @"Fish"}; - NSDictionary* result = [input linq_where:^BOOL(id key, id value) { + NSDictionary* result = [input linq_where:^BOOL(NSString *key, NSString *value) { return [key isEqual:[value substringToIndex:1]]; }]; - STAssertEquals(result.allKeys.count, (NSUInteger)3, nil); - STAssertEqualObjects(result[@"A"], @"Apple", nil); - STAssertEqualObjects(result[@"B"], @"Banana", nil); - STAssertEqualObjects(result[@"C"], @"Carrot", nil); + XCTAssertEqual(result.allKeys.count, (NSUInteger)3); + XCTAssertEqualObjects(result[@"A"], @"Apple"); + XCTAssertEqualObjects(result[@"B"], @"Banana"); + XCTAssertEqualObjects(result[@"C"], @"Carrot"); } - (void)testSelect @@ -41,11 +41,11 @@ - (void)testSelect return [NSString stringWithFormat:@"%@, %@", key, [value substringToIndex:1]]; }]; - STAssertEquals(result.allKeys.count, (NSUInteger)4, nil); - STAssertEqualObjects(result[@"A"], @"A, A", nil); - STAssertEqualObjects(result[@"B"], @"B, B", nil); - STAssertEqualObjects(result[@"C"], @"C, C", nil); - STAssertEqualObjects(result[@"D"], @"D, F", nil); + XCTAssertEqual(result.allKeys.count, (NSUInteger)4); + XCTAssertEqualObjects(result[@"A"], @"A, A"); + XCTAssertEqualObjects(result[@"B"], @"B, B"); + XCTAssertEqualObjects(result[@"C"], @"C, C"); + XCTAssertEqualObjects(result[@"D"], @"D, F"); } - (void)testSelectWithNil @@ -61,11 +61,11 @@ - (void)testSelectWithNil return [projection isEqualToString:@"A, A"] ? nil : projection; }]; - STAssertEquals(result.allKeys.count, (NSUInteger)4, nil); - STAssertEqualObjects(result[@"A"], [NSNull null], nil); - STAssertEqualObjects(result[@"B"], @"B, B", nil); - STAssertEqualObjects(result[@"C"], @"C, C", nil); - STAssertEqualObjects(result[@"D"], @"D, F", nil); + XCTAssertEqual(result.allKeys.count, (NSUInteger)4); + XCTAssertEqualObjects(result[@"A"], [NSNull null]); + XCTAssertEqualObjects(result[@"B"], @"B, B"); + XCTAssertEqualObjects(result[@"C"], @"C, C"); + XCTAssertEqualObjects(result[@"D"], @"D, F"); } - (void)testToArray @@ -80,10 +80,10 @@ - (void)testToArray NSLog(@"%@", result); - STAssertEquals(result.count, (NSUInteger)3, nil); - STAssertEqualObjects(result[0], @"A, Apple", nil); - STAssertEqualObjects(result[1], @"B, Banana", nil); - STAssertEqualObjects(result[2], @"C, Carrot", nil); + XCTAssertEqual(result.count, (NSUInteger)3); + XCTAssertEqualObjects(result[0], @"A, Apple"); + XCTAssertEqualObjects(result[1], @"B, Banana"); + XCTAssertEqualObjects(result[2], @"C, Carrot"); } - (void)testToArrayWithNil @@ -99,10 +99,10 @@ - (void)testToArrayWithNil NSLog(@"%@", result); - STAssertEquals(result.count, (NSUInteger)3, nil); - STAssertEqualObjects(result[0], [NSNull null], nil); - STAssertEqualObjects(result[1], @"B, Banana", nil); - STAssertEqualObjects(result[2], @"C, Carrot", nil); + XCTAssertEqual(result.count, (NSUInteger)3); + XCTAssertEqualObjects(result[0], [NSNull null]); + XCTAssertEqualObjects(result[1], @"B, Banana"); + XCTAssertEqualObjects(result[2], @"C, Carrot"); } - (void)testAll @@ -114,12 +114,12 @@ - (void)testAll BOOL allValuesHaveTheLetterA = [input linq_all:^BOOL(id key, id value) { return [value rangeOfString:@"a"].length != 0; }]; - STAssertTrue(allValuesHaveTheLetterA, nil); + XCTAssertTrue(allValuesHaveTheLetterA); BOOL allValuesContainKey = [input linq_all:^BOOL(id key, id value) { return [value rangeOfString:key].length != 0; }]; - STAssertFalse(allValuesContainKey, nil); + XCTAssertFalse(allValuesContainKey); } - (void)testAny @@ -131,12 +131,12 @@ - (void)testAny BOOL anyValuesHaveTheLetterN = [input linq_any:^BOOL(id key, id value) { return [value rangeOfString:@"n"].length != 0; }]; - STAssertTrue(anyValuesHaveTheLetterN, nil); + XCTAssertTrue(anyValuesHaveTheLetterN); BOOL anyKeysHaveTheLetterN = [input linq_any:^BOOL(id key, id value) { return [key rangeOfString:@"n"].length != 0; }]; - STAssertFalse(anyKeysHaveTheLetterN, nil); + XCTAssertFalse(anyKeysHaveTheLetterN); } @@ -150,7 +150,7 @@ - (void)testCount NSUInteger valuesThatContainKey = [input linq_count:^BOOL(id key, id value) { return [value rangeOfString:key].length != 0; }]; - STAssertEquals(valuesThatContainKey, (NSUInteger)2, nil); + XCTAssertEqual(valuesThatContainKey, (NSUInteger)2); } - (void)testMerge @@ -166,12 +166,12 @@ - (void)testMerge NSDictionary* result = [input linq_Merge:merge]; - STAssertEquals(result.allKeys.count, (NSUInteger)5, nil); - STAssertEqualObjects(result[@"a"], @"apple", nil); - STAssertEqualObjects(result[@"b"], @"banana", nil); - STAssertEqualObjects(result[@"c"], @"bat", nil); - STAssertEqualObjects(result[@"d"], @"dog", nil); - STAssertEqualObjects(result[@"e"], @"egg", nil); + XCTAssertEqual(result.allKeys.count, (NSUInteger)5); + XCTAssertEqualObjects(result[@"a"], @"apple"); + XCTAssertEqualObjects(result[@"b"], @"banana"); + XCTAssertEqualObjects(result[@"c"], @"bat"); + XCTAssertEqualObjects(result[@"d"], @"dog"); + XCTAssertEqualObjects(result[@"e"], @"egg"); } @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Person.h b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Person.h index 70294f4..721606d 100755 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Person.h +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/Person.h @@ -12,7 +12,7 @@ @property (retain, nonatomic) NSString* name; @property (retain, nonatomic) NSNumber* age; -@property (assign) NSUInteger* intAge; +@property (assign) NSUInteger intAge; + (Person*) personWithName:(NSString*)name age:(NSNumber*)age; diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.h b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.h index 8557c3f..8cd1245 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.h +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.h @@ -6,11 +6,11 @@ // Copyright (c) 2013 Colin Eberhardt. All rights reserved. // -#import +#import /** Tests that demonstrate more complex scenarious rather than just test specific methods. */ -@interface ScenarioTests : SenTestCase +@interface ScenarioTests : XCTestCase @end diff --git a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.m b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.m index 91975d4..49ea437 100644 --- a/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.m +++ b/LinqToObjectiveCTest/LinqToObjectiveCTestTests/ScenarioTests.m @@ -32,7 +32,7 @@ - (void)testDictionaryToQuerystring return [NSString stringWithFormat:@"%@&%@", item, aggregate]; }]; - STAssertEqualObjects(@"page=24&q=how+many+kittens&lang=en-US&key=1234", result, nil); + XCTAssertEqualObjects(@"page=24&q=how+many+kittens&lang=en-US&key=1234", result); } - (void)testCountingPeopleWithSurnamesStartingWithEachLetter @@ -47,7 +47,7 @@ - (void)testCountingPeopleWithSurnamesStartingWithEachLetter return [[[person name] substringToIndex:1] uppercaseString]; }] linq_select:^id(id key, id value) { - return [NSNumber numberWithInt:[value count]]; + return [NSNumber numberWithInt:(int)[value count]]; }]; NSLog(@"%@", result); diff --git a/NSArray+LinqExtensions.h b/NSArray+LinqExtensions.h index 81361cf..0d30993 100644 --- a/NSArray+LinqExtensions.h +++ b/NSArray+LinqExtensions.h @@ -20,58 +20,58 @@ #define LINQKeyPath(__keyp) (^id(id item){return [item valueForKeyPath:@#__keyp];}) #define LINQKey(__key) (^id(id item){return [item valueForKey:@#__key];}) -typedef BOOL (^LINQCondition)(id item); - -typedef id (^LINQSelector)(id item); - -typedef id (^LINQAccumulator)(id item, id aggregate); - /** Various NSArray extensions that provide a Linq-style query API */ -@interface NSArray (QueryExtension) +@interface NSArray (QueryExtension) + +typedef BOOL (^LINQCondition)(ObjectType item); + +typedef id (^LINQSelector)(ObjectType item); + +typedef id (^LINQAccumulator)(ObjectType item, id aggregate); /** Filters a sequence of values based on a predicate. @param predicate The function to test each source element for a condition. @return An array that contains elements from the input sequence that satisfy the condition. */ -- (NSArray*) linq_where:(LINQCondition)predicate; +- (NSArray *)linq_where:(LINQCondition)predicate; /** Projects each element of a sequence into a new form. @param selector A transform function to apply to each element. @return An array whose elements are the result of invoking the transform function on each element of source. */ -- (NSArray*) linq_select:(LINQSelector)transform; +- (NSArray *)linq_select:(LINQSelector)transform; /** Projects each element of a sequence into a new form. If the transform returns nil for any of the elements, -the projection fails and returns nil. + the projection fails and returns nil. @param selector A transform function to apply to each element. @return An array whose elements are the result of invoking the transform function on each element of source. */ -- (NSArray*)linq_selectAndStopOnNil:(LINQSelector)transform; +- (NSArray *)linq_selectAndStopOnNil:(LINQSelector)transform; /** Sorts the elements of a sequence in ascending order. @return An array whose elements are sorted in ascending order. */ -- (NSArray*) linq_sort; +- (NSArray *)linq_sort; /** Sorts the elements of a sequence in ascending order by using a specified keySelector. - @param keySelector A selector that provides the 'key' which the array should by sorted by. + @param keySelector A selector that provides the 'key' which the array should by sorted by. @return An array whose elements are sorted in ascending order. */ -- (NSArray*) linq_sort:(LINQSelector)keySelector; +- (NSArray *)linq_sort:(LINQSelector)keySelector; /** Sorts the elements of a sequence in descending order. @return An array whose elements are sorted in descending order. */ -- (NSArray *)linq_sortDescending; +- (NSArray *)linq_sortDescending; /** Sorts the elements of a sequence in descending order by using a specified keySelector. @@ -85,88 +85,88 @@ the projection fails and returns nil. @param type The type to filter the elements of the sequence on. @return An array whose elements are all of the given type. */ -- (NSArray*) linq_ofType:(Class)type; +- (NSArray *)linq_ofType:(Class)type; /** Projects each element of a sequence to an NSArray and flattens the resulting sequences into one sequence. @param transform A transform function to apply to each element, this should return an NSArray. @return An array whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. */ -- (NSArray*) linq_selectMany:(LINQSelector)transform; +- (NSArray *)linq_selectMany:(LINQSelector)transform; /** Returns distinct elements from a sequence. @return An array of distinct elements. */ -- (NSArray*) linq_distinct; +- (NSArray *)linq_distinct; /** Returns distinct elements from a sequence, where the given selector is used to specify the value to use for equality for each item. @param keySelector Specifies the value to use for equality for each item. @return An array of distinct elements. */ -- (NSArray*) linq_distinct:(LINQSelector)keySelector; +- (NSArray *)linq_distinct:(LINQSelector)keySelector; /** Applies an accumulator function over a sequence. The item in the array is used as the initial aggregate value. @param accumulator An accumulator function to be invoked on each element. @return The final accumulator value. */ -- (id) linq_aggregate:(LINQAccumulator)accumulator; +- (id)linq_aggregate:(LINQAccumulator)accumulator; /** Returns the first item from the source array, or nil if the array is empty. @return The first item from the source array, or nil if the array is empty. */ -- (id) linq_firstOrNil; +- (ObjectType)linq_firstOrNil; /** Returns the first item from the source array matching a predicate, or nil if there are no objects passing the test. @param predicate The function to test each source element for a condition. @return An item from the input sequence that satisfy the condition. */ -- (id)linq_firstOrNil:(LINQCondition)predicate; +- (ObjectType)linq_firstOrNil:(LINQCondition)predicate; /** Returns the last item from the source array, or nil if the array is empty. @return The last item from the source array, or nil if the array is empty. */ -- (id) linq_lastOrNil; +- (ObjectType)linq_lastOrNil; /** Bypasses a specified number of elements in an array and then returns the remaining elements. @param count The number of elements to bypass. @return An array that contains the elements that occur after the specified index in the input array. */ -- (NSArray*) linq_skip:(NSUInteger)count; +- (NSArray *)linq_skip:(NSUInteger)count; /** Returns a specified number of contiguous elements from the start of an array. @param count The number of elements to take. @return An array that contains the specified number of elements from the start of the input array. */ -- (NSArray*) linq_take:(NSUInteger)count; +- (NSArray *)linq_take:(NSUInteger)count; /** Determines whether all the elements of the array satisfies a condition. @param condition The condition to test elements against. @return Whether all the elements of the array satisfies a condition. */ -- (BOOL) linq_all:(LINQCondition)condition; +- (BOOL)linq_all:(LINQCondition)condition; /** Determines whether any of the elements of the array satisfies a condition. @param condition The condition to test elements against. @return Whether any of the elements of the array satisfies a condition. */ -- (BOOL) linq_any:(LINQCondition)condition; +- (BOOL)linq_any:(LINQCondition)condition; /** Groups the elements of the array by keys provided by the given key selector. The returned dictionary will contain the keys that are the result of applying the key selector function to each item of the array, and the value for each key is an array of all the items that return the same key value. @param groupKeySelector Determines the group key for each item in the array @return A dictionary that groups the items via the given key selector. */ -- (NSDictionary*) linq_groupBy:(LINQSelector)groupKeySelector; +- (NSDictionary *> *)linq_groupBy:(LINQSelector)groupKeySelector; /** Transforms the source array into a dictionary by applying the given keySelector and valueSelector to each item in the array. @@ -174,39 +174,39 @@ the projection fails and returns nil. @param valueSelector A selector function that is applied to each item to determine the value it will have within the returned dictionary. @return A dictionary that is the result of applying the supplied selector functions to each item of the array. */ -- (NSDictionary*) linq_toDictionaryWithKeySelector:(LINQSelector)keySelector valueSelector:(LINQSelector)valueSelector; +- (NSDictionary *)linq_toDictionaryWithKeySelector:(LINQSelector)keySelector valueSelector:(LINQSelector)valueSelector; /** Transforms the source array into a dictionary by applying the given keySelectorto each item in the array. @param keySelector A selector function that is applied to each item to determine the key it will have within the returned dictionary. @return A dictionary that is the result of applying the supplied selector functions to each item of the array. */ -- (NSDictionary*) linq_toDictionaryWithKeySelector:(LINQSelector)keySelector; +- (NSDictionary *)linq_toDictionaryWithKeySelector:(LINQSelector)keySelector; /** Counts the number of elements in the array that satisfy the given condition. @param condition The condition to test elements against. @return The number of elements that satisfy the condition. */ -- (NSUInteger) linq_count:(LINQCondition)condition; +- (NSUInteger)linq_count:(LINQCondition)condition; /** Concatonates the given array to the end of this array. @param array The array to concatonate. @return The concatonated array. */ -- (NSArray*) linq_concat:(NSArray*)array; +- (NSArray *)linq_concat:(NSArray*)array; /** Reverses the order of items within this array. @return The reversed array. */ -- (NSArray*) linq_reverse; +- (NSArray *)linq_reverse; /** Sums the elements in the array. @return The sum of elements within this array. */ -- (NSNumber*)linq_sum; +- (NSNumber *)linq_sum; @end diff --git a/NSDictionary+LinqExtensions.h b/NSDictionary+LinqExtensions.h index 4e33ef2..9131104 100644 --- a/NSDictionary+LinqExtensions.h +++ b/NSDictionary+LinqExtensions.h @@ -8,56 +8,56 @@ #import -typedef id (^LINQKeyValueSelector)(id key, id value); - -typedef BOOL (^LINQKeyValueCondition)(id key, id value); - /** Various NSDictionary extensions that provide a Linq-style query API */ -@interface NSDictionary (QueryExtension) +@interface NSDictionary (QueryExtension) + +typedef id (^LINQKeyValueSelector)(KeyType key, ObjectType value); + +typedef BOOL (^LINQKeyValueCondition)(KeyType key, ObjectType value); /** Filters a dictionary based on a predicate. @param predicate The function to test each source key-value pair for a condition. @return A dictionary that contains key-value pairs from the input dictionary that satisfy the condition. */ -- (NSDictionary*) linq_where:(LINQKeyValueCondition)predicate; +- (NSDictionary *)linq_where:(LINQKeyValueCondition)predicate; /** Projects each element of the dictionary into a new form. @param selector A transform function to apply to each element. @return A dicionary whose elements are the result of invoking the transform function on each key-value pair of source. */ -- (NSDictionary*) linq_select:(LINQKeyValueSelector)selector; +- (NSDictionary *)linq_select:(LINQKeyValueSelector)selector; /** Projects each element of the dictionary to a new form, which is used to populate the returned array. @param selector A transform function to apply to each element. @return An array whose elements are the result of invoking the transform function on each key-value pair of source. */ -- (NSArray*) linq_toArray:(LINQKeyValueSelector)selector; +- (NSArray *)linq_toArray:(LINQKeyValueSelector)selector; /** Determines whether all of the key-value pairs of the dictionary satisfies a condition. @param condition The condition to test key-value pairs against. @return Whether any of the element of the dictionary satisfies a condition. */ -- (BOOL) linq_all:(LINQKeyValueCondition)condition; +- (BOOL)linq_all:(LINQKeyValueCondition)condition; /** Determines whether any of the key-value pairs of the dictionary satisfies a condition. @param condition The condition to test key-value pairs against. @return Whether any of the element of the dictionary satisfies a condition. */ -- (BOOL) linq_any:(LINQKeyValueCondition)condition; +- (BOOL)linq_any:(LINQKeyValueCondition)condition; /** Counts the number of key-value pairs that satisfy the given condition. @param condition The condition to test key-value pairs against. @return The number of elements that satisfy the condition. */ -- (NSUInteger) linq_count:(LINQKeyValueCondition)condition; +- (NSUInteger)linq_count:(LINQKeyValueCondition)condition; /** Merges the contents of this dictionary with the given dictionary. For any duplicates, the value from the source dictionary will be used. @@ -65,6 +65,6 @@ typedef BOOL (^LINQKeyValueCondition)(id key, id value); @param dic The dictionary to merge with. @return A dictionary which is the result of merging. */ -- (NSDictionary*) linq_Merge:(NSDictionary*)dic; +- (NSDictionary*)linq_Merge:(NSDictionary*)dic; @end