Add variation tests.

This commit is contained in:
Lyle Mantooth 2024-02-10 16:16:52 -05:00
parent ef9b4f3769
commit 557c34311a
Signed by: IslandUsurper
GPG key ID: 6DB52EAE123A5789

View file

@ -194,3 +194,83 @@ pub fn select_variant<'i>(input: &'i str, var: &'i Variant) -> String {
output
}
#[cfg(test)]
mod test {
use super::SfxMode;
const INPUT: &'static str = "
#VARIANT ~
#VARIANT _ tr
#SFXV ` *
#WAVE 0x20 0x62 violins
#WAVE 0x21 0x63 violas
#WAVE 0x22 ~0x01~ _0x09_ piano high
#WAVE 0x23 0x02 piano mid
#WAVE 0x24 0x07 piano lo-mid
#WAVE 0x25 0x04 piano low
##WAVE 0x26 0x06 piano x-high
#WAVE 0x27 0x75 vox
#WAVE 0x28 0x7E horn
#WAVE 0x29 0x92 oboe
";
#[test]
fn default_variant() {
let vlist = super::get_variants(INPUT, SfxMode::Off);
let def = vlist
.get("_default_")
.expect("_default_ variant always exists");
let variation = super::select_variant(INPUT, def);
assert_eq!(
variation,
"
#VARIANT
#VARIANT _ tr
#SFXV ` *
#WAVE 0x20 0x62 violins
#WAVE 0x21 0x63 violas
#WAVE 0x22 0x01 piano high
#WAVE 0x23 0x02 piano mid
#WAVE 0x24 0x07 piano lo-mid
#WAVE 0x25 0x04 piano low
##WAVE 0x26 0x06 piano x-high
#WAVE 0x27 0x75 vox
#WAVE 0x28 0x7E horn
#WAVE 0x29 0x92 oboe
"
);
}
#[test]
fn tr_variant() {
let vlist = super::get_variants(INPUT, SfxMode::Off);
let tr = vlist
.get("tr")
.expect("tr variant is in input");
let variation = super::select_variant(INPUT, tr);
assert_eq!(
variation,
"
#VARIANT ~
#VARIANT tr
#SFXV ` *
#WAVE 0x20 0x62 violins
#WAVE 0x21 0x63 violas
#WAVE 0x22 0x09 piano high
#WAVE 0x23 0x02 piano mid
#WAVE 0x24 0x07 piano lo-mid
#WAVE 0x25 0x04 piano low
##WAVE 0x26 0x06 piano x-high
#WAVE 0x27 0x75 vox
#WAVE 0x28 0x7E horn
#WAVE 0x29 0x92 oboe
"
);
}
}