Skip to content

Commit

Permalink
Wrote rudimentary tests
Browse files Browse the repository at this point in the history
* Added rudimentary tests in `TriboolTests` and `TriboolObjCTests`.
* Set up all the Xcode target and scheme similar to how a fresh `swift package generate-xcodeproj` does.
  • Loading branch information
capnslipp committed Dec 29, 2022
1 parent 64145b7 commit 93b8a25
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 14 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let package = Package(
dependencies: [],
targets: [
.target(name: "Tribool", dependencies: [], path: "Sources/"),
.testTarget(name: "TriboolTests", dependencies: ["Tribool"], path: "Tests/", sources: ["TriboolTests.swift"]),
],
swiftLanguageVersions: [
.version("3"),
Expand Down
33 changes: 33 additions & 0 deletions Tests/TriboolObjCTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// VucktCTests.m
// Vuckt
//
// Created by Cap'n Slipp on 5/13/20.
//

@import XCTest;
@import Tribool;
#import "TriboolTests-Swift.h"



@interface TriboolObjCTests : XCTestCase
@end


@implementation TriboolObjCTests

- (void)setUp {
}

- (void)tearDown {
}

- (void)testTriboolObjC
{
XCTAssertEqual(TriboolTests.indeterminateTribool, TriboolIndeterminate);
XCTAssertEqual(TriboolTests.trueTribool, TriboolTrue);
XCTAssertEqual(TriboolTests.falseTribool, TriboolFalse);
}

@end
39 changes: 39 additions & 0 deletions Tests/TriboolTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import XCTest
@testable import Tribool



@objc public final class TriboolTests : XCTestCase
{
public static let indeterminateTribool = Tribool.indeterminate
public static let trueTribool = Tribool.true
public static let falseTribool = Tribool.false


func testTribool() throws
{
var tribool = Tribool()
XCTAssertEqual(tribool, Tribool.indeterminate)
XCTAssertEqual(tribool.optionalBoolValue, nil)
XCTAssertEqual(tribool.description, "indeterminate")

tribool = .true
XCTAssertEqual(tribool, Tribool.true)
XCTAssertEqual(tribool, true)
XCTAssertEqual(tribool.boolValue, true)
XCTAssertEqual(tribool.optionalBoolValue, true)
XCTAssertEqual(tribool.description, "true")

tribool = .false
XCTAssertEqual(tribool, Tribool.false)
XCTAssertEqual(tribool, false)
XCTAssertEqual(tribool.boolValue, false)
XCTAssertEqual(tribool.optionalBoolValue, false)
XCTAssertEqual(tribool.description, "false")

tribool = .indeterminate
XCTAssertEqual(tribool, Tribool.indeterminate)
XCTAssertEqual(tribool.optionalBoolValue, nil)
XCTAssertEqual(tribool.description, "indeterminate")
}
}
183 changes: 173 additions & 10 deletions Tribool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,40 @@
objects = {

/* Begin PBXBuildFile section */
FA48B1E3295D8AC400EE0B7B /* Tribool.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = OBJ_13 /* Tribool.framework */; };
FA48B1EC295D8AE500EE0B7B /* TriboolObjCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FA48B1EA295D8AE500EE0B7B /* TriboolObjCTests.m */; };
FA48B1ED295D8AE500EE0B7B /* TriboolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA48B1EB295D8AE500EE0B7B /* TriboolTests.swift */; };
OBJ_19 /* Tribool.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* Tribool.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
FA48B1E4295D8AC400EE0B7B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = OBJ_1 /* Project object */;
proxyType = 1;
remoteGlobalIDString = OBJ_14;
remoteInfo = Tribool;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
FA48B1DF295D8AC400EE0B7B /* TriboolTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TriboolTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
FA48B1EA295D8AE500EE0B7B /* TriboolObjCTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TriboolObjCTests.m; path = Tests/TriboolObjCTests.m; sourceTree = SOURCE_ROOT; };
FA48B1EB295D8AE500EE0B7B /* TriboolTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TriboolTests.swift; path = Tests/TriboolTests.swift; sourceTree = SOURCE_ROOT; };
OBJ_13 /* Tribool.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Tribool.framework; sourceTree = BUILT_PRODUCTS_DIR; };
OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
OBJ_9 /* Tribool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tribool.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
FA48B1DC295D8AC400EE0B7B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA48B1E3295D8AC400EE0B7B /* Tribool.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
OBJ_20 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 0;
Expand All @@ -30,6 +54,8 @@
OBJ_10 /* Tests */ = {
isa = PBXGroup;
children = (
FA48B1EB295D8AE500EE0B7B /* TriboolTests.swift */,
FA48B1EA295D8AE500EE0B7B /* TriboolObjCTests.m */,
);
path = Tests;
sourceTree = "<group>";
Expand All @@ -38,6 +64,7 @@
isa = PBXGroup;
children = (
OBJ_13 /* Tribool.framework */,
FA48B1DF295D8AC400EE0B7B /* TriboolTests.xctest */,
);
name = Products;
sourceTree = BUILT_PRODUCTS_DIR;
Expand All @@ -53,25 +80,34 @@
sourceTree = "<group>";
};
OBJ_7 /* Sources */ = {
isa = PBXGroup;
children = (
OBJ_8 /* Tribool */,
);
path = Sources;
sourceTree = "<group>";
};
OBJ_8 /* Tribool */ = {
isa = PBXGroup;
children = (
OBJ_9 /* Tribool.swift */,
);
name = Tribool;
path = Sources;
sourceTree = SOURCE_ROOT;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
FA48B1DE295D8AC400EE0B7B /* TriboolTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = FA48B1E8295D8AC400EE0B7B /* Build configuration list for PBXNativeTarget "TriboolTests" */;
buildPhases = (
FA48B1DB295D8AC400EE0B7B /* Sources */,
FA48B1DC295D8AC400EE0B7B /* Frameworks */,
FA48B1DD295D8AC400EE0B7B /* Resources */,
);
buildRules = (
);
dependencies = (
FA48B1E5295D8AC400EE0B7B /* PBXTargetDependency */,
);
name = TriboolTests;
productName = TriboolTests;
productReference = FA48B1DF295D8AC400EE0B7B /* TriboolTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
OBJ_14 /* Tribool */ = {
isa = PBXNativeTarget;
buildConfigurationList = OBJ_15 /* Build configuration list for PBXNativeTarget "Tribool" */;
Expand All @@ -94,8 +130,15 @@
OBJ_1 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 9999;
TargetAttributes = {
FA48B1DE295D8AC400EE0B7B = {
CreatedOnToolsVersion = 14.2;
DevelopmentTeam = UQQE2H6P34;
LastSwiftMigration = 1420;
ProvisioningStyle = Automatic;
};
OBJ_14 = {
LastSwiftMigration = 1020;
};
Expand All @@ -115,11 +158,31 @@
projectRoot = "";
targets = (
OBJ_14 /* Tribool */,
FA48B1DE295D8AC400EE0B7B /* TriboolTests */,
);
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
FA48B1DD295D8AC400EE0B7B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
FA48B1DB295D8AC400EE0B7B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FA48B1EC295D8AE500EE0B7B /* TriboolObjCTests.m in Sources */,
FA48B1ED295D8AE500EE0B7B /* TriboolTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
OBJ_18 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 0;
Expand All @@ -130,7 +193,98 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
FA48B1E5295D8AC400EE0B7B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = OBJ_14 /* Tribool */;
targetProxy = FA48B1E4295D8AC400EE0B7B /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
FA48B1E6295D8AC400EE0B7B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = UQQE2H6P34;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 12.6;
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.slippyd.TriboolTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
FA48B1E7295D8AC400EE0B7B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = UQQE2H6P34;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GENERATE_INFOPLIST_FILE = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 12.6;
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.slippyd.TriboolTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
};
name = Release;
};
OBJ_16 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -267,6 +421,15 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
FA48B1E8295D8AC400EE0B7B /* Build configuration list for PBXNativeTarget "TriboolTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FA48B1E6295D8AC400EE0B7B /* Debug */,
FA48B1E7295D8AC400EE0B7B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
OBJ_15 /* Build configuration list for PBXNativeTarget "Tribool" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
Loading

0 comments on commit 93b8a25

Please sign in to comment.