]> git.proxmox.com Git - rustc.git/blob - vendor/backtrace/tests/long_fn_name.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / vendor / backtrace / tests / long_fn_name.rs
1 use backtrace::Backtrace;
2
3 // 50-character module name
4 mod _234567890_234567890_234567890_234567890_234567890 {
5 // 50-character struct name
6 #[allow(non_camel_case_types)]
7 pub struct _234567890_234567890_234567890_234567890_234567890<T>(T);
8 impl<T> _234567890_234567890_234567890_234567890_234567890<T> {
9 #[allow(dead_code)]
10 pub fn new() -> crate::Backtrace {
11 crate::Backtrace::new()
12 }
13 }
14 }
15
16 // Long function names must be truncated to (MAX_SYM_NAME - 1) characters.
17 // Only run this test for msvc, since gnu prints "<no info>" for all frames.
18 #[test]
19 #[cfg(all(windows, target_env = "msvc"))]
20 fn test_long_fn_name() {
21 use _234567890_234567890_234567890_234567890_234567890::_234567890_234567890_234567890_234567890_234567890 as S;
22
23 // 10 repetitions of struct name, so fully qualified function name is
24 // atleast 10 * (50 + 50) * 2 = 2000 characters long.
25 // It's actually longer since it also includes `::`, `<>` and the
26 // name of the current module
27 let bt = S::<S<S<S<S<S<S<S<S<S<i32>>>>>>>>>>::new();
28 println!("{:?}", bt);
29
30 let mut found_long_name_frame = false;
31
32 for frame in bt.frames() {
33 let symbols = frame.symbols();
34 if symbols.is_empty() {
35 continue;
36 }
37
38 if let Some(function_name) = symbols[0].name() {
39 let function_name = function_name.as_str().unwrap();
40 if function_name.contains("::_234567890_234567890_234567890_234567890_234567890") {
41 found_long_name_frame = true;
42 assert!(function_name.len() > 200);
43 }
44 }
45 }
46
47 assert!(found_long_name_frame);
48 }