diff options
| author | jacksonfu14 <jackson@fashionunited.com> | 2025-11-14 18:22:21 +0100 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2025-11-14 18:22:21 +0100 |
| commit | 6aeb5a91c42446b5ea68ec81dd01079a74787c96 (patch) | |
| tree | 4de217802fc9701ca1a0dbb08685972885264ee8 /morphology-img/tests/pitch.rs | |
| parent | 30e48fe5083db3f83d68c830fb43c6a7a955a99c (diff) | |
feature: add morphology rendering module
Diffstat (limited to 'morphology-img/tests/pitch.rs')
| -rw-r--r-- | morphology-img/tests/pitch.rs | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/morphology-img/tests/pitch.rs b/morphology-img/tests/pitch.rs new file mode 100644 index 0000000..986cebc --- /dev/null +++ b/morphology-img/tests/pitch.rs @@ -0,0 +1,85 @@ +use morphology_img::pitch::{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_lilypond_note_with_flat() { + let pitch = LilyPondPitch::new("bes,"); + let duration = Duration::QUARTER; + let note = LilyPondNote::new(pitch, duration); + assert_eq!(note.as_str(), "bes,4"); +} + +#[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); +} |