#![allow(
clippy::approx_constant,
clippy::useless_vec,
clippy::len_zero,
clippy::unnecessary_cast,
clippy::redundant_closure,
clippy::too_many_arguments,
clippy::type_complexity,
clippy::needless_borrow,
clippy::enum_variant_names,
clippy::upper_case_acronyms,
clippy::inconsistent_digit_grouping,
clippy::unit_cmp,
clippy::assertions_on_constants,
clippy::iter_on_single_items,
clippy::expect_fun_call,
clippy::redundant_pattern_matching,
variant_size_differences,
clippy::absurd_extreme_comparisons,
clippy::nonminimal_bool,
clippy::for_kv_map,
clippy::needless_range_loop,
clippy::single_match,
clippy::collapsible_if,
clippy::needless_return,
clippy::redundant_clone,
clippy::map_entry,
clippy::match_single_binding,
clippy::bool_comparison,
clippy::derivable_impls,
clippy::manual_range_contains,
clippy::needless_borrows_for_generic_args,
clippy::manual_map,
clippy::vec_init_then_push,
clippy::identity_op,
clippy::manual_flatten,
clippy::single_char_pattern,
clippy::search_is_some,
clippy::option_map_unit_fn,
clippy::while_let_on_iterator,
clippy::clone_on_copy,
clippy::box_collection,
clippy::redundant_field_names,
clippy::ptr_arg,
clippy::large_enum_variant,
clippy::match_ref_pats,
clippy::needless_pass_by_value,
clippy::unused_unit,
clippy::let_and_return,
clippy::suspicious_else_formatting,
clippy::manual_strip,
clippy::match_like_matches_macro,
clippy::from_over_into,
clippy::wrong_self_convention,
clippy::inherent_to_string,
clippy::new_without_default,
clippy::unnecessary_wraps,
clippy::field_reassign_with_default,
clippy::manual_find,
clippy::unnecessary_lazy_evaluations,
clippy::should_implement_trait,
clippy::missing_safety_doc,
clippy::unusual_byte_groupings,
clippy::bool_assert_comparison,
clippy::zero_prefixed_literal,
clippy::await_holding_lock,
clippy::manual_saturating_arithmetic,
clippy::explicit_counter_loop,
clippy::needless_lifetimes,
clippy::single_component_path_imports,
clippy::uninlined_format_args,
clippy::iter_cloned_collect,
clippy::manual_str_repeat,
clippy::excessive_precision,
clippy::precedence,
clippy::unnecessary_literal_unwrap
)]
use oxicode::{decode_from_slice, encode_to_vec, Decode, Encode};
use proptest::prelude::*;
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct CoreTemperatureReading {
channel_id: u32,
axial_position_m: f32,
radial_position_m: f32,
temperature_c: f32,
timestamp_s: u64,
calibrated: bool,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct ControlRodPosition {
rcca_id: u16,
steps_withdrawn: u16,
speed_steps_per_min: f32,
coil_current_a: f32,
rod_bottom: bool,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct NeutronFluxMeasurement {
detector_id: u32,
flux_n_per_cm2_s: f64,
power_range_pct: f32,
range_type: u8,
axial_offset: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct PrimaryCoolantLoop {
loop_id: u8,
t_hot_c: f32,
t_cold_c: f32,
rcp_speed_rpm: f32,
flow_rate_kg_per_s: f32,
pressuriser_pressure_mpa: f32,
pressuriser_level_frac: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct SteamGeneratorTube {
sg_id: u8,
row: u16,
column: u16,
degradation_pct: f32,
plugged: bool,
eddy_current_v: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct ContainmentPressure {
sensor_id: u32,
pressure_kpa: f32,
temperature_c: f32,
humidity_frac: f32,
hydrogen_vol_pct: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct RadiationDosimetry {
badge_id: u64,
dose_msv: f32,
dose_rate_usv_per_h: f32,
alarm_active: bool,
zone_code: u8,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct SpentFuelPool {
pool_id: u8,
water_temp_c: f32,
level_above_fuel_m: f32,
cooling_outlet_c: f32,
boron_ppm: f32,
assembly_count: u16,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
enum DieselGeneratorState {
Standby {
jacket_water_temp_c: f32,
fuel_level_frac: f32,
},
Running {
output_kw: f32,
frequency_hz: f32,
lube_oil_pressure_kpa: f32,
exhaust_temp_c: f32,
},
Failed {
failure_code: u16,
},
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct EccsValvePosition {
valve_tag: String,
stem_position_frac: f32,
auto_actuated: bool,
accumulator_pressure_mpa: f32,
motor_current_a: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
enum RpsTrip {
Normal,
HighFlux { flux_pct: f32 },
OverTemperatureDeltaT { delta_t_c: f32, setpoint_c: f32 },
LowPressure {
pressure_mpa: f32,
setpoint_mpa: f32,
},
HighPressuriserlevel { level_frac: f32 },
LowFlow { loop_id: u8, flow_pct: f32 },
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct BoronConcentration {
sample_point_id: u32,
boron_ppm: f32,
sample_temp_c: f32,
timestamp_s: u64,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct CoolantChemistry {
sample_id: u64,
ph_25c: f32,
dissolved_o2_ppb: f32,
lithium7_ppm: f32,
chloride_ppb: f32,
conductivity_us_per_cm: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct TurbineGeneratorSnapshot {
unit_id: u8,
speed_rpm: f32,
output_mwe: f32,
main_steam_pressure_mpa: f32,
condenser_vacuum_kpa: f32,
h2_cooling_kpa: f32,
}
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
struct SeismicReading {
station_id: u32,
pga_g: f32,
cav_cm_per_s: f32,
obe_exceeded: bool,
sse_exceeded: bool,
}
#[test]
fn test_core_temperature_roundtrip() {
proptest!(|(
channel_id: u32,
axial_position_m in 0.0f32..4.0f32,
radial_position_m in 0.0f32..2.5f32,
temperature_c in 250.0f32..350.0f32,
timestamp_s: u64,
calibrated: bool,
)| {
let val = CoreTemperatureReading {
channel_id, axial_position_m, radial_position_m,
temperature_c, timestamp_s, calibrated,
};
let enc = encode_to_vec(&val).expect("encode CoreTemperatureReading failed");
let (dec, consumed): (CoreTemperatureReading, usize) =
decode_from_slice(&enc).expect("decode CoreTemperatureReading failed");
prop_assert_eq!(&val, &dec, "CoreTemperatureReading roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_core_temperature_determinism() {
proptest!(|(
channel_id: u32,
axial_position_m in 0.0f32..4.0f32,
radial_position_m in 0.0f32..2.5f32,
temperature_c in 250.0f32..350.0f32,
timestamp_s: u64,
calibrated: bool,
)| {
let val = CoreTemperatureReading {
channel_id, axial_position_m, radial_position_m,
temperature_c, timestamp_s, calibrated,
};
let enc1 = encode_to_vec(&val).expect("first encode CoreTemperatureReading failed");
let enc2 = encode_to_vec(&val).expect("second encode CoreTemperatureReading failed");
prop_assert_eq!(enc1, enc2, "encoding must be deterministic");
});
}
#[test]
fn test_control_rod_position_roundtrip() {
proptest!(|(
rcca_id in 0u16..53u16,
steps_withdrawn in 0u16..229u16,
speed_steps_per_min in 0.0f32..72.0f32,
coil_current_a in 0.0f32..10.0f32,
rod_bottom: bool,
)| {
let val = ControlRodPosition {
rcca_id, steps_withdrawn, speed_steps_per_min,
coil_current_a, rod_bottom,
};
let enc = encode_to_vec(&val).expect("encode ControlRodPosition failed");
let (dec, consumed): (ControlRodPosition, usize) =
decode_from_slice(&enc).expect("decode ControlRodPosition failed");
prop_assert_eq!(&val, &dec, "ControlRodPosition roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_vec_control_rod_roundtrip() {
proptest!(|(
items in prop::collection::vec(
(
0u16..53u16,
0u16..229u16,
0.0f32..72.0f32,
0.0f32..10.0f32,
any::<bool>(),
).prop_map(|(rcca_id, steps_withdrawn, speed_steps_per_min, coil_current_a, rod_bottom)| {
ControlRodPosition { rcca_id, steps_withdrawn, speed_steps_per_min, coil_current_a, rod_bottom }
}),
0..12usize,
),
)| {
let enc = encode_to_vec(&items).expect("encode Vec<ControlRodPosition> failed");
let (dec, consumed): (Vec<ControlRodPosition>, usize) =
decode_from_slice(&enc).expect("decode Vec<ControlRodPosition> failed");
prop_assert_eq!(&items, &dec, "Vec<ControlRodPosition> roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_neutron_flux_roundtrip() {
proptest!(|(
detector_id: u32,
flux_n_per_cm2_s in 1e6f64..1e14f64,
power_range_pct in 0.0f32..120.0f32,
range_type in 0u8..3u8,
axial_offset in (-1.0f32)..1.0f32,
)| {
let val = NeutronFluxMeasurement {
detector_id, flux_n_per_cm2_s, power_range_pct,
range_type, axial_offset,
};
let enc = encode_to_vec(&val).expect("encode NeutronFluxMeasurement failed");
let (dec, consumed): (NeutronFluxMeasurement, usize) =
decode_from_slice(&enc).expect("decode NeutronFluxMeasurement failed");
prop_assert_eq!(&val, &dec, "NeutronFluxMeasurement roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_neutron_flux_reencode_idempotent() {
proptest!(|(
detector_id: u32,
flux_n_per_cm2_s in 1e6f64..1e14f64,
power_range_pct in 0.0f32..120.0f32,
range_type in 0u8..3u8,
axial_offset in (-1.0f32)..1.0f32,
)| {
let val = NeutronFluxMeasurement {
detector_id, flux_n_per_cm2_s, power_range_pct,
range_type, axial_offset,
};
let enc1 = encode_to_vec(&val).expect("first encode NeutronFluxMeasurement failed");
let (decoded, _): (NeutronFluxMeasurement, usize) =
decode_from_slice(&enc1).expect("decode NeutronFluxMeasurement failed");
let enc2 = encode_to_vec(&decoded).expect("re-encode NeutronFluxMeasurement failed");
prop_assert_eq!(enc1, enc2, "re-encoding must produce identical bytes");
});
}
#[test]
fn test_primary_coolant_loop_roundtrip() {
proptest!(|(
loop_id in 1u8..5u8,
t_hot_c in 300.0f32..330.0f32,
t_cold_c in 280.0f32..295.0f32,
rcp_speed_rpm in 1100.0f32..1200.0f32,
flow_rate_kg_per_s in 4000.0f32..5500.0f32,
pressuriser_pressure_mpa in 14.5f32..16.0f32,
pressuriser_level_frac in 0.2f32..0.8f32,
)| {
let val = PrimaryCoolantLoop {
loop_id, t_hot_c, t_cold_c, rcp_speed_rpm,
flow_rate_kg_per_s, pressuriser_pressure_mpa, pressuriser_level_frac,
};
let enc = encode_to_vec(&val).expect("encode PrimaryCoolantLoop failed");
let (dec, consumed): (PrimaryCoolantLoop, usize) =
decode_from_slice(&enc).expect("decode PrimaryCoolantLoop failed");
prop_assert_eq!(&val, &dec, "PrimaryCoolantLoop roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_steam_generator_tube_roundtrip() {
proptest!(|(
sg_id in 1u8..5u8,
row in 1u16..100u16,
column in 1u16..150u16,
degradation_pct in 0.0f32..100.0f32,
plugged: bool,
eddy_current_v in 0.0f32..10.0f32,
)| {
let val = SteamGeneratorTube {
sg_id, row, column, degradation_pct, plugged, eddy_current_v,
};
let enc = encode_to_vec(&val).expect("encode SteamGeneratorTube failed");
let (dec, consumed): (SteamGeneratorTube, usize) =
decode_from_slice(&enc).expect("decode SteamGeneratorTube failed");
prop_assert_eq!(&val, &dec, "SteamGeneratorTube roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_vec_steam_generator_tube_roundtrip() {
proptest!(|(
items in prop::collection::vec(
(
1u8..5u8,
1u16..100u16,
1u16..150u16,
0.0f32..100.0f32,
any::<bool>(),
0.0f32..10.0f32,
).prop_map(|(sg_id, row, column, degradation_pct, plugged, eddy_current_v)| {
SteamGeneratorTube { sg_id, row, column, degradation_pct, plugged, eddy_current_v }
}),
0..8usize,
),
)| {
let enc = encode_to_vec(&items).expect("encode Vec<SteamGeneratorTube> failed");
let (dec, consumed): (Vec<SteamGeneratorTube>, usize) =
decode_from_slice(&enc).expect("decode Vec<SteamGeneratorTube> failed");
prop_assert_eq!(&items, &dec, "Vec<SteamGeneratorTube> roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_containment_pressure_roundtrip() {
proptest!(|(
sensor_id: u32,
pressure_kpa in 90.0f32..450.0f32,
temperature_c in 20.0f32..150.0f32,
humidity_frac in 0.0f32..1.0f32,
hydrogen_vol_pct in 0.0f32..5.0f32,
)| {
let val = ContainmentPressure {
sensor_id, pressure_kpa, temperature_c, humidity_frac, hydrogen_vol_pct,
};
let enc = encode_to_vec(&val).expect("encode ContainmentPressure failed");
let (dec, consumed): (ContainmentPressure, usize) =
decode_from_slice(&enc).expect("decode ContainmentPressure failed");
prop_assert_eq!(&val, &dec, "ContainmentPressure roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_radiation_dosimetry_roundtrip() {
proptest!(|(
badge_id: u64,
dose_msv in 0.0f32..50.0f32,
dose_rate_usv_per_h in 0.0f32..10000.0f32,
alarm_active: bool,
zone_code in 0u8..4u8,
)| {
let val = RadiationDosimetry {
badge_id, dose_msv, dose_rate_usv_per_h, alarm_active, zone_code,
};
let enc = encode_to_vec(&val).expect("encode RadiationDosimetry failed");
let (dec, consumed): (RadiationDosimetry, usize) =
decode_from_slice(&enc).expect("decode RadiationDosimetry failed");
prop_assert_eq!(&val, &dec, "RadiationDosimetry roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_radiation_dosimetry_reencode_idempotent() {
proptest!(|(
badge_id: u64,
dose_msv in 0.0f32..50.0f32,
dose_rate_usv_per_h in 0.0f32..10000.0f32,
alarm_active: bool,
zone_code in 0u8..4u8,
)| {
let val = RadiationDosimetry {
badge_id, dose_msv, dose_rate_usv_per_h, alarm_active, zone_code,
};
let enc1 = encode_to_vec(&val).expect("first encode RadiationDosimetry failed");
let (decoded, _): (RadiationDosimetry, usize) =
decode_from_slice(&enc1).expect("decode RadiationDosimetry failed");
let enc2 = encode_to_vec(&decoded).expect("re-encode RadiationDosimetry failed");
prop_assert_eq!(enc1, enc2, "re-encoding must produce identical bytes");
});
}
#[test]
fn test_spent_fuel_pool_roundtrip() {
proptest!(|(
pool_id in 1u8..4u8,
water_temp_c in 25.0f32..65.0f32,
level_above_fuel_m in 5.0f32..12.0f32,
cooling_outlet_c in 20.0f32..45.0f32,
boron_ppm in 2000.0f32..2600.0f32,
assembly_count in 0u16..3000u16,
)| {
let val = SpentFuelPool {
pool_id, water_temp_c, level_above_fuel_m,
cooling_outlet_c, boron_ppm, assembly_count,
};
let enc = encode_to_vec(&val).expect("encode SpentFuelPool failed");
let (dec, consumed): (SpentFuelPool, usize) =
decode_from_slice(&enc).expect("decode SpentFuelPool failed");
prop_assert_eq!(&val, &dec, "SpentFuelPool roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_diesel_generator_standby_roundtrip() {
proptest!(|(
jacket_water_temp_c in 50.0f32..80.0f32,
fuel_level_frac in 0.5f32..1.0f32,
)| {
let val = DieselGeneratorState::Standby {
jacket_water_temp_c, fuel_level_frac,
};
let enc = encode_to_vec(&val).expect("encode DieselGeneratorState::Standby failed");
let (dec, consumed): (DieselGeneratorState, usize) =
decode_from_slice(&enc).expect("decode DieselGeneratorState::Standby failed");
prop_assert_eq!(&val, &dec, "DieselGeneratorState::Standby roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_diesel_generator_running_roundtrip() {
proptest!(|(
output_kw in 500.0f32..7000.0f32,
frequency_hz in 59.5f32..60.5f32,
lube_oil_pressure_kpa in 300.0f32..600.0f32,
exhaust_temp_c in 300.0f32..600.0f32,
)| {
let val = DieselGeneratorState::Running {
output_kw, frequency_hz, lube_oil_pressure_kpa, exhaust_temp_c,
};
let enc = encode_to_vec(&val).expect("encode DieselGeneratorState::Running failed");
let (dec, consumed): (DieselGeneratorState, usize) =
decode_from_slice(&enc).expect("decode DieselGeneratorState::Running failed");
prop_assert_eq!(&val, &dec, "DieselGeneratorState::Running roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_diesel_generator_failed_roundtrip() {
proptest!(|(
failure_code: u16,
)| {
let val = DieselGeneratorState::Failed { failure_code };
let enc = encode_to_vec(&val).expect("encode DieselGeneratorState::Failed failed");
let (dec, consumed): (DieselGeneratorState, usize) =
decode_from_slice(&enc).expect("decode DieselGeneratorState::Failed failed");
prop_assert_eq!(&val, &dec, "DieselGeneratorState::Failed roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_eccs_valve_position_roundtrip() {
proptest!(|(
valve_tag in "[A-Z]{2}-[0-9]{3}",
stem_position_frac in 0.0f32..1.0f32,
auto_actuated: bool,
accumulator_pressure_mpa in 0.0f32..5.0f32,
motor_current_a in 0.0f32..50.0f32,
)| {
let val = EccsValvePosition {
valve_tag, stem_position_frac, auto_actuated,
accumulator_pressure_mpa, motor_current_a,
};
let enc = encode_to_vec(&val).expect("encode EccsValvePosition failed");
let (dec, consumed): (EccsValvePosition, usize) =
decode_from_slice(&enc).expect("decode EccsValvePosition failed");
prop_assert_eq!(&val, &dec, "EccsValvePosition roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_rps_trip_all_variants_roundtrip() {
let trip_strategy = prop_oneof![
Just(RpsTrip::Normal),
(80.0f32..120.0f32).prop_map(|flux_pct| RpsTrip::HighFlux { flux_pct }),
(20.0f32..40.0f32, 25.0f32..35.0f32).prop_map(|(delta_t_c, setpoint_c)| {
RpsTrip::OverTemperatureDeltaT {
delta_t_c,
setpoint_c,
}
}),
(10.0f32..15.0f32, 12.0f32..14.0f32).prop_map(|(pressure_mpa, setpoint_mpa)| {
RpsTrip::LowPressure {
pressure_mpa,
setpoint_mpa,
}
}),
(0.5f32..1.0f32).prop_map(|level_frac| RpsTrip::HighPressuriserlevel { level_frac }),
(1u8..5u8, 50.0f32..100.0f32)
.prop_map(|(loop_id, flow_pct)| { RpsTrip::LowFlow { loop_id, flow_pct } }),
];
proptest!(|(val in trip_strategy)| {
let enc = encode_to_vec(&val).expect("encode RpsTrip failed");
let (dec, consumed): (RpsTrip, usize) =
decode_from_slice(&enc).expect("decode RpsTrip failed");
prop_assert_eq!(&val, &dec, "RpsTrip roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_boron_concentration_roundtrip() {
proptest!(|(
sample_point_id: u32,
boron_ppm in 0.0f32..2500.0f32,
sample_temp_c in 20.0f32..60.0f32,
timestamp_s: u64,
)| {
let val = BoronConcentration {
sample_point_id, boron_ppm, sample_temp_c, timestamp_s,
};
let enc = encode_to_vec(&val).expect("encode BoronConcentration failed");
let (dec, consumed): (BoronConcentration, usize) =
decode_from_slice(&enc).expect("decode BoronConcentration failed");
prop_assert_eq!(&val, &dec, "BoronConcentration roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_coolant_chemistry_roundtrip() {
proptest!(|(
sample_id: u64,
ph_25c in 6.0f32..8.0f32,
dissolved_o2_ppb in 0.0f32..100.0f32,
lithium7_ppm in 0.0f32..5.0f32,
chloride_ppb in 0.0f32..150.0f32,
conductivity_us_per_cm in 0.0f32..50.0f32,
)| {
let val = CoolantChemistry {
sample_id, ph_25c, dissolved_o2_ppb,
lithium7_ppm, chloride_ppb, conductivity_us_per_cm,
};
let enc = encode_to_vec(&val).expect("encode CoolantChemistry failed");
let (dec, consumed): (CoolantChemistry, usize) =
decode_from_slice(&enc).expect("decode CoolantChemistry failed");
prop_assert_eq!(&val, &dec, "CoolantChemistry roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_turbine_generator_snapshot_roundtrip() {
proptest!(|(
unit_id in 1u8..4u8,
speed_rpm in 1790.0f32..1810.0f32,
output_mwe in 0.0f32..1400.0f32,
main_steam_pressure_mpa in 5.0f32..7.5f32,
condenser_vacuum_kpa in 3.0f32..10.0f32,
h2_cooling_kpa in 300.0f32..450.0f32,
)| {
let val = TurbineGeneratorSnapshot {
unit_id, speed_rpm, output_mwe,
main_steam_pressure_mpa, condenser_vacuum_kpa, h2_cooling_kpa,
};
let enc = encode_to_vec(&val).expect("encode TurbineGeneratorSnapshot failed");
let (dec, consumed): (TurbineGeneratorSnapshot, usize) =
decode_from_slice(&enc).expect("decode TurbineGeneratorSnapshot failed");
prop_assert_eq!(&val, &dec, "TurbineGeneratorSnapshot roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}
#[test]
fn test_seismic_reading_roundtrip() {
proptest!(|(
station_id: u32,
pga_g in 0.0f32..2.0f32,
cav_cm_per_s in 0.0f32..100.0f32,
obe_exceeded: bool,
sse_exceeded: bool,
)| {
let val = SeismicReading {
station_id, pga_g, cav_cm_per_s, obe_exceeded, sse_exceeded,
};
let enc = encode_to_vec(&val).expect("encode SeismicReading failed");
let (dec, consumed): (SeismicReading, usize) =
decode_from_slice(&enc).expect("decode SeismicReading failed");
prop_assert_eq!(&val, &dec, "SeismicReading roundtrip mismatch");
prop_assert_eq!(consumed, enc.len(), "consumed bytes mismatch");
});
}