mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 12:13:54 -07:00
[Bleeding] Added sharp() and natural() factory functions to mirror the flat() one, sharped() and flattened() functions to get a note from an existing note, a toString(), and more tests. Addresses BUKKIT-861
By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
@@ -2,6 +2,7 @@ package org.bukkit;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -79,9 +80,64 @@ public class NoteTest {
|
||||
new Note((byte) 3, Note.Tone.A, true);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void createNoteOctaveNonSharpable() {
|
||||
new Note((byte) 0, Note.Tone.B, true);
|
||||
Note note = new Note((byte) 0, Note.Tone.B, true);
|
||||
assertFalse(note.isSharped());
|
||||
assertThat(note.getTone(), is(Note.Tone.C));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createNoteFlat() {
|
||||
Note note = Note.flat(0, Note.Tone.D);
|
||||
assertTrue(note.isSharped());
|
||||
assertThat(note.getTone(), is(Note.Tone.C));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createNoteFlatNonFlattenable() {
|
||||
Note note = Note.flat(0, Note.Tone.C);
|
||||
assertFalse(note.isSharped());
|
||||
assertThat(note.getTone(), is(Note.Tone.B));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlatWrapping() {
|
||||
Note note = Note.flat(1, Note.Tone.G);
|
||||
assertTrue(note.isSharped());
|
||||
assertThat(note.getTone(), is(Note.Tone.F));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlatWrapping2() {
|
||||
Note note = new Note(1, Note.Tone.G, false).flattened();
|
||||
assertTrue(note.isSharped());
|
||||
assertThat(note.getTone(), is(Note.Tone.F));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSharpWrapping() {
|
||||
Note note = new Note(1, Note.Tone.F, false).sharped();
|
||||
assertTrue(note.isSharped());
|
||||
assertThat(note.getTone(), is(Note.Tone.F));
|
||||
assertEquals(note.getOctave(), 2);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testSharpWrapping2() {
|
||||
new Note(2, Note.Tone.F, true).sharped();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHighest() {
|
||||
Note note = new Note(2, Note.Tone.F, true);
|
||||
assertEquals(note.getId(), (byte)24);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLowest() {
|
||||
Note note = new Note(0, Note.Tone.F, true);
|
||||
assertEquals(note.getId(), (byte)0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user