Skip to content

Commit

Permalink
Introduce SPM (Swift Package Manager) support
Browse files Browse the repository at this point in the history
This involved running the `swift package init` command, followed by
performing some `git mv` commands to move the test and framework code,
removing some unneeded files afterwards, running `swift package
generate-xcodeproj` and renaming the tests directory to Tests.

I also had to add a Tests/LinuxMain.swift and add entries to the
Tests/UInt128Tests/UInt128Tests.swift files to make sure that
testing can happen on a Linux workstation without much hassle.
  • Loading branch information
Jitsusama committed May 29, 2017
1 parent 84195d8 commit 5609245
Show file tree
Hide file tree
Showing 16 changed files with 315 additions and 436 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
.DS_Store
# Unimportant user state files from XCode
*.xcuserstate
xcuserdata
# Vi swap files
*.swp
# SPM files
/.build
/Packages

7 changes: 7 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// swift-tools-version:3.1

import PackageDescription

let package = Package(
name: "UInt128"
)
2 changes: 1 addition & 1 deletion Playground.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

import UInt128

let integer: UInt128 = 0xf
let integer: UInt128 = 0xf
2 changes: 1 addition & 1 deletion Playground.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='osx'>
<playground version='5.0' target-platform='macos' timelineScrubberEnabled='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
6 changes: 0 additions & 6 deletions Playground.playground/timeline.xctimeline

This file was deleted.

File renamed without changes.
12 changes: 12 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import XCTest
@testable import UInt128Tests

XCTMain([
testCase(UInt128Tests.allTests),
testCase(UInt128StringTests.allTests),
testCase(UInt128UnsignedIntegerTests.allTests),
testCase(UInt128StrideableTests.allTests),
testCase(UInt128BitwiseOperationsTests.allTests),
testCase(UInt128IntegerArithmeticTests.allTests),
testCase(UInt128ComparableTests.allTests)
])
58 changes: 58 additions & 0 deletions tests/UInt128Tests.swift → Tests/UInt128Tests/UInt128Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ let bizarreUInt128: UInt128 = "0xf1f3f5f7f9fbfdfffefcfaf0f8f6f4f2"
/// This class' purpose in life is to test UInt128 like there's no tomorrow.
class UInt128Tests: XCTestCase {
let sanityValue = UInt128(upperBits: 1878316677920070929, lowerBits: 2022432965322149909)
static var allTests = {
return [
("testMax", testMax),
("testMin", testMin),
("testSignificantBits", testSignificantBits),
("testBigEndian", testBigEndian),
("testLittleEndian", testLittleEndian),
("testSize", testSize)
]
}
func testMax() {
XCTAssertEqual(
UInt128.max,
Expand Down Expand Up @@ -94,6 +104,15 @@ class UInt128Tests: XCTestCase {
class UInt128StringTests: XCTestCase {
let bizarreUInt128: UInt128 = "0xf1f3f5f7f9fbfdfffefcfaf0f8f6f4f2"
let sanityValue = UInt128(upperBits: 1878316677920070929, lowerBits: 2022432965322149909)
static var allTests = {
return [
("testFringeStringConversions", testFringeStringConversions),
("testBinaryStringConversion", testBinaryStringConversion),
("testOctalStringConversion", testOctalStringConversion),
("testDecimalStringConversion", testDecimalStringConversion),
("testHexadecimalStringConversion", testHexadecimalStringConversion)
]
}
func testFringeStringConversions() {
// Test Empty String Input.
do {
Expand Down Expand Up @@ -318,6 +337,14 @@ class UInt128StringTests: XCTestCase {
}*/
}
class UInt128UnsignedIntegerTests: XCTestCase {
static var allTests = {
return [
("testUIntInputs", testUIntInputs),
("testToUIntMax", testToUIntMax),
("testHashValues", testHashValues),
("testIndexTypes", testIndexTypes)
]
}
func testUIntInputs() {
// Test UInt8 Input
XCTAssertEqual(
Expand Down Expand Up @@ -391,6 +418,12 @@ class UInt128UnsignedIntegerTests: XCTestCase {
}
}
class UInt128StrideableTests: XCTestCase {
static var allTests = {
return [
("testAdvancedBy", testAdvancedBy),
("testDistanceTo", testDistanceTo)
]
}
func testAdvancedBy() {
XCTAssertEqual(
UInt128.min.advancedBy(1), UInt128(integerLiteral: 1),
Expand Down Expand Up @@ -435,6 +468,17 @@ class UInt128StrideableTests: XCTestCase {
class UInt128BitwiseOperationsTests: XCTestCase {
let allZeros = UInt128.allZeros
let allOnes = UInt128.max
static var allTests = {
return [
("testAllZeros", testAllZeros),
("testAND", testAND),
("testOR", testOR),
("testXOR", testXOR),
("testComplement", testComplement),
("testShiftLeft", testShiftLeft),
("testShiftRight", testShiftRight)
]
}
func testAllZeros() {
XCTAssertEqual(
allZeros.value.upperBits, 0,
Expand Down Expand Up @@ -613,6 +657,14 @@ class UInt128BitwiseOperationsTests: XCTestCase {
}
}
class UInt128IntegerArithmeticTests: XCTestCase {
static var allTests = {
return [
("testAddition", testAddition),
("testSubtraction", testSubtraction),
("testDivisionAndModulus", testDivisionAndModulus),
("testMultiplication", testMultiplication)
]
}
func testAddition() {
var mathOperation = UInt128.addWithOverflow(UInt128(UInt64.max), 1)
XCTAssert(
Expand Down Expand Up @@ -805,6 +857,12 @@ class UInt128IntegerArithmeticTests: XCTestCase {
}
}
class UInt128ComparableTests: XCTestCase {
static var allTests = {
return [
("testComparable", testComparable),
("testEquatable", testEquatable)
]
}
func testComparable() {
XCTAssertGreaterThan(
UInt128(UInt64.max) << 64, UInt128(UInt64.max),
Expand Down
25 changes: 25 additions & 0 deletions UInt128.xcodeproj/UInt128Tests_Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
25 changes: 25 additions & 0 deletions UInt128.xcodeproj/UInt128_Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
Loading

0 comments on commit 5609245

Please sign in to comment.