Merge pull request #254 from jonreid/master

Update Swift Package Manager, clean up starting test, add README
This commit is contained in:
Emily Bache 2021-08-23 07:31:21 +02:00 committed by GitHub
commit 045597940b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 13 deletions

View File

@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.3
import PackageDescription

12
swift/README.md Normal file
View File

@ -0,0 +1,12 @@
## Build and test using any of the following
Command line:
- `swift test`
Xcode:
- Open this "swift" folder to open package
- In the Xcode menu, select Product > Test to run tests
AppCode:
- Open this "swift" folder to open package
- Select "GildedRoseTests" configuration and run

View File

@ -1,12 +1,12 @@
public class GildedRose {
var items:[Item]
var items: [Item]
public init(items:[Item]) {
public init(items: [Item]) {
self.items = items
}
public func updateQuality() {
for i in 0..<items.count {
for i in 0 ..< items.count {
if (items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert") {
if (items[i].quality > 0) {
if (items[i].name != "Sulfuras, Hand of Ragnaros") {

View File

@ -3,16 +3,14 @@ import XCTest
class GildedRoseTests: XCTestCase {
func testFoo() {
func testFoo() throws {
let items = [Item(name: "foo", sellIn: 0, quality: 0)]
let app = GildedRose(items: items);
app.updateQuality();
XCTAssertEqual("fixme", app.items[0].name);
let app = GildedRose(items: items)
app.updateQuality()
XCTAssertEqual(app.items[0].name, "fixme")
}
static var allTests : [(String, (GildedRoseTests) -> () throws -> Void)] {
return [
("testFoo", testFoo),
]
}
static var allTests = [
("testFoo", testFoo),
]
}