-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test framework to use new Testing module and Swift tools version
- Loading branch information
1 parent
98b42de
commit 9b2cf81
Showing
5 changed files
with
144 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import XCTest | ||
import Testing | ||
import Foundation | ||
@testable import {{exercise|camelCase}} | ||
class {{exercise|camelCase}}Tests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
@Suite struct {{exercise|camelCase}}Tests { | ||
{% for case in cases %} | ||
{% if forloop.first -%} | ||
func test{{case.description |camelCase }}() { | ||
@Test("{{case.description}}") | ||
{% else -%} | ||
func test{{case.description |camelCase }}() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
@Test("{{case.description}}", .enabled(if: RUNALL)) | ||
{% endif -%} | ||
XCTAssertEqual("{{case.expected}}", Acronym.abbreviate("{{case.input.phrase}}")) | ||
func test{{case.description |camelCase }}() { | ||
#expect("{{case.expected}}" == Acronym.abbreviate("{{case.input.phrase}}")) | ||
} | ||
{% endfor -%} | ||
} |
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,4 +1,4 @@ | ||
// swift-tools-version:5.3 | ||
// swift-tools-version:6.0 | ||
|
||
import PackageDescription | ||
|
||
|
65 changes: 34 additions & 31 deletions
65
exercises/practice/acronym/Tests/AcronymTests/AcronymTests.swift
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,54 +1,57 @@ | ||
import XCTest | ||
import Foundation | ||
import Testing | ||
|
||
@testable import Acronym | ||
|
||
class AcronymTests: XCTestCase { | ||
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false | ||
|
||
@Suite struct AcronymTests { | ||
|
||
@Test("basic") | ||
func testBasic() { | ||
XCTAssertEqual("PNG", Acronym.abbreviate("Portable Network Graphics")) | ||
#expect("PNG" == Acronym.abbreviate("Portable Network Graphics")) | ||
} | ||
|
||
func testLowercaseWords() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("ROR", Acronym.abbreviate("Ruby on Rails")) | ||
@Test("lowercase words", .enabled(if: RUNALL)) | ||
func testLowercaseWords() { | ||
#expect("ROR" == Acronym.abbreviate("Ruby on Rails")) | ||
} | ||
|
||
func testPunctuation() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("FIFO", Acronym.abbreviate("First In, First Out")) | ||
@Test("punctuation", .enabled(if: RUNALL)) | ||
func testPunctuation() { | ||
#expect("FIFO" == Acronym.abbreviate("First In, First Out")) | ||
} | ||
|
||
func testAllCapsWord() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("GIMP", Acronym.abbreviate("GNU Image Manipulation Program")) | ||
@Test("all caps word", .enabled(if: RUNALL)) | ||
func testAllCapsWord() { | ||
#expect("GIMP" == Acronym.abbreviate("GNU Image Manipulation Program")) | ||
} | ||
|
||
func testPunctuationWithoutWhitespace() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("CMOS", Acronym.abbreviate("Complementary metal-oxide semiconductor")) | ||
@Test("punctuation without whitespace", .enabled(if: RUNALL)) | ||
func testPunctuationWithoutWhitespace() { | ||
#expect("CMOS" == Acronym.abbreviate("Complementary metal-oxide semiconductor")) | ||
} | ||
|
||
func testVeryLongAbbreviation() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual( | ||
"ROTFLSHTMDCOALM", | ||
Acronym.abbreviate( | ||
"Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me")) | ||
@Test("very long abbreviation", .enabled(if: RUNALL)) | ||
func testVeryLongAbbreviation() { | ||
#expect( | ||
"ROTFLSHTMDCOALM" | ||
== Acronym.abbreviate( | ||
"Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me")) | ||
} | ||
|
||
func testConsecutiveDelimiters() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("SIMUFTA", Acronym.abbreviate("Something - I made up from thin air")) | ||
@Test("consecutive delimiters", .enabled(if: RUNALL)) | ||
func testConsecutiveDelimiters() { | ||
#expect("SIMUFTA" == Acronym.abbreviate("Something - I made up from thin air")) | ||
} | ||
|
||
func testApostrophes() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("HC", Acronym.abbreviate("Halley's Comet")) | ||
@Test("apostrophes", .enabled(if: RUNALL)) | ||
func testApostrophes() { | ||
#expect("HC" == Acronym.abbreviate("Halley's Comet")) | ||
} | ||
|
||
func testUnderscoreEmphasis() throws { | ||
try XCTSkipIf(true && !runAll) // change true to false to run this test | ||
XCTAssertEqual("TRNT", Acronym.abbreviate("The Road _Not_ Taken")) | ||
@Test("underscore emphasis", .enabled(if: RUNALL)) | ||
func testUnderscoreEmphasis() { | ||
#expect("TRNT" == Acronym.abbreviate("The Road _Not_ Taken")) | ||
} | ||
} |
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
Oops, something went wrong.