mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
test(test_util/lsp): add tests for invalid content-length (#12971)
This commit is contained in:
parent
b5fdfb9d25
commit
9825c876b4
1 changed files with 15 additions and 3 deletions
|
@ -337,8 +337,20 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_read_message() {
|
||||
let msg = b"content-length: 11\r\n\r\nhello world";
|
||||
let mut reader = std::io::Cursor::new(msg);
|
||||
assert_eq!(read_message(&mut reader).unwrap(), b"hello world");
|
||||
let msg1 = b"content-length: 11\r\n\r\nhello world";
|
||||
let mut reader1 = std::io::Cursor::new(msg1);
|
||||
assert_eq!(read_message(&mut reader1).unwrap(), b"hello world");
|
||||
|
||||
let msg2 = b"content-length: 5\r\n\r\nhello world";
|
||||
let mut reader2 = std::io::Cursor::new(msg2);
|
||||
assert_eq!(read_message(&mut reader2).unwrap(), b"hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "failed to fill whole buffer")]
|
||||
fn test_invalid_read_message() {
|
||||
let msg1 = b"content-length: 12\r\n\r\nhello world";
|
||||
let mut reader1 = std::io::Cursor::new(msg1);
|
||||
read_message(&mut reader1).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue