From patchwork Wed Feb 6 18:33:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [for-1.4?, v2, 3/5] tmp105-test: Combine assertions of 16-bit responses From: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 218719 Message-Id: <1360175610-8992-4-git-send-email-afaerber@suse.de> To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Date: Wed, 6 Feb 2013 19:33:28 +0100 From: Andreas Färber Instead of comparing bytes individually, compare the full values. This aids spotting endianness issues. Signed-off-by: Andreas Färber --- tests/tmp105-test.c | 8 ++++---- 1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-) diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index a6ad213..a1fe99e 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -40,16 +40,16 @@ static void send_and_receive(void) cmd[2] = 0x34; i2c_send(i2c, addr, cmd, 3); i2c_recv(i2c, addr, resp, 2); - g_assert_cmphex(resp[0], ==, cmd[1]); - g_assert_cmphex(resp[1], ==, cmd[2]); + g_assert_cmphex(((uint16_t)resp[0] << 8) | resp[1], ==, + ((uint16_t)cmd[1] << 8) | cmd[2]); cmd[0] = TMP105_REG_T_HIGH; cmd[1] = 0x42; cmd[2] = 0x31; i2c_send(i2c, addr, cmd, 3); i2c_recv(i2c, addr, resp, 2); - g_assert_cmphex(resp[0], ==, cmd[1]); - g_assert_cmphex(resp[1], ==, cmd[2]); + g_assert_cmphex(((uint16_t)resp[0] << 8) | resp[1], ==, + ((uint16_t)cmd[1] << 8) | cmd[2]); } int main(int argc, char **argv)