add Music#chord (#204)

This commit is contained in:
Pascal Schumacher
2017-03-12 22:32:46 +01:00
committed by Ricky Yim
parent 061d3a5ba0
commit 8caa5a5841
2 changed files with 10 additions and 0 deletions
@@ -4,6 +4,7 @@ public class Music {
private static final String[] KEYS = new String[] { "C", "D", "E", "F", "G", "A", "B" };
private static final String[] KEY_VARIANTS = new String[] { "b", "#", "" };
private static final String[] CHORD_TYPES = new String[] { "", "maj", "6", "maj7", "m", "m7", "-7", "7", "dom7", "dim", "dim7", "m7b5"};
private final Faker faker;
@@ -18,4 +19,8 @@ public class Music {
public String key() {
return faker.options().option(KEYS) + faker.options().option(KEY_VARIANTS);
}
public String chord() {
return key() + faker.options().option(CHORD_TYPES);
}
}
@@ -16,4 +16,9 @@ public class MusicTest extends AbstractFakerTest {
public void key() {
assertThat(faker.music().key(), matchesRegularExpression("([A-Z])+(b|#){0,1}"));
}
@Test
public void chord() {
assertThat(faker.music().chord(), matchesRegularExpression("([A-Z])+(b|#){0,1}+(-?[a-zA-Z0-9]{0,4})"));
}
}