proto/finger: test serialization roundtrip
All checks were successful
Build and test / check (push) Successful in 1m6s
Build and test / build (push) Successful in 1m42s
Build and test / test (push) Successful in 1m53s
Build and test / docs (push) Successful in 4m57s

This commit is contained in:
2026-01-31 12:50:39 +09:00
parent 23b163e828
commit 5dc3327980

View File

@@ -105,3 +105,31 @@ impl FingerResponse {
out
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_finger_serialization_roundrip() {
let request = FingerRequest::new(true, "alice".to_string());
let bytes = request.to_bytes();
let deserialized = FingerRequest::from_bytes(&bytes);
assert_eq!(request, deserialized);
let request2 = FingerRequest::new(false, "bob".to_string());
let bytes2 = request2.to_bytes();
let deserialized2 = FingerRequest::from_bytes(&bytes2);
assert_eq!(request2, deserialized2);
let response = FingerResponse::new("Hello, World!\nThis is a test.\n".to_string());
let response_bytes = response.to_bytes();
let deserialized_response = FingerResponse::from_bytes(&response_bytes);
assert_eq!(response, deserialized_response);
let response2 = FingerResponse::new("Single line response\n".to_string());
let response_bytes2 = response2.to_bytes();
let deserialized_response2 = FingerResponse::from_bytes(&response_bytes2);
assert_eq!(response2, deserialized_response2);
}
}