forked from nicolasbrailo/PianOli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test NoteMapper helper with JUnit 5/Jupiter.
Our very first unit tests! Needs some additional plugins, because Google isn't moving on JUnit 5 support. see - Google tracking issue: android/android-test#224 - Android <-> JUnit 5 plugin https://github.com/mannodermaus/android-junit5 - StackOverflow answer about the plugin https://stackoverflow.com/questions/46161113/junit-5-for-android-testing
- Loading branch information
Jules Kerssemakers
committed
Sep 10, 2023
1 parent
b49495e
commit 2ff0211
Showing
3 changed files
with
31 additions
and
0 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
27 changes: 27 additions & 0 deletions
27
app/src/test/java/com/nicobrailo/pianoli/melodies/NoteMapperTest.java
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 @@ | ||
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"); | ||
} | ||
} |
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