Example #1
0
 // chordPlayEqualsTest(): m1 = m2
 @Test
 public void chordPlayEqualsTest() {
   Chord a = new Chord(new Note(1, new Pitch('C')), new Note(1, new Pitch('C')));
   try {
     SequencePlayer player = new SequencePlayer(140, 12);
     a.play(player, 0);
     assertEquals(
         "Event: NOTE_ON  Pitch: 60  Tick: 0\n"
             + "Event: NOTE_ON  Pitch: 60  Tick: 0\n"
             + "Event: NOTE_OFF Pitch: 60  Tick: 12\n"
             + "Event: NOTE_OFF Pitch: 60  Tick: 12\n"
             + "Meta event: END_OF_TRACK Tick: 12\n",
         player.toString());
   } catch (MidiUnavailableException mue) {
     mue.printStackTrace();
   } catch (InvalidMidiDataException imde) {
     imde.printStackTrace();
   }
 }
Example #2
0
 // chordDifferentDurationTest(): m1, m2 different duration
 @Test
 public void chordDifferentDurationTest() {
   Chord a = new Chord(new Note(1, new Pitch('C')), new Note(5, new Pitch('A')));
   assertTrue(a.duration() == a.top().duration());
   Chord b = new Chord(a, new Note(3, new Pitch('D')));
   assertTrue(b.top().duration() == b.duration());
 }
Example #3
0
 // chordToStringDifferentTest(): m1 and m2 non-equals
 @Test
 public void chordToStringDifferentTest() {
   Chord a = new Chord(new Note(2, new Pitch('C')), new Note(5, new Pitch('A')));
   assertEquals("chord(C2.0 |||| A5.0)", a.toString());
 }
Example #4
0
 // chordToStringEqualsTest(): m1 and m2 equals
 @Test
 public void chordToStringEqualsTest() {
   Chord a = new Chord(new Note(5, new Pitch('A')), new Note(5, new Pitch('A')));
   assertEquals("chord(A5.0 |||| A5.0)", a.toString());
 }
Example #5
0
 // chordEqualsFalseWrongOrderTest(): musics are identical but in wrong order
 @Test
 public void chordEqualsFalseWrongOrderTest() {
   Chord a = new Chord(new Note(2, new Pitch('C')), new Note(5, new Pitch('A')));
   Chord b = new Chord(new Note(5, new Pitch('A')), new Note(2, new Pitch('C')));
   assertFalse(a.equals(b));
 }
Example #6
0
 // chordlHashCodeTest()
 @Test
 public void chordHashCodeTest() {
   Chord a = new Chord(new Note(2, new Pitch('C')), new Note(5, new Pitch('A')));
   Music b = new Chord(new Note(2, new Pitch('D')), new Note(5, new Pitch('B'))).transpose(-2);
   assertEquals(a.hashCode(), b.hashCode());
 }
Example #7
0
 // chordSameDurationTest(): m1, m2 same duration
 @Test
 public void chordSameDurationTest() {
   Chord a = new Chord(new Note(5, new Pitch('B')), new Note(5, new Pitch('A')));
   assertTrue(5 == a.duration());
 }
Example #8
0
 // chordConstructorTest()
 @Test
 public void chordConstructorTest() {
   Chord a = new Chord(new Note(2., new Pitch('C')), new Note(1., new Pitch('F')));
   assertEquals("chord(C2.0 |||| F1.0)", a.toString());
 }