This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from heidipuk/update-to-vapor3
Update to vapor3
- Loading branch information
Showing
13 changed files
with
111 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
// swift-tools-version:4.2 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "DataURI", | ||
products: [ | ||
.library(name: "DataURI", targets: ["DataURI"]) | ||
], | ||
dependencies: [ | ||
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2), | ||
.package(url: "https://github.com/vapor/core.git", from: "3.0.0"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "DataURI", | ||
dependencies: ["Core"] | ||
), | ||
.testTarget( | ||
name: "DataURITests", | ||
dependencies: ["DataURI"] | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
public typealias Byte = UInt8 | ||
public typealias Bytes = [Byte] | ||
|
||
extension Byte { | ||
internal var asciiCode: Byte { | ||
if self >= 48 && self <= 57 { | ||
return self - 48 | ||
} else if self >= 65 && self <= 70 { | ||
return self - 55 | ||
} else { | ||
return 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extension Sequence where Iterator.Element == Byte { | ||
/// Converts a slice of bytes to | ||
/// string. Courtesy of Vapor 2 - Core and @vzsg | ||
public func makeString() -> String { | ||
let array = Array(self) + [0] | ||
|
||
return array.withUnsafeBytes { rawBuffer in | ||
guard let pointer = rawBuffer.baseAddress?.assumingMemoryBound(to: CChar.self) else { return nil } | ||
return String(validatingUTF8: pointer) | ||
} ?? "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import XCTest | ||
|
||
extension DataURITests { | ||
static let __allTests = [ | ||
("testBase64Text", testBase64Text), | ||
("testFailedInvalidScheme", testFailedInvalidScheme), | ||
("testHTMLJavascriptText", testHTMLJavascriptText), | ||
("testHTMLText", testHTMLText), | ||
("testPublicInterface", testPublicInterface), | ||
("testSpeed", testSpeed), | ||
("testTextNoType", testTextNoType), | ||
] | ||
} | ||
|
||
extension ParserTests { | ||
static let __allTests = [ | ||
("testConsume", testConsume), | ||
("testConsumePercentDecoded", testConsumePercentDecoded), | ||
("testConsumePercentDecodedFailed", testConsumePercentDecodedFailed), | ||
("testConsumeUntil", testConsumeUntil), | ||
("testConsumeWhile", testConsumeWhile), | ||
("testExtractType", testExtractType), | ||
("testExtractTypeFailed", testExtractTypeFailed), | ||
("testExtractTypeMetadata", testExtractTypeMetadata), | ||
("testExtractTypeWithMetadata", testExtractTypeWithMetadata), | ||
("testParserInit", testParserInit), | ||
] | ||
} | ||
|
||
#if !os(macOS) | ||
public func __allTests() -> [XCTestCaseEntry] { | ||
return [ | ||
testCase(DataURITests.__allTests), | ||
testCase(ParserTests.__allTests), | ||
] | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import XCTest | ||
@testable import DataURITests | ||
|
||
XCTMain([ | ||
testCase(DataURITests.allTests), | ||
testCase(ParserTests.allTests), | ||
]) | ||
import DataURITests | ||
|
||
var tests = [XCTestCaseEntry]() | ||
tests += DataURITests.__allTests() | ||
|
||
XCTMain(tests) |