From b0caaff8c8c265aa60c5d391fbc6e20be98bd5ad Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sat, 13 Dec 2025 11:20:57 +0100 Subject: [PATCH] Add binary test and example data --- tests/binary_integration_test.rs | 39 +++++++++++++++++++++++++++++++ tests/data/B032361A.BIN | Bin 0 -> 102 bytes tests/data/B032361B.BIN | Bin 0 -> 10244 bytes tests/data/B032361C.BIN | Bin 0 -> 10244 bytes 4 files changed, 39 insertions(+) create mode 100644 tests/binary_integration_test.rs create mode 100644 tests/data/B032361A.BIN create mode 100644 tests/data/B032361B.BIN create mode 100644 tests/data/B032361C.BIN diff --git a/tests/binary_integration_test.rs b/tests/binary_integration_test.rs new file mode 100644 index 0000000..3c21805 --- /dev/null +++ b/tests/binary_integration_test.rs @@ -0,0 +1,39 @@ +use std::process::Command; +use std::path::Path; + +fn binary_name() -> String { + if cfg!(windows) { + "EnergyLogger4000-Reader.exe".into() + } else { + "EnergyLogger4000-Reader".into() + } +} + +#[test] +fn test_info_file() { + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + + let binary_path = Path::new(manifest_dir) + .join("target") + .join("debug") + .join(binary_name()); + + let info_test_file = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests") + .join("data") + .join("B032361A.BIN"); + + let output = Command::new(binary_path) + .current_dir(manifest_dir) + .arg("-f") + .arg(info_test_file) + .output() + .expect("failed to run binary"); + + assert!(output.status.success(), "Binary exited with {:?}\nstderr:\n{}", output.status.code(), String::from_utf8_lossy(&output.stderr)); + + // Checkoutput info file + let expected_output = "----- FINAL RESULT -----\n--- INFO ---\nUnit ID: 1\nTimestamp: 2025-12-11 17:34:00\nTarif 1: 0.35000000000000003\nTarif 2: 0.25\nTotal power comsumption: 0.045 kWh\nTotal recorded time 2269.98 h\nTotal on time 297.16 h\n- Day: 1\n-- Total kWh today min: 0.009 kWh\n-- Total recorded time today min: 7.4 h\n-- Total on time today min: 0.85 h\n- Day: 2\n-- Total kWh today min: 0.013 kWh\n-- Total recorded time today min: 2.15 h\n-- Total on time today min: 1.71 h\n- Day: 3\n-- Total kWh today min: 0.022 kWh\n-- Total recorded time today min: 6.45 h\n-- Total on time today min: 2.46 h\n- Day: 4\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n- Day: 5\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n- Day: 6\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n- Day: 7\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n- Day: 8\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n- Day: 9\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n- Day: 10\n-- Total kWh today min: 0 kWh\n-- Total recorded time today min: 0 h\n-- Total on time today min: 0 h\n"; + let actual_output = String::from_utf8_lossy(&output.stdout); + assert_eq!(actual_output, expected_output, "Unexpected output:\n{}", actual_output); +} diff --git a/tests/data/B032361A.BIN b/tests/data/B032361A.BIN new file mode 100644 index 0000000000000000000000000000000000000000..aa39a56308f9a862c5ee95f942e57480ead46f01 GIT binary patch literal 102 zcmebDbMv=iV9;eQ+s05L!oa}Ez`)DEAjW_VFg;)D7hP;6f z5s{;c!kvnp;|WxY=*I{0(ZoyS`22Y&;#ECi5Qy= zmeT_}%xToVX7BPPdzVkZXB=_V5l-7a)c&5sbIt!a*z*}5G3Wz2zlU-(?H$6mKo{3` zD<9deyx(?C6V?G*ZC`w+N>6}foys?Gm@TdOLhj!PFb<3XqeU?!SjD-=7r>yXf7hYU zH5=%Y19CtP$N@PZ2jqYpkOOi+4#)vHAP3}t9FPNYKn}K@d$%tD literal 0 HcmV?d00001 diff --git a/tests/data/B032361C.BIN b/tests/data/B032361C.BIN new file mode 100644 index 0000000000000000000000000000000000000000..a6738bae6a73862252ef8c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