Skip to content

Commit 4b808eb

Browse files
committed
Add tests for erroneous searches and out of bounds indexing
1 parent ebd20d2 commit 4b808eb

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/testsuite/install.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,3 +3068,49 @@ For more information, try '--help'.
30683068
"#]])
30693069
.run();
30703070
}
3071+
3072+
#[cargo_test]
3073+
fn emoji_name() {
3074+
pkg("foo", "0.0.1");
3075+
cargo_process("install 🦀")
3076+
.with_status(101)
3077+
.with_stdout_data("")
3078+
.with_stderr_data(str![[r#"
3079+
3080+
thread 'main' (939065) panicked at crates/cargo-util/src/registry.rs:24:44:
3081+
byte index 2 is not a char boundary; it is inside '🦀' (bytes 0..4) of `🦀`
3082+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3083+
3084+
"#]])
3085+
.run();
3086+
}
3087+
3088+
#[cargo_test]
3089+
fn starts_with_number_case() {
3090+
pkg("foo", "0.0.1");
3091+
cargo_process("install 23898932983")
3092+
.with_status(101)
3093+
.with_stdout_data("")
3094+
.with_stderr_data(str![[r#"
3095+
[UPDATING] `dummy-registry` index
3096+
[ERROR] could not find `23898932983` in registry `crates-io` with version `*`
3097+
3098+
"#]])
3099+
.run();
3100+
}
3101+
3102+
#[cargo_test]
3103+
fn mistaken_flag_case() {
3104+
pkg("foo", "0.0.1");
3105+
cargo_process("install ––path .") // en dashes
3106+
.with_status(101)
3107+
.with_stdout_data("")
3108+
.with_stderr_data(str![[r#"
3109+
3110+
thread 'main' (939643) panicked at crates/cargo-util/src/registry.rs:24:44:
3111+
byte index 2 is not a char boundary; it is inside '–' (bytes 0..3) of `––path`
3112+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3113+
3114+
"#]])
3115+
.run();
3116+
}

0 commit comments

Comments
 (0)