From 0cc8739ddeae110620316fab5225bf6e1787dd3d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 13 Mar 2021 10:11:09 -0500 Subject: try harder to make utf8 strings when requested --- src/private.rs | 4 ++-- tests/input.rs | 52 ++++++++++++++-------------------------------------- 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/private.rs b/src/private.rs index 6bb37a9..0b5d2f2 100644 --- a/src/private.rs +++ b/src/private.rs @@ -65,9 +65,9 @@ pub trait Input { && !self.should_parse_special_keys() } 28..=31 => true, - 32..=126 => true, + 32..=126 => !self.should_parse_utf8(), 127 => !self.should_parse_special_keys(), - 128..=255 => true, + 128..=255 => !self.should_parse_utf8(), }) .collect(); if !prefix.is_empty() { diff --git a/tests/input.rs b/tests/input.rs index 79aaea7..b1607bf 100644 --- a/tests/input.rs +++ b/tests/input.rs @@ -144,44 +144,20 @@ fn run_input_test( } } else { if utf8 { - // assert_eq!( - // std::string::String::from_utf8(fixtures::read_line( - // &mut r - // )) - // .unwrap(), - // "Bytes([27]): [27]\r\n" - // ); - // assert_eq!( - // std::string::String::from_utf8(fixtures::read_line( - // &mut r - // )) - // .unwrap(), - // "String(\"[A\"): [91, 65]\r\n" - // ); - if meta { - assert_eq!( - std::string::String::from_utf8( - fixtures::read_line(&mut r) - ) - .unwrap(), - "Bytes([27]): [27]\r\n" - ); - assert_eq!( - std::string::String::from_utf8( - fixtures::read_line(&mut r) - ) - .unwrap(), - "String(\"[A\"): [91, 65]\r\n" - ); - } else { - assert_eq!( - std::string::String::from_utf8( - fixtures::read_line(&mut r) - ) - .unwrap(), - "Bytes([27, 91, 65]): [27, 91, 65]\r\n" - ); - } + assert_eq!( + std::string::String::from_utf8(fixtures::read_line( + &mut r + )) + .unwrap(), + "Bytes([27]): [27]\r\n" + ); + assert_eq!( + std::string::String::from_utf8(fixtures::read_line( + &mut r + )) + .unwrap(), + "String(\"[A\"): [91, 65]\r\n" + ); } else { if meta { assert_eq!( -- cgit v1.2.3-54-g00ecf