File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 5
5
class MachOOpenTest < Minitest ::Test
6
6
include Helpers
7
7
8
+ def test_nonexistent_file
9
+ assert_raises ArgumentError do
10
+ MachO . open ( "/this/is/a/file/that/cannot/possibly/exist" )
11
+ end
12
+ end
13
+
14
+ # MachO.open has slightly looser qualifications for truncation than
15
+ # either MachOFile.new or FatFile.new - it just makes sure that there are
16
+ # enough magic bytes to read, and lets the actual parser raise a
17
+ # TruncationError later on if required.
18
+ def test_truncated_file
19
+ tempfile_with_data ( "truncated_file" , "\x00 \x00 " ) do |truncated_file |
20
+ assert_raises MachO ::TruncatedFileError do
21
+ MachO . open ( truncated_file . path )
22
+ end
23
+ end
24
+ end
25
+
26
+ def test_bad_magic
27
+ tempfile_with_data ( "junk_file" , "\xFF \xFF \xFF \xFF " ) do |junk_file |
28
+ assert_raises MachO ::MagicError do
29
+ MachO . open ( junk_file . path )
30
+ end
31
+ end
32
+ end
33
+
8
34
def test_open
9
35
file = MachO . open ( "test/bin/libhello.dylib" )
10
36
You can’t perform that action at this time.
0 commit comments