focus/crates/focus-transport/tests/transport_tests.rs

27 lines
824 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! transport 模块chunked 解码)的集成测试。
//! Integration tests for the transport module (chunked decoding).
use focus_transport::transport::decode_chunked;
#[test]
fn decodes_simple_chunked_body() {
// 两个分块:"Hello" 与 " World",随后是终止分块。
// Two chunks: "Hello" and " World", then terminating chunk.
let body = b"5\r\nHello\r\n6\r\n World\r\n0\r\n\r\n";
let decoded = decode_chunked(body).unwrap();
assert_eq!(decoded, b"Hello World");
}
#[test]
fn decodes_chunk_with_extension() {
let body = b"5;name=value\r\nHello\r\n0\r\n\r\n";
let decoded = decode_chunked(body).unwrap();
assert_eq!(decoded, b"Hello");
}
#[test]
fn decodes_single_chunk() {
let body = b"3\r\nabc\r\n0\r\n\r\n";
assert_eq!(decode_chunked(body).unwrap(), b"abc");
}