()
| 335 | |
| 336 | #[test] |
| 337 | fn decode_grouped_response() { |
| 338 | // Build a response: [{device_id: "pump-1", avg_temperature: 95.5}] |
| 339 | let row = rmpv::Value::Map(vec![ |
| 340 | ( |
| 341 | rmpv::Value::String("device_id".into()), |
| 342 | rmpv::Value::String("pump-1".into()), |
| 343 | ), |
| 344 | ( |
| 345 | rmpv::Value::String("avg_temperature".into()), |
| 346 | rmpv::Value::F64(95.5), |
| 347 | ), |
| 348 | ]); |
| 349 | let array = rmpv::Value::Array(vec![row]); |
| 350 | let mut buf = Vec::new(); |
| 351 | rmpv::encode::write_value(&mut buf, &array).unwrap(); |
| 352 | |
| 353 | let results = decode_aggregate_response(&buf, &["device_id".to_string()], "avg").unwrap(); |
| 354 | assert_eq!(results.len(), 1); |
| 355 | assert_eq!(results[0].0, "pump-1"); |
| 356 | assert!((results[0].1 - 95.5).abs() < 1e-12); |
| 357 | } |
| 358 | |
| 359 | #[test] |
| 360 | fn decode_no_group_response() { |
nothing calls this directly
no test coverage detected