Skip to content

Commit

Permalink
Add new ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Feb 9, 2024
1 parent 88d6e9f commit 9e1b2d9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::path::{Path, PathBuf};
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: usize = 1819;
const ROOT_ENTRY_LIMIT: usize = 871;
const ROOT_ENTRY_LIMIT: usize = 872;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/precondition-checks/misaligned-slice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-fail
// compile-flags: -Copt-level=3 -Cdebug-assertions=yes
// error-pattern: unsafe precondition(s) violated: slice::from_raw_parts
// ignore-debug
// ignore-wasm32-bare no panic messages

fn main() {
unsafe {
let _s: &[u64] = std::slice::from_raw_parts(1usize as *const u64, 0);
}
}
11 changes: 11 additions & 0 deletions tests/ui/precondition-checks/null-slice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-fail
// compile-flags: -Copt-level=3 -Cdebug-assertions=yes
// error-pattern: unsafe precondition(s) violated: slice::from_raw_parts
// ignore-debug
// ignore-wasm32-bare no panic messages

fn main() {
unsafe {
let _s: &[u8] = std::slice::from_raw_parts(std::ptr::null(), 0);
}
}
12 changes: 12 additions & 0 deletions tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// run-fail
// compile-flags: -Copt-level=3 -Cdebug-assertions=yes
// error-pattern: unsafe precondition(s) violated: hint::assert_unchecked
// ignore-debug
// ignore-wasm32-bare no panic messages

fn main() {
unsafe {
let sli: &[u8] = &[0];
sli.get_unchecked(1);
}
}

0 comments on commit 9e1b2d9

Please sign in to comment.