3 import static org.hamcrest.CoreMatchers.is;
4 import static org.hamcrest.CoreMatchers.nullValue;
5 import static org.junit.Assert.assertEquals;
6 import static org.junit.Assert.assertFalse;
7 import static org.junit.Assert.assertNotNull;
8 import static org.junit.Assert.assertThat;
9 import static org.junit.Assert.assertTrue;
10 import static org.junit.Assert.fail;
12 import java.util.Collection;
14 import org.junit.Test;
16 import com.google.common.collect.Lists;
20 public void getToneByData() {
27 public void verifySharpedData() {
29 if (!tone.isSharpable())
return;
31 assertFalse(tone.isSharped(tone.getId(
false)));
32 assertTrue(tone.isSharped(tone.getId(
true)));
37 public void verifyUnknownToneData() {
38 Collection<Byte> tones = Lists.newArrayList();
39 for (
int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
44 if (tone.isSharpable()) tones.remove(tone.getId(
true));
45 tones.remove(tone.getId());
48 for (Byte data : tones) {
55 fail(data +
" should throw IllegalArgumentException");
56 }
catch (IllegalArgumentException e) {
63 @Test(expected = IllegalArgumentException.class)
64 public void createNoteBelowMin() {
68 @Test(expected = IllegalArgumentException.class)
69 public void createNoteAboveMax() {
73 @Test(expected = IllegalArgumentException.class)
74 public void createNoteOctaveBelowMax() {
78 @Test(expected = IllegalArgumentException.class)
79 public void createNoteOctaveAboveMax() {
84 public void createNoteOctaveNonSharpable() {
91 public void createNoteFlat() {
98 public void createNoteFlatNonFlattenable() {
105 public void testFlatWrapping() {
112 public void testFlatWrapping2() {
119 public void testSharpWrapping() {
126 @Test(expected=IllegalArgumentException.class)
127 public void testSharpWrapping2() {
132 public void testHighest() {
134 assertEquals(note.
getId(), (byte)24);
138 public void testLowest() {
140 assertEquals(note.
getId(), (byte)0);
145 for (
int i = 1; i <= 24; i++) {
151 Note newNote =
new Note(octave, tone, sharped);
152 assertThat(newNote, is(note));
153 assertThat(newNote.
getId(), is(note.
getId()));
static Note flat(int octave, Tone tone)
static Tone getById(byte id)