Skip to content

Commit 8bd6b7e

Browse files
fixed unit-tests
1 parent 0b2085a commit 8bd6b7e

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

Sources/Tonic/Chord.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public struct Chord: Equatable, Codable {
9494
/// - Returns: Roman Numeral notation
9595
public func romanNumeralNotation(in key: Key) -> String? {
9696
let capitalRomanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII"]
97-
if let index = key.primaryTriads.firstIndex(where: { $0 == self }) {
97+
if let index = key.primaryTriads().firstIndex(where: { $0 == self }) {
9898
let romanNumeral = capitalRomanNumerals[index]
9999
switch type {
100100
case .major: return romanNumeral

Tests/TonicTests/ChordTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ class ChordTests: XCTestCase {
185185
}
186186

187187
func testRomanNumerals() {
188-
XCTAssertEqual(Key.C.primaryTriads.map { $0.romanNumeralNotation(in: Key.C) ?? "" },
188+
XCTAssertEqual(Key.C.primaryTriads().map { $0.romanNumeralNotation(in: Key.C) ?? "" },
189189
["I", "ii", "iii", "IV", "V", "vi", "vii°"])
190-
XCTAssertEqual(Key.C.primaryTriads.map { $0.romanNumeralNotation(in: Key.Am) ?? "" },
190+
XCTAssertEqual(Key.C.primaryTriads().map { $0.romanNumeralNotation(in: Key.Am) ?? "" },
191191
["III", "iv", "v", "VI", "VII", "i", "ii°"])
192-
XCTAssertEqual(Key.C.primaryTriads.map { $0.romanNumeralNotation(in: Key.G) ?? "" },
192+
XCTAssertEqual(Key.C.primaryTriads().map { $0.romanNumeralNotation(in: Key.G) ?? "" },
193193
["IV", "", "vi", "", "I", "ii", ""])
194-
XCTAssertEqual(Key.Am.primaryTriads.map { $0.romanNumeralNotation(in: Key.Am) ?? "" },
194+
XCTAssertEqual(Key.Am.primaryTriads().map { $0.romanNumeralNotation(in: Key.Am) ?? "" },
195195
["i", "ii°", "III", "iv", "v", "VI", "VII"])
196-
XCTAssertEqual(Key.Am.primaryTriads.map { $0.romanNumeralNotation(in: Key.C) ?? "" },
196+
XCTAssertEqual(Key.Am.primaryTriads().map { $0.romanNumeralNotation(in: Key.C) ?? "" },
197197
["vi", "vii°", "I", "ii", "iii", "IV", "V"])
198198
}
199199

Tests/TonicTests/KeyTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@ class KeyTests: XCTestCase {
1717
}
1818

1919
func testKeyPrimaryTriads() {
20-
XCTAssertEqual(Key.C.primaryTriads.map { $0.description },
20+
XCTAssertEqual(Key.C.primaryTriads().map { $0.description },
2121
["C", "Dm", "Em", "F", "G", "Am", ""])
22-
XCTAssertEqual(Key.Am.primaryTriads.map { $0.description },
22+
XCTAssertEqual(Key.Am.primaryTriads().map { $0.description },
2323
["Am", "", "C", "Dm", "Em", "F", "G"])
24-
XCTAssertEqual(Key.G.primaryTriads.map { $0.description },
24+
XCTAssertEqual(Key.G.primaryTriads().map { $0.description },
2525
["G", "Am", "Bm", "C", "D", "Em", "F♯°"])
26-
XCTAssertEqual(Key.Cs.primaryTriads.map { $0.description },
26+
XCTAssertEqual(Key.Cs.primaryTriads().map { $0.description },
2727
["C♯", "D♯m", "E♯m", "F♯", "G♯", "A♯m", "B♯°"])
28-
XCTAssertEqual(Key.Cb.primaryTriads.map { $0.description },
28+
XCTAssertEqual(Key.Cb.primaryTriads().map { $0.description },
2929
["C♭", "D♭m", "E♭m", "F♭", "G♭", "A♭m", "B♭°"])
3030
}
3131

3232
func testScalePrimaryTriads() {
33-
XCTAssertEqual(Key(root: .C, scale: .harmonicMinor).primaryTriads.map { $0.description },
33+
XCTAssertEqual(Key(root: .C, scale: .harmonicMinor).primaryTriads().map { $0.description },
3434
["Cm", "", "E♭⁺", "Fm", "G", "A♭", ""])
3535

36-
XCTAssertEqual(Key(root: .Db, scale: .phrygian).primaryTriads.map { $0.description },
36+
XCTAssertEqual(Key(root: .Db, scale: .phrygian).primaryTriads().map { $0.description },
3737
["D♭m", "E𝄫", "F♭", "G♭m", "A♭°", "B𝄫", "C♭m"])
3838

39-
XCTAssertEqual(Key(root: .Ds, scale: .harmonicMinor).primaryTriads.map { $0.description },
39+
XCTAssertEqual(Key(root: .Ds, scale: .harmonicMinor).primaryTriads().map { $0.description },
4040
["D♯m", "E♯°", "F♯⁺", "G♯m", "A♯", "B", "C𝄪°"])
4141
}
4242

4343
func testKeyChords() {
44-
XCTAssertEqual(Key.G.chords.count, 60) // This should only change if new chord types are added
45-
for triad in Key.G.primaryTriads {
46-
XCTAssert(Key.G.chords.contains(triad))
44+
XCTAssertEqual(Key.G.chords().count, 60) // This should only change if new chord types are added
45+
for triad in Key.G.primaryTriads() {
46+
XCTAssert(Key.G.chords().contains(triad))
4747
}
4848
}
4949

Tests/TonicTests/ReadMeTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ final class ReadMeTests: XCTestCase {
1616

1717
// What chords are in this key?
1818
func testChordsInKey() {
19-
XCTAssertEqual(Key.Cm.chords.count, 60)
19+
XCTAssertEqual(Key.Cm.chords().count, 60)
2020
}
2121

2222
// What chords in this key contain this note?
2323
func testChordsInKeyContainNote() {
24-
XCTAssertEqual(Key.C.chords.filter { $0.noteClasses.contains(.C) }.count, 36)
24+
XCTAssertEqual(Key.C.chords().filter { $0.noteClasses.contains(.C) }.count, 36)
2525
}
2626

2727
// What notes do these keys have in common?

0 commit comments

Comments
 (0)