-
-
Notifications
You must be signed in to change notification settings - Fork 13
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 #30 from x-0o0/jaesung/feature/keyword-based-search
String keyword-based search
- Loading branch information
Showing
5 changed files
with
126 additions
and
6 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,23 +1,26 @@ | ||
// swift-tools-version:5.4 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
// swift-tools-version:5.9 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SwiftyChords", | ||
platforms: [.iOS(.v13), .macOS(.v11)], | ||
products: [ | ||
// Products define the executables and libraries produced by a package, and make them visible to other packages. | ||
.library( | ||
name: "SwiftyChords", | ||
targets: ["SwiftyChords"]), | ||
targets: ["SwiftyChords"] | ||
), | ||
], | ||
dependencies: [], | ||
targets: [ | ||
.target( | ||
name: "SwiftyChords", | ||
dependencies: [], | ||
resources: [.process("Resources")] | ||
), | ||
.testTarget( | ||
name: "SwiftyChordsTests", | ||
dependencies: [ | ||
"SwiftyChords" | ||
] | ||
) | ||
] | ||
) |
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,27 @@ | ||
// | ||
// ArrayExtensionTests.swift | ||
// | ||
// | ||
// Created on 7/28/24. | ||
// | ||
|
||
#if canImport(Testing) | ||
import Testing | ||
@testable import SwiftyChords | ||
|
||
@Suite | ||
struct ArrayExtensionTests { | ||
@Test( | ||
"Tests 'matching(keyword:)'", | ||
arguments: Chord.allCases | ||
) | ||
func matchingKeyword(chord: Chord) throws { | ||
let chords = Chords.guitar | ||
let positions = chords.matching(keyword: chord.keyword) | ||
|
||
#expect(positions.filter { $0.key.rawValue != chord.key.rawValue }.isEmpty) | ||
#expect(positions.filter { $0.suffix.rawValue != chord.suffix.rawValue }.isEmpty) | ||
} | ||
} | ||
#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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Chord.Tests.swift | ||
// | ||
// | ||
// Created on 7/28/24. | ||
// | ||
|
||
enum Chord: CaseIterable { | ||
case cSharpMajor, aMinor, cBasedG, dSus4, g7 | ||
|
||
var keyword: String { | ||
switch self { | ||
case .cSharpMajor: | ||
"C#" | ||
case .aMinor: | ||
"Am" | ||
case .cBasedG: | ||
"C/G" | ||
case .dSus4: | ||
"Dsus4" | ||
case .g7: | ||
"G7" | ||
} | ||
} | ||
var key: Chords.Key { | ||
switch self { | ||
case .cSharpMajor: Chords.Key.cSharp | ||
case .aMinor: Chords.Key.a | ||
case .cBasedG: Chords.Key.c | ||
case .dSus4: Chords.Key.d | ||
case .g7: Chords.Key.g | ||
} | ||
} | ||
|
||
var suffix: Chords.Suffix { | ||
switch self { | ||
case .cSharpMajor: Chords.Suffix.major | ||
case .aMinor: Chords.Suffix.minor | ||
case .cBasedG: Chords.Suffix.slashG | ||
case .dSus4: Chords.Suffix.susFour | ||
case .g7: Chords.Suffix.seven | ||
} | ||
} | ||
} | ||
|