rust/library/core/tests/panic/location.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
808 B
Rust
Raw Normal View History

2022-09-27 14:09:32 -05:00
use core::panic::Location;
// Note: Some of the following tests depend on the source location,
// so please be careful when editing this file.
#[test]
fn location_const_caller() {
2022-09-27 14:40:53 -05:00
const _CALLER_REFERENCE: &Location<'static> = Location::caller();
const _CALLER: Location<'static> = *Location::caller();
2022-09-27 14:09:32 -05:00
}
#[test]
fn location_const_file() {
2022-09-27 14:40:53 -05:00
const CALLER: &Location<'static> = Location::caller();
const FILE: &str = CALLER.file();
2022-10-08 06:48:53 -05:00
assert_eq!(FILE, file!());
2022-09-27 14:09:32 -05:00
}
#[test]
fn location_const_line() {
2022-09-27 14:40:53 -05:00
const CALLER: &Location<'static> = Location::caller();
const LINE: u32 = CALLER.line();
assert_eq!(LINE, 21);
2022-09-27 14:09:32 -05:00
}
#[test]
fn location_const_column() {
2022-09-27 14:40:53 -05:00
const CALLER: &Location<'static> = Location::caller();
const COLUMN: u32 = CALLER.column();
assert_eq!(COLUMN, 40);
2022-09-27 14:23:52 -05:00
}