Skip to content

Commit b6c6331

Browse files
committed
test: Add tests for MachO::FatFile.new_from_machos.
1 parent a62178f commit b6c6331

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/test_fat.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,35 @@ def test_extract_macho
247247
end
248248
end
249249

250+
def test_new_from_machos
251+
filenames = SINGLE_ARCHES.map { |a| fixture(a, "hello.bin") }
252+
machos = filenames.map { |f| MachO::MachOFile.new(f) }
253+
254+
file = MachO::FatFile.new_from_machos(*machos)
255+
256+
assert file
257+
assert_instance_of MachO::FatFile, file
258+
259+
# the number of machos inside the new fat file should be the number
260+
# of individual machos we gave it
261+
assert machos.size, file.machos.size
262+
263+
# the order of machos within the fat file should be preserved
264+
machos.each_with_index do |macho, i|
265+
assert_equal macho.cputype, file.machos[i].cputype
266+
end
267+
268+
# we should be able to dump the newly created fat file
269+
file.write("merged_machos.bin")
270+
271+
# ...and load it back as a new object without errors
272+
file = MachO::FatFile.new("merged_machos.bin")
273+
274+
assert file
275+
ensure
276+
delete_if_exists("merged_machos.bin")
277+
end
278+
250279
def test_change_dylib_id
251280
groups = FAT_ARCH_PAIRS.map do |arch|
252281
["libhello.dylib", "libhello_actual.dylib", "libhello_expected.dylib"].map do |fn|

0 commit comments

Comments
 (0)