summaryrefslogtreecommitdiff
path: root/morphology-img/tests/note_types.rs
blob: dad9753322255a48b095bfbf777c17f8de420947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use morphology_img::note::{LilyPondPitch, LilyPondNote, Duration};

#[test]
fn test_lilypond_pitch_creation() {
    let pitch = LilyPondPitch::new("c'");
    assert_eq!(pitch.as_str(), "c'");
}

#[test]
fn test_lilypond_pitch_from_string() {
    let pitch = LilyPondPitch::new("bes,".to_string());
    assert_eq!(pitch.as_str(), "bes,");
}

#[test]
fn test_duration_quarter() {
    let duration = Duration::QUARTER;
    assert_eq!(duration.as_str(), "4");
}

#[test]
fn test_duration_new() {
    let duration = Duration::new(8);
    assert_eq!(duration.as_str(), "8");
}

#[test]
fn test_lilypond_note_creation() {
    let pitch = LilyPondPitch::new("c'");
    let duration = Duration::QUARTER;
    let note = LilyPondNote::new(pitch, duration);
    assert_eq!(note.as_str(), "c'4");
}

#[test]
fn test_lilypond_note_with_different_duration() {
    let pitch = LilyPondPitch::new("d");
    let duration = Duration::new(8);
    let note = LilyPondNote::new(pitch, duration);
    assert_eq!(note.as_str(), "d8");
}

#[test]
fn test_pitch_equality() {
    let pitch1 = LilyPondPitch::new("c'");
    let pitch2 = LilyPondPitch::new("c'");
    let pitch3 = LilyPondPitch::new("d'");
    assert_eq!(pitch1, pitch2);
    assert_ne!(pitch1, pitch3);
}

#[test]
fn test_note_equality() {
    let note1 = LilyPondNote::new(
        LilyPondPitch::new("c'"),
        Duration::QUARTER
    );
    let note2 = LilyPondNote::new(
        LilyPondPitch::new("c'"),
        Duration::QUARTER
    );
    let note3 = LilyPondNote::new(
        LilyPondPitch::new("d'"),
        Duration::QUARTER
    );
    assert_eq!(note1, note2);
    assert_ne!(note1, note3);
}

#[test]
fn test_duration_equality() {
    let dur1 = Duration::new(4);
    let dur2 = Duration::QUARTER;
    let dur3 = Duration::new(8);
    assert_eq!(dur1, dur2);
    assert_ne!(dur1, dur3);
}