Esempio n. 1
0
  @Test
  public void musicNoteReadTest6() throws Exception {

    assertAmbiguityFree(parser, "B,"); // Nos garantiza que es válido y no hay ambigüedades
    MusicNote note = parser.parse("B,");

    assertTrue(note instanceof RelativeMusicNote);
    RelativeMusicNote rNote = (RelativeMusicNote) note;

    // Check the alteration
    assertNotNull(rNote.getOctave());
    OctaveAlteration oAlteration = rNote.getOctave();
    assertTrue(oAlteration instanceof DownOctaveAlteration);
    DownOctaveAlteration dOAlteration = (DownOctaveAlteration) oAlteration;
    assertEquals(",", dOAlteration.getValue());

    MusicNoteName mNoteName = rNote.getMusicNoteName();
    assertTrue(mNoteName instanceof BasicNoteName);
    BasicNoteName bNoteName = (BasicNoteName) mNoteName;

    assertEquals("B", bNoteName.getValue());
  }
Esempio n. 2
0
  @Test
  public void musicNoteReadTest4() throws Exception {

    assertAmbiguityFree(parser, "A#"); // Nos garantiza que es válido y no hay ambigüedades
    MusicNote note = parser.parse("A#");

    assertTrue(note instanceof RelativeMusicNote);
    RelativeMusicNote rNote = (RelativeMusicNote) note;

    assertNull(rNote.getOctave());

    MusicNoteName mNoteName = rNote.getMusicNoteName();

    assertTrue(mNoteName instanceof AlteredNoteName);
    AlteredNoteName altNoteName = (AlteredNoteName) mNoteName;

    assertEquals("A", altNoteName.getBasicNoteName().getValue());

    Alteration alteration = altNoteName.getAlteration();
    assertTrue(alteration instanceof SharpAlteration);
    SharpAlteration sharpAlteration = (SharpAlteration) alteration;
    assertEquals("#", sharpAlteration.getValue());
  }