diff --git a/app/build.gradle b/app/build.gradle index cd4f8f2..8fb1b5b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.application' +apply plugin: 'de.mannodermaus.android-junit5' android { compileSdkVersion 33 @@ -51,6 +52,8 @@ dependencies { implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.preference:preference:1.2.0' implementation "androidx.annotation:annotation:1.6.0" + + testImplementation "org.junit.jupiter:junit-jupiter:5.9.2" } // Not sure why this started happening all of a sudden, but the buidl was failing diff --git a/app/src/test/java/com/nicobrailo/pianoli/melodies/NoteMapperTest.java b/app/src/test/java/com/nicobrailo/pianoli/melodies/NoteMapperTest.java new file mode 100644 index 0000000..57bc274 --- /dev/null +++ b/app/src/test/java/com/nicobrailo/pianoli/melodies/NoteMapperTest.java @@ -0,0 +1,27 @@ +package com.nicobrailo.pianoli.melodies; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static com.nicobrailo.pianoli.melodies.NoteMapper.get_key_idx_from_note; +import static org.junit.jupiter.api.Assertions.*; + +class NoteMapperTest { + + @Test + public void noteRangeLimits() { + assertEquals(0, get_key_idx_from_note("C1"), + "lowest parsable note should be parsed"); + assertEquals(26, get_key_idx_from_note("B2"), + "lowest parsable note should be parsed"); + + } + + @ParameterizedTest + @ValueSource(strings = {"C#1", "Db1", "Dâ™­1"}) + public void fancySynonyms(String note) { + assertEquals(1, get_key_idx_from_note(note), + "all synonyms for the same note should work, including fancy symbols"); + } +} diff --git a/build.gradle b/build.gradle index f50a357..3715dda 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:8.0.2' + classpath "de.mannodermaus.gradle.plugins:android-junit5:1.9.3.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files