/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015-2019 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
try {
const BinaryData master_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
- const std::string master_key_ascii = convertToHex(master_key);
- // the string master_key_ascii is equal to "000102030405060708090a0b0c0d0e0f" after conversion
+ std::string answer = "000102030405060708090a0b0c0d0e0f";
- BinaryData answer = {0x30, 0x30, 0x30, 0x31, 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x30, 0x37,
- 0x30, 0x38, 0x30, 0x39, 0x30, 0x61, 0x30, 0x62, 0x30, 0x63, 0x30, 0x64, 0x30, 0x65, 0x30, 0x66
- };
- // the answer is a set of hex codes of ASCII symbols in master_key_ascii string, e.g. hex(a) = 0x61
+ const std::string master_key_ascii = convertToHex(master_key);
// check
- for (unsigned int i = 0; i < master_key.size() * 2; i++) {
- if (master_key_ascii[i] != answer[i]) {
- printf("[%2d] %X != %X\n", i, master_key_ascii[i], answer[i]);
- TEST_FAIL("outcome isn't match with expected answer");
- }
- }
+ TEST_EXPECT(answer, master_key_ascii);
} catch (runtime::Exception &e) {
TEST_FAIL(e.what());
}
{
try {
const BinaryData master_key = {0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F};
- BinaryData answer = {0x46, 0x30, 0x45, 0x31, 0x44, 0x32, 0x43, 0x33, 0x42, 0x34, 0x41, 0x35, 0x39, 0x36, 0x38, 0x37,
- 0x37, 0x38, 0x36, 0x39, 0x35, 0x41, 0x34, 0x42, 0x33, 0x43, 0x32, 0x44, 0x31, 0x45, 0x30, 0x46
- };
+ std::string answer = "f0e1d2c3b4a5968778695a4b3c2d1e0f";
+
const std::string master_key_ascii = convertToHex(master_key);
// check
- for (unsigned int i = 0; i < master_key.size() * 2; i++)
- if (master_key_ascii[i] != answer[i])
- TEST_FAIL("outcome isn't match with expected answer");
+ TEST_EXPECT(answer, master_key_ascii);
} catch (runtime::Exception &e) {
TEST_FAIL(e.what());
}