Skip to content

Commit

Permalink
feat: added sus chord support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tgo1014 committed Jun 23, 2024
1 parent f82d601 commit 2d71c86
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ afterEvaluate {
from components.java
groupId = 'com.github.Tgo1014'
artifactId = 'Khord'
version = '1.1.1'
version = '1.2.0'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/tgo1014/khord/Khord.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public object Khord {
return validList.contains(chord[1]) || chord[1].isDigit()
}
val chordFirstChar = chord.firstOrNull { it.isUpperCase() }?.toString()
if (chordFirstChar in ChordRoot.allChords && chord.findAnyOf(listOf("add", "/", "º", "°")) != null) {
if (chordFirstChar in ChordRoot.allChords && chord.findAnyOf(listOf("add", "/", "º", "°", "sus")) != null) {
return true
}
if (chordFirstChar in ChordRoot.allChords && chord.any { it.isDigit() }) {
Expand Down
14 changes: 14 additions & 0 deletions src/test/kotlin/tgo1014/khord/KhordTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,18 @@ class KhordTest {
assertEquals("G#6(9)", result)
}

@Test
fun `GIVEN chord is sus WHEN searching THEN return as valid chord`() {
val result = Khord.find("Gsus G")
assertEquals("Gsus", result[0].chord)
assertEquals("G", result[1].chord)
}

@Test
fun `GIVEN sus chord WHEN transposing THEN transposes correctly`() {
val chord = Khord.find("Gsus").first()
val result = Khord.transposeChord(chord, ChordRoot.C, ChordRoot.Db)
assertEquals("G#sus", result)
}

}

0 comments on commit 2d71c86

Please sign in to comment.