Пример #1
0
 // noteToStringTest(): integer duration, decimal duration
 @Test
 public void noteToStringTest() {
   Note a2 = new Note(2, new Pitch('A'));
   Note a3 = new Note(.25, new Pitch('A'));
   assertEquals("A2.0", a2.toString());
   assertEquals("A0.25", a3.toString());
 }
Пример #2
0
 // noteEqualsFalseTest(): covers all false partitions
 // same pitch, different duration
 // same duration, different pitch
 // different duration, different pitch
 @Test
 public void noteEqualsFalseTest() {
   Note a2 = new Note(2, new Pitch('A'));
   Note a3 = new Note(3, new Pitch('A'));
   Note d3 = new Note(3, new Pitch('D'));
   assertFalse(a2.equals(a3));
   assertFalse(a3.equals(d3));
   assertFalse(a2.equals(d3));
 }
Пример #3
0
 // notePlayTest(): covers all partitions
 @Test
 public void notePlayTest() {
   Note shortNote = new Note(.5, new Pitch('A'));
   Note highNote = new Note(20, new Pitch('A')).transpose(20);
   try {
     SequencePlayer player = new SequencePlayer(140, 12);
     shortNote.play(player, 0);
     highNote.play(player, .5);
     assertEquals(
         "Event: NOTE_ON  Pitch: 69  Tick: 0\n"
             + "Event: NOTE_OFF Pitch: 69  Tick: 6\n"
             + "Event: NOTE_ON  Pitch: 89  Tick: 6\n"
             + "Event: NOTE_OFF Pitch: 89  Tick: 246\n"
             + "Meta event: END_OF_TRACK Tick: 246\n",
         player.toString());
   } catch (MidiUnavailableException mue) {
     mue.printStackTrace();
   } catch (InvalidMidiDataException imde) {
     imde.printStackTrace();
   }
 }
Пример #4
0
 // noteHashCodeTest()
 @Test
 public void noteHashCodeTest() {
   Note a = new Note(2, new Pitch('F'));
   Note b = new Note(2.0, new Pitch('E'));
   assertEquals(a.transpose(-1).hashCode(), b.hashCode());
 }
Пример #5
0
 // noteTransposeTest()
 @Test
 public void noteTransposeTest() {
   Note a = new Note(2, new Pitch('A'));
   assertEquals(new Pitch('B'), a.transpose(2).pitch());
 }
Пример #6
0
 // noteDurationTest()
 @Test
 public void noteDurationTest() {
   Note a = new Note(2, new Pitch('A'));
   assertTrue(2 == a.duration());
 }
Пример #7
0
 // notePitchTest()
 @Test
 public void notePitchTest() {
   Note a = new Note(2, new Pitch('A'));
   assertEquals(new Pitch('A'), a.pitch());
 }
Пример #8
0
 // noteConstructorTest()
 @Test
 public void noteConstructorTest() {
   Note a = new Note(.1 / 5, new Pitch('A'));
   assertEquals("A0.02", a.toString());
 }