Index: util/mach/mach_message_util_test.cc |
diff --git a/util/mach/mach_message_util_test.cc b/util/mach/mach_message_util_test.cc |
index b8ecbbd741fd0c19883a948dca693123d4731624..66543067b407b1771b220d51d88a8e83fde0ba15 100644 |
--- a/util/mach/mach_message_util_test.cc |
+++ b/util/mach/mach_message_util_test.cc |
@@ -63,6 +63,29 @@ TEST(MachMessageUtil, PrepareMIGReplyFromRequest_SetMIGReplyError) { |
EXPECT_EQ(MIG_BAD_ID, reply.RetCode); |
} |
+TEST(MachMessageUtil, MachMessageTrailerFromHeader) { |
+ mach_msg_empty_t empty; |
+ empty.send.header.msgh_size = sizeof(mach_msg_empty_send_t); |
+ EXPECT_EQ(&empty.rcv.trailer, |
+ MachMessageTrailerFromHeader(&empty.rcv.header)); |
+ |
+ struct TestSendMessage : public mach_msg_header_t { |
+ uint8_t data[126]; |
+ }; |
+ struct TestReceiveMessage : public TestSendMessage { |
+ mach_msg_trailer_t trailer; |
+ }; |
+ union TestMessage { |
+ TestSendMessage send; |
+ TestReceiveMessage receive; |
+ }; |
+ |
+ TestMessage test; |
+ test.send.msgh_size = sizeof(TestSendMessage); |
+ EXPECT_EQ(&test.receive.trailer, |
+ MachMessageTrailerFromHeader(&test.receive)); |
+} |
+ |
} // namespace |
} // namespace test |
} // namespace crashpad |