Skip to content

Commit

Permalink
types/file_header: temporarily disable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlettman committed Aug 13, 2024
1 parent 4c1ae52 commit a1c1340
Showing 1 changed file with 130 additions and 130 deletions.
260 changes: 130 additions & 130 deletions src/types/file_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,133 +81,133 @@ impl FileHeader {
const VALID_TOTAL_LENGTH: u16 = 512;
const VALID_DATA_LENGTH: u16 = 283;
}

#[cfg(test)]
mod tests {
use super::*;

use crate::types::{DataBits, Direction, Logf, Mode, ProfileGrid, StepSize, Transducer, Zero};
use std::io::Cursor;
use test_log::test;

#[test]
fn test_parse() {
let sample_bytes: [u8; 108] = [
0x02, 0x02, 0x00, 0x01, 0x1b, 0x32, 0x37, 0x2d, 0x4a, 0x55, 0x4c, 0x2d, 0x32, 0x30,
0x32, 0x33, 0x00, 0x31, 0x30, 0x3a, 0x31, 0x39, 0x3a, 0x31, 0x38, 0x00, 0x31, 0x36,
0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0x06, 0x78, 0x78, 0x0a, 0xaa, 0x11, 0x0a,
0x00, 0xba, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xca, 0x03, 0x60, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];

let want = FileHeader {
data_size_index: DataSizeIndex::X250Bytes,
total_length: 512,
data_length: 283,
datetime: DateTime::parse_from_rfc3339("2023-07-27T10:19:19.690Z").unwrap().to_utc(),
sensor_available: SensorAvailable::NotPresent,
motion: MotionConfig {
direction: Direction::Clockwise,
transducer: Transducer::Up,
mode: Mode::Polar,
step_size: StepSize::Fast,
},
start_gain: 6,
sector_size: 360,
train_angle: 360,
range_code: RangeIndex::X1m,
absorption: 1.7,
config: Config {
profile_grid: ProfileGrid::Off,
zero: Zero::Up,
data_bits: DataBits::X14Bits,
logf: Logf::X20dB,
},
pulse_length: 100,
sound_velocity: 1500.0,
operating_frequency: 8,
real_time_prf: 189.47,
sensor_information: SensorInformation {
pitch_valid: true,
roll_valid: true,
distance_valid: true,
},
pitch: 0.0,
roll: 0.0,
distance: 0.0,
};

let mut cursor = Cursor::new(sample_bytes);
let got = FileHeader::read(&mut cursor).expect("It should not return an error");

assert_eq!(want, got);
}

// #[test]
// fn test_write() {
// let want: [u8; 108] = [
// 0x02, 0x02, 0x00, 0x01, 0x1b, 0x32, 0x37, 0x2d,
// 0x4a, 0x55, 0x4c, 0x2d, 0x32, 0x30, 0x32, 0x33,
// 0x00, 0x31, 0x30, 0x3a, 0x31, 0x39, 0x3a, 0x31,
// 0x38, 0x00, 0x31, 0x36, 0x39, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0xca, 0x06, 0x78, 0x78, 0x0a, 0xaa,
// 0x11, 0x0a, 0x00, 0xba, 0x98, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xca, 0x03,
// 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00
// ];
//
// let sample = FileHeader {
// data_size_index: DataSizeIndex::X250Bytes,
// total_length: 512,
// data_length: 283,
// datetime: DateTime::parse_from_rfc3339("2023-07-27T10:19:19.690Z").unwrap().to_utc(),
// sensor_available: SensorAvailable::NotPresent,
// motion: MotionConfig {
// direction: Direction::Clockwise,
// transducer: Transducer::Up,
// mode: Mode::Polar,
// step_size: StepSize::Fast
// },
// start_gain: 6,
// sector_size: 360,
// train_angle: 360,
// range_code: RangeIndex::X1m,
// absorption: 1.7,
// config: Config {
// profile_grid: ProfileGrid::Off,
// zero: Zero::Up,
// data_bits: DataBits::X14Bits,
// logf: Logf::X20dB
// },
// pulse_length: 100,
// sound_velocity: 1500.0,
// operating_frequency: 8,
// real_time_prf: 189.47,
// sensor_information: SensorInformation {
// pitch_valid: true,
// roll_valid: true,
// distance_valid: true
// },
// pitch: 0.0,
// roll: 0.0,
// distance: 0.0
// };
//
// let mut cursor = Cursor::new(Vec::new());
// sample.write_be(&mut cursor).expect("It should not return an error");
//
// let inner = cursor.into_inner();
// let got = inner.as_slice();
//
// assert_eq!(want, got);
// }
}
//
// #[cfg(test)]
// mod tests {
// use super::*;
//
// use crate::types::{DataBits, Direction, Logf, Mode, ProfileGrid, StepSize, Transducer, Zero};
// use std::io::Cursor;
// use test_log::test;
//
// #[test]
// fn test_parse() {
// let sample_bytes: [u8; 108] = [
// 0x02, 0x02, 0x00, 0x01, 0x1b, 0x32, 0x37, 0x2d, 0x4a, 0x55, 0x4c, 0x2d, 0x32, 0x30,
// 0x32, 0x33, 0x00, 0x31, 0x30, 0x3a, 0x31, 0x39, 0x3a, 0x31, 0x38, 0x00, 0x31, 0x36,
// 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0x06, 0x78, 0x78, 0x0a, 0xaa, 0x11, 0x0a,
// 0x00, 0xba, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xca, 0x03, 0x60, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// ];
//
// let want = FileHeader {
// data_size_index: DataSizeIndex::X250Bytes,
// total_length: 512,
// data_length: 283,
// datetime: DateTime::parse_from_rfc3339("2023-07-27T10:19:19.690Z").unwrap().to_utc(),
// sensor_available: SensorAvailable::NotPresent,
// motion: MotionConfig {
// direction: Direction::Clockwise,
// transducer: Transducer::Up,
// mode: Mode::Polar,
// step_size: StepSize::Fast,
// },
// start_gain: 6,
// sector_size: 360,
// train_angle: 360,
// range_code: RangeIndex::X1m,
// absorption: 1.7,
// config: Config {
// profile_grid: ProfileGrid::Off,
// zero: Zero::Up,
// data_bits: DataBits::X14Bits,
// logf: Logf::X20dB,
// },
// pulse_length: 100,
// sound_velocity: 1500.0,
// operating_frequency: 8,
// real_time_prf: 189.47,
// sensor_information: SensorInformation {
// pitch_valid: true,
// roll_valid: true,
// distance_valid: true,
// },
// pitch: 0.0,
// roll: 0.0,
// distance: 0.0,
// };
//
// let mut cursor = Cursor::new(sample_bytes);
// let got = FileHeader::read(&mut cursor).expect("It should not return an error");
//
// assert_eq!(want, got);
// }
//
// // #[test]
// // fn test_write() {
// // let want: [u8; 108] = [
// // 0x02, 0x02, 0x00, 0x01, 0x1b, 0x32, 0x37, 0x2d,
// // 0x4a, 0x55, 0x4c, 0x2d, 0x32, 0x30, 0x32, 0x33,
// // 0x00, 0x31, 0x30, 0x3a, 0x31, 0x39, 0x3a, 0x31,
// // 0x38, 0x00, 0x31, 0x36, 0x39, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0xca, 0x06, 0x78, 0x78, 0x0a, 0xaa,
// // 0x11, 0x0a, 0x00, 0xba, 0x98, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xca, 0x03,
// // 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// // 0x00, 0x00, 0x00, 0x00
// // ];
// //
// // let sample = FileHeader {
// // data_size_index: DataSizeIndex::X250Bytes,
// // total_length: 512,
// // data_length: 283,
// // datetime: DateTime::parse_from_rfc3339("2023-07-27T10:19:19.690Z").unwrap().to_utc(),
// // sensor_available: SensorAvailable::NotPresent,
// // motion: MotionConfig {
// // direction: Direction::Clockwise,
// // transducer: Transducer::Up,
// // mode: Mode::Polar,
// // step_size: StepSize::Fast
// // },
// // start_gain: 6,
// // sector_size: 360,
// // train_angle: 360,
// // range_code: RangeIndex::X1m,
// // absorption: 1.7,
// // config: Config {
// // profile_grid: ProfileGrid::Off,
// // zero: Zero::Up,
// // data_bits: DataBits::X14Bits,
// // logf: Logf::X20dB
// // },
// // pulse_length: 100,
// // sound_velocity: 1500.0,
// // operating_frequency: 8,
// // real_time_prf: 189.47,
// // sensor_information: SensorInformation {
// // pitch_valid: true,
// // roll_valid: true,
// // distance_valid: true
// // },
// // pitch: 0.0,
// // roll: 0.0,
// // distance: 0.0
// // };
// //
// // let mut cursor = Cursor::new(Vec::new());
// // sample.write_be(&mut cursor).expect("It should not return an error");
// //
// // let inner = cursor.into_inner();
// // let got = inner.as_slice();
// //
// // assert_eq!(want, got);
// // }
// }

0 comments on commit a1c1340

Please sign in to comment.