Debian Codegraph @

tests/test_fmt.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use anyhowrust-analyzer cargo anyhow 1.0.103 crate/::{bailrust-analyzer cargo anyhow 1.0.103 macros/bail!, Contextrust-analyzer cargo anyhow 1.0.103 Context#, Resultrust-analyzer cargo anyhow 1.0.103 Result#};
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
3
4 fn frust-analyzer cargo anyhow 1.0.103 f().() -> Resultrust-analyzer cargo anyhow 1.0.103 Result#<()> {
5 bailrust-analyzer cargo anyhow 1.0.103 macros/bail!!(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::PermissionDeniedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#PermissionDenied#, "oh no!"));
6 }
7
8 fn grust-analyzer cargo anyhow 1.0.103 g().() -> Resultrust-analyzer cargo anyhow 1.0.103 Result#<()> {
9 frust-analyzer cargo anyhow 1.0.103 f().().contextrust-analyzer cargo anyhow 1.0.103 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("f failed")
10 }
11
12 fn hrust-analyzer cargo anyhow 1.0.103 h().() -> Resultrust-analyzer cargo anyhow 1.0.103 Result#<()> {
13 grust-analyzer cargo anyhow 1.0.103 g().().contextrust-analyzer cargo anyhow 1.0.103 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("g failed")
14 }
15
16 const EXPECTED_ALTDISPLAY_Frust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDISPLAY_F.: &str = "oh no!";
17
18 const EXPECTED_ALTDISPLAY_Grust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDISPLAY_G.: &str = "f failed: oh no!";
19
20 const EXPECTED_ALTDISPLAY_Hrust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDISPLAY_H.: &str = "g failed: f failed: oh no!";
21
22 const EXPECTED_DEBUG_Frust-analyzer cargo anyhow 1.0.103 EXPECTED_DEBUG_F.: &str = "oh no!";
23
24 const EXPECTED_DEBUG_Grust-analyzer cargo anyhow 1.0.103 EXPECTED_DEBUG_G.: &str = "\
25 f failed
26
27 Caused by:
28 oh no!\
29 ";
30
31 const EXPECTED_DEBUG_Hrust-analyzer cargo anyhow 1.0.103 EXPECTED_DEBUG_H.: &str = "\
32 g failed
33
34 Caused by:
35 0: f failed
36 1: oh no!\
37 ";
38
39 const EXPECTED_ALTDEBUG_Frust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDEBUG_F.: &str = "\
40 Custom {
41 kind: PermissionDenied,
42 error: \"oh no!\",
43 }\
44 ";
45
46 const EXPECTED_ALTDEBUG_Grust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDEBUG_G.: &str = "\
47 Error {
48 context: \"f failed\",
49 source: Custom {
50 kind: PermissionDenied,
51 error: \"oh no!\",
52 },
53 }\
54 ";
55
56 const EXPECTED_ALTDEBUG_Hrust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDEBUG_H.: &str = "\
57 Error {
58 context: \"g failed\",
59 source: Error {
60 context: \"f failed\",
61 source: Custom {
62 kind: PermissionDenied,
63 error: \"oh no!\",
64 },
65 },
66 }\
67 ";
68
69 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
70 fn test_displayrust-analyzer cargo anyhow 1.0.103 test_display().() {
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("g failed", hrust-analyzer cargo anyhow 1.0.103 h().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
72 }
73
74 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
75 fn test_altdisplayrust-analyzer cargo anyhow 1.0.103 test_altdisplay().() {
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXPECTED_ALTDISPLAY_Frust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDISPLAY_F., formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#}", frust-analyzer cargo anyhow 1.0.103 f().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()));
77 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXPECTED_ALTDISPLAY_Grust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDISPLAY_G., formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#}", grust-analyzer cargo anyhow 1.0.103 g().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()));
78 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXPECTED_ALTDISPLAY_Hrust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDISPLAY_H., formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#}", hrust-analyzer cargo anyhow 1.0.103 h().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()));
79 }
80
•81 /*#[test]
82 fn test_debug() {
83 assert_eq!(EXPECTED_DEBUG_F, format!("{:?}", f().unwrap_err()));
84 assert_eq!(EXPECTED_DEBUG_G, format!("{:?}", g().unwrap_err()));
85 assert_eq!(EXPECTED_DEBUG_H, format!("{:?}", h().unwrap_err()));
•86 }*/
87
88 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
89 fn test_altdebugrust-analyzer cargo anyhow 1.0.103 test_altdebug().() {
90 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXPECTED_ALTDEBUG_Frust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDEBUG_F., formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#?}", frust-analyzer cargo anyhow 1.0.103 f().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()));
91 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXPECTED_ALTDEBUG_Grust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDEBUG_G., formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#?}", grust-analyzer cargo anyhow 1.0.103 g().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()));
92 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXPECTED_ALTDEBUG_Hrust-analyzer cargo anyhow 1.0.103 EXPECTED_ALTDEBUG_H., formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#?}", hrust-analyzer cargo anyhow 1.0.103 h().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()));
93 }