-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, if there was enough whitespace to fill the buffer it would return a read length of zero, even though there is still content to read.
- Loading branch information
1 parent
dda0866
commit c094548
Showing
3 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::io::Read; | ||
|
||
#[test] | ||
fn test() { | ||
const TEST: &str = " t/prau0INWoWUQ0LgQ\tMUdJRcCetBZP\nAyD+DCpn 01yWZT/LBo3Ogk0INwwuAtKNI "; | ||
|
||
let mut stripped = String::new(); | ||
super::WhitespaceRemover::new(TEST.as_bytes()) | ||
.read_to_string(&mut stripped) | ||
.unwrap(); | ||
|
||
assert_eq!( | ||
stripped, | ||
"t/prau0INWoWUQ0LgQMUdJRcCetBZPAyD+DCpn01yWZT/LBo3Ogk0INwwuAtKNI" | ||
); | ||
} | ||
|
||
#[test] | ||
fn long_whitespace() { | ||
let mut test_string = "a".to_owned(); | ||
test_string.reserve_exact(161); | ||
for _ in 0..20 { | ||
test_string.push_str(" "); | ||
} | ||
test_string.push('b'); | ||
|
||
let mut stripped = String::new(); | ||
super::WhitespaceRemover::new(test_string.as_bytes()) | ||
.read_to_string(&mut stripped) | ||
.unwrap(); | ||
|
||
assert_eq!(stripped, "ab"); | ||
} |