File tree Expand file tree Collapse file tree 2 files changed +46
-53
lines changed Expand file tree Collapse file tree 2 files changed +46
-53
lines changed Original file line number Diff line number Diff line change @@ -85,56 +85,3 @@ impl<'a> Analyzer<'a> {
85
85
} ) ;
86
86
}
87
87
}
88
-
89
- #[ cfg( test) ]
90
- mod tests {
91
- use super :: * ;
92
- use std:: { fs, path:: PathBuf } ;
93
-
94
- fn get_test_path ( ) -> PathBuf {
95
- PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) )
96
- . join ( "target" )
97
- . join ( "debug" )
98
- . join ( env ! ( "CARGO_PKG_NAME" ) )
99
- }
100
-
101
- fn get_test_bytes ( ) -> Result < Vec < u8 > > {
102
- let debug_binary = get_test_path ( ) ;
103
- Ok ( fs:: read ( debug_binary) ?)
104
- }
105
-
106
- #[ test]
107
- fn test_init ( ) -> Result < ( ) > {
108
- Analyzer :: new (
109
- FileInfo :: new (
110
- get_test_path ( ) . to_str ( ) . expect ( "failed to get test path" ) ,
111
- get_test_bytes ( ) ?. as_slice ( ) ,
112
- ) ?,
113
- 4 ,
114
- vec ! [ ] ,
115
- )
116
- . map ( |_| ( ) )
117
- }
118
-
119
- #[ test]
120
- fn test_extract_strings ( ) -> Result < ( ) > {
121
- let test_bytes = get_test_bytes ( ) ?;
122
- let test_path = get_test_path ( ) ;
123
- let mut analyzer = Analyzer :: new (
124
- FileInfo :: new (
125
- test_path. to_str ( ) . expect ( "failed to get test path" ) ,
126
- test_bytes. as_slice ( ) ,
127
- ) ?,
128
- 4 ,
129
- vec ! [ ] ,
130
- ) ?;
131
- let ( tx, rx) = mpsc:: channel ( ) ;
132
- analyzer. extract_strings ( tx) ;
133
- if let Event :: FileStrings ( strings) = rx. recv ( ) ? {
134
- assert ! ( strings?. iter( ) . map( |( s, _) | s) . any( |v| v == ".debug_str" ) ) ;
135
- } else {
136
- panic ! ( "strings did not succeed" ) ;
137
- }
138
- Ok ( ( ) )
139
- }
140
- }
Original file line number Diff line number Diff line change
1
+ use binsider:: { app:: Analyzer , error:: Result , file:: FileInfo , prelude:: Event } ;
2
+ use std:: { fs, path:: PathBuf , sync:: mpsc} ;
3
+
4
+ fn get_test_path ( ) -> PathBuf {
5
+ PathBuf :: from ( env ! ( "CARGO_BIN_EXE_binsider" ) )
6
+ }
7
+
8
+ fn get_test_bytes ( ) -> Result < Vec < u8 > > {
9
+ let debug_binary = get_test_path ( ) ;
10
+ Ok ( fs:: read ( debug_binary) ?)
11
+ }
12
+
13
+ #[ test]
14
+ fn test_init ( ) -> Result < ( ) > {
15
+ Analyzer :: new (
16
+ FileInfo :: new (
17
+ get_test_path ( ) . to_str ( ) . expect ( "failed to get test path" ) ,
18
+ get_test_bytes ( ) ?. as_slice ( ) ,
19
+ ) ?,
20
+ 4 ,
21
+ vec ! [ ] ,
22
+ )
23
+ . map ( |_| ( ) )
24
+ }
25
+
26
+ #[ test]
27
+ fn test_extract_strings ( ) -> Result < ( ) > {
28
+ let test_bytes = get_test_bytes ( ) ?;
29
+ let test_path = get_test_path ( ) ;
30
+ let mut analyzer = Analyzer :: new (
31
+ FileInfo :: new (
32
+ test_path. to_str ( ) . expect ( "failed to get test path" ) ,
33
+ test_bytes. as_slice ( ) ,
34
+ ) ?,
35
+ 4 ,
36
+ vec ! [ ] ,
37
+ ) ?;
38
+ let ( tx, rx) = mpsc:: channel ( ) ;
39
+ analyzer. extract_strings ( tx) ;
40
+ if let Event :: FileStrings ( strings) = rx. recv ( ) ? {
41
+ assert ! ( strings?. iter( ) . map( |( s, _) | s) . any( |v| v == ".debug_str" ) ) ;
42
+ } else {
43
+ panic ! ( "strings did not succeed" ) ;
44
+ }
45
+ Ok ( ( ) )
46
+ }
You can’t perform that action at this time.
0 commit comments