config: add test_fit_eeprom

pull/20/head
Astro 2020-09-24 20:59:04 +02:00
parent 58e648b5e0
commit 17e89b2041
1 changed files with 27 additions and 1 deletions

View File

@ -33,7 +33,7 @@ impl Config {
}
}
#[derive(Serialize, Deserialize)]
#[derive(Clone, Serialize, Deserialize)]
pub struct ChannelConfig {
center: CenterPoint,
pid: pid::Parameters,
@ -53,3 +53,29 @@ impl ChannelConfig {
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_fit_eeprom() {
let channel_config = ChannelConfig {
center: CenterPoint::Override(1.5),
pid: pid::Parameters::default(),
pid_target: 93.7,
sh: steinhart_hart::Parameters::default(),
};
let config = Config {
channels: [
channel_config.clone(),
channel_config.clone(),
],
};
const EEPROM_SIZE: usize = 0x80;
let mut buffer = [0; EEPROM_SIZE];
let buffer = config.encode(&mut buffer).unwrap();
assert!(buffer.len() <= EEPROM_SIZE);
}
}