Skip to content

Commit f6be7ec

Browse files
committed
improve test case
1 parent 6063bc0 commit f6be7ec

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/commands.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,22 +2162,15 @@ pub mod tests {
21622162

21632163
#[test]
21642164
fn test_build_version_command() {
2165-
if let (
2166-
LoadCommand::BuildVersion(BuildVersion {
2167-
platform,
2168-
minos,
2169-
sdk,
2170-
build_tools,
2171-
}),
2172-
cmdsize,
2173-
) = parse_command!(LC_BUILD_VERSION)
2174-
{
2165+
let (cmd, cmdsize) = parse_command!(LC_BUILD_VERSION);
2166+
2167+
if let LoadCommand::BuildVersion(ref version) = cmd {
21752168
assert_eq!(cmdsize, 32);
2176-
assert_eq!(platform, 8);
2177-
assert_eq!(minos.to_string(), "12.0");
2178-
assert_eq!(sdk.to_string(), "12.0");
2169+
assert_eq!(version.platform(), Platform::Other(8));
2170+
assert_eq!(version.minos.to_string(), "12.0");
2171+
assert_eq!(version.sdk.to_string(), "12.0");
21792172
assert_eq!(
2180-
build_tools,
2173+
version.build_tools,
21812174
vec![BuildTool {
21822175
tool: 3,
21832176
version: "409.10.0".parse().unwrap()
@@ -2186,5 +2179,17 @@ pub mod tests {
21862179
} else {
21872180
panic!()
21882181
}
2182+
2183+
assert_eq!(
2184+
MachCommand(cmd, cmdsize).to_string(),
2185+
" cmd LC_BUILD_VERSION
2186+
cmdsize 32
2187+
platform Other(8)
2188+
minos 12.0
2189+
sdk 12.0
2190+
tools
2191+
LD 409.10
2192+
"
2193+
);
21892194
}
21902195
}

src/testdata.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,11 @@ const LC_RPATH_DATA: [u8; 0x40] = [
537537
Load command 50
538538
cmd LC_BUILD_VERSION
539539
cmdsize 32
540+
platform Other(8)
541+
minos 12.0
542+
sdk 12.0
543+
tools
544+
LD 409.10
540545
**/
541546
const LC_BUILD_VERSION: [u8; 0x20] = [
542547
0x32, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x0C,

0 commit comments

Comments
 (0)