add test cases for u32, f32, bool, String
This commit is contained in:
parent
8fad54e8f9
commit
85f535b25f
@ -16,4 +16,21 @@ fn main() {
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.trim_end().parse::<i32>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.trim_end().parse::<u32>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.trim_end().parse::<f32>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.trim_end().parse::<bool>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
// this is actually ok, so don't lint here
|
||||
let _x = input.parse::<String>().unwrap();
|
||||
}
|
||||
|
@ -16,4 +16,21 @@ fn main() {
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.parse::<i32>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.parse::<u32>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.parse::<f32>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
let _x = input.parse::<bool>().unwrap();
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
// this is actually ok, so don't lint here
|
||||
let _x = input.parse::<String>().unwrap();
|
||||
}
|
||||
|
@ -27,5 +27,47 @@ note: call to `.read_line()` here, which leaves a trailing newline character in
|
||||
LL | std::io::stdin().read_line(&mut input).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: calling `.parse()` without trimming the trailing newline character
|
||||
--> $DIR/read_line_without_trim.rs:22:20
|
||||
|
|
||||
LL | let _x = input.parse::<u32>().unwrap();
|
||||
| ----- ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: try: `input.trim_end()`
|
||||
|
|
||||
note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail
|
||||
--> $DIR/read_line_without_trim.rs:21:5
|
||||
|
|
||||
LL | std::io::stdin().read_line(&mut input).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: calling `.parse()` without trimming the trailing newline character
|
||||
--> $DIR/read_line_without_trim.rs:26:20
|
||||
|
|
||||
LL | let _x = input.parse::<f32>().unwrap();
|
||||
| ----- ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: try: `input.trim_end()`
|
||||
|
|
||||
note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail
|
||||
--> $DIR/read_line_without_trim.rs:25:5
|
||||
|
|
||||
LL | std::io::stdin().read_line(&mut input).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: calling `.parse()` without trimming the trailing newline character
|
||||
--> $DIR/read_line_without_trim.rs:30:20
|
||||
|
|
||||
LL | let _x = input.parse::<bool>().unwrap();
|
||||
| ----- ^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: try: `input.trim_end()`
|
||||
|
|
||||
note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail
|
||||
--> $DIR/read_line_without_trim.rs:29:5
|
||||
|
|
||||
LL | std::io::stdin().read_line(&mut input).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user