本文整理汇总了C++中TEST_ASSERT_EQUAL_STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_ASSERT_EQUAL_STRING函数的具体用法?C++ TEST_ASSERT_EQUAL_STRING怎么用?C++ TEST_ASSERT_EQUAL_STRING使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_ASSERT_EQUAL_STRING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(utilities, IPv6Address) {
const struct in6_addr address = {{{
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
}}};
const char *expected = "2001:db8:85a3:8d3:1319:8a2e:370:7334";
sockaddr_u input;
struct addrinfo inputA;
memset(&input, 0, sizeof(input));
input.sa6.sin6_family = AF_INET6;
input.sa6.sin6_addr = address;
/* coverity[leaked_storage] */
TEST_ASSERT_EQUAL_STRING(expected, ss_to_str(&input));
inputA = CreateAddrinfo(&input);
/* coverity[leaked_storage] */
TEST_ASSERT_EQUAL_STRING(expected, addrinfo_to_str(&inputA));
}
示例2: test_ipv6_addr_to_str__success2
static void test_ipv6_addr_to_str__success2(void)
{
ng_ipv6_addr_t a = { {
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
}
};
char result[NG_IPV6_ADDR_MAX_STR_LEN];
TEST_ASSERT_EQUAL_STRING("fe80::f8f9:fafb:fcfd:feff",
ng_ipv6_addr_to_str(result, &a, sizeof(result)));
}
示例3: test_Finding_Element_if_Key_not_Found_in_the_Simple_JSON_List_Should_Throw_Error
/************************************************************************************************************
* The JsonList for the findElement Function to test are as shown below, *
* *
* { *
* "NAME1":"JS", *
* "NAME2":20, *
* "NAME3":"STEVEN", *
* } *
* *
* -Test to find the 'Key'="AGE". *
* *
************************************************************************************************************/
void test_Finding_Element_if_Key_not_Found_in_the_Simple_JSON_List_Should_Throw_Error()
{
printf("JSON list Finding Element test No.1\n");
JsonObject *jsonObj;
Token *jsonTok;
ListElement *findKey;
Token *findVal;
ErrorObject *err;
TOKEN_DECLARE;
getToken_ExpectAndReturn(openBrace0); //"{"
getToken_ExpectAndReturn(NAME1); //"NAME1"
getToken_ExpectAndReturn(colon0); //":"
getToken_ExpectAndReturn(JS); //"JS"
getToken_ExpectAndReturn(coma0); //","
getToken_ExpectAndReturn(NAME2); //"NAME2"
getToken_ExpectAndReturn(colon1); //":"
getToken_ExpectAndReturn(int20); //20
getToken_ExpectAndReturn(coma1); //","
getToken_ExpectAndReturn(NAME3); //"NAME3"
getToken_ExpectAndReturn(colon2); //":"
getToken_ExpectAndReturn(STEVEN); //"STEVEN"
getToken_ExpectAndReturn(closeBrace0); //"}"
getToken_ExpectAndReturn(dollarSign);
jsonObj=createJsonObject();
Try{
jsonTok=jsonParse(jsonObj);
}Catch(err){
TEST_FAIL_JSON("unexpected error occurred =>'%s'",err->errorMsg);
free(err);
}
TEST_ASSERT_EQUAL(END,jsonObj->state);
Try{
findKey=keyFind(((JsonToken *)jsonTok)->list, "AGE", strCompare);
TEST_FAIL_MESSAGE("Expecting ERR_KEY_NOT_FOUND to be thrown, but none thrown.");
}Catch(err){
TEST_ASSERT_EQUAL_STRING("ERROR[14]:Key not Found.Finding 'Key'=>'AGE'.",err->errorMsg);
TEST_ASSERT_EQUAL(ERR_KEY_NOT_FOUND,err->errorCode);
free(err);
}
free(jsonObj);
free(jsonTok);
free(findKey);
free(findVal);
TOKEN_FREE;
printf("\n\n");
}
示例4: test_requestbuilder_BuildsWithHeaders
void test_requestbuilder_BuildsWithHeaders(void)
{
builder.putHeader("Host", "www.example.com");
builder.putHeader("Content-Type", "text/html");
builder.putHeader("Some-Other-Header", "Some-Other-Value");
builder.writeToBuffer(requestBuffer, 512);
TEST_ASSERT_EQUAL_STRING(
"GET / HTTP/1.1\r\n"
"Host: www.example.com\r\n"
"Content-Type: text/html\r\n"
"Some-Other-Header: Some-Other-Value\r\n", requestBuffer);
}
示例5: test_ipv6_addr_to_str__success
static void test_ipv6_addr_to_str__success(void)
{
ng_ipv6_addr_t a = { {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
}
};
char result[NG_IPV6_ADDR_MAX_STR_LEN];
TEST_ASSERT_EQUAL_STRING("1:203:405:607:809:a0b:c0d:e0f",
ng_ipv6_addr_to_str(result, &a, sizeof(result)));
}
示例6: test_GetEmptyCookieF
void test_GetEmptyCookieF()
{
char* cookiestra = "NYT_W2=IndianapolisINUS";
const char* cookiename = "NYT_W2";
const char* expected="IndianapolisINUS";
char* actual = get_weather_code_from_cookie(cookiestra, cookiename);
printf("I have:%s:\n", actual);
TEST_ASSERT_EQUAL_STRING(expected, actual);
}
示例7: test_pktbuf_merge_data__success2
static void test_pktbuf_merge_data__success2(void)
{
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, TEST_STRING4,
sizeof(TEST_STRING4),
GNRC_NETTYPE_TEST);
pkt = gnrc_pktbuf_add(pkt, TEST_STRING8, sizeof(TEST_STRING8), GNRC_NETTYPE_TEST);
pkt = gnrc_pktbuf_add(pkt, TEST_STRING16, sizeof(TEST_STRING16), GNRC_NETTYPE_TEST);
TEST_ASSERT_EQUAL_INT(0, gnrc_pktbuf_merge(pkt));
TEST_ASSERT_NULL(pkt->next);
TEST_ASSERT_EQUAL_STRING(TEST_STRING16, pkt->data);
TEST_ASSERT_EQUAL_STRING(TEST_STRING8,
(char *) pkt->data + sizeof(TEST_STRING16));
TEST_ASSERT_EQUAL_STRING(TEST_STRING4,
(char *) pkt->data + sizeof(TEST_STRING16) +
sizeof(TEST_STRING8));
gnrc_pktbuf_release(pkt);
TEST_ASSERT(gnrc_pktbuf_is_empty());
TEST_ASSERT(gnrc_pktbuf_is_sane());
}
示例8: test_labels
void test_labels(void) {
init_hash_table();
Instruction* i = new_instruction_label("test", 1);
TEST_ASSERT_EQUAL_STRING("test", i->opcode);
TEST_ASSERT(i->type = I_TYPE_LABEL);
set_label_address("test", 34);
Address* a = addr_from_label(strdup("test"));
resolve_address(a);
TEST_ASSERT_EQUAL_INT_MESSAGE(34, a->immediate, "Incorrect label address");
free(a);
free(i);
}
示例9: test_ONFI_ReadParameterPage_ShouldRead_ONFI
void test_ONFI_ReadParameterPage_ShouldRead_ONFI(void)
{
static const int8_t expected[] = "ONFI";
uint8_t buff[5];
buff[4] = 0;
ONFI_ReadParameterPage(0);
ONFI_receive8(buff, 4);
TEST_ASSERT_EQUAL_STRING(expected, buff);
}
示例10: test_requestbuilder_BuildsWithContentLengthHeader
void test_requestbuilder_BuildsWithContentLengthHeader(void)
{
builder.writeToBuffer(requestBuffer, 512, true);
TEST_ASSERT_EQUAL_STRING(
"GET / HTTP/1.1\r\n"
"Host: www.example.com\r\n"
"Content-Type: text/html\r\n"
"Some-Other-Header: Some-Other-Value\r\n"
"Content-Length: 30\r\n"
"\r\n"
"This is some data in the body.\r\n", requestBuffer);
}
示例11: test_ipv6_addr_to_str__success5
static void test_ipv6_addr_to_str__success5(void)
{
ng_ipv6_addr_t a = { {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 192, 168, 0, 1
}
};
char result[NG_IPV6_ADDR_MAX_STR_LEN];
TEST_ASSERT_EQUAL_STRING("::ffff:192.168.0.1",
ng_ipv6_addr_to_str(result, &a, sizeof(result)));
}
示例12: test_fmt_lpad
static void test_fmt_lpad(void)
{
const char base[] = "abcd";
char string[9] = {0};
strcpy(string, base);
fmt_lpad(string, 4, 8, ' ');
TEST_ASSERT_EQUAL_STRING(" abcd", (char*)string);
fmt_lpad(string, 0, 0, '1');
TEST_ASSERT_EQUAL_STRING(" abcd", (char*)string);
fmt_lpad(string, 4, 0, '2');
TEST_ASSERT_EQUAL_STRING(" abcd", (char*)string);
fmt_lpad(string, 0, 4, '3');
TEST_ASSERT_EQUAL_STRING("3333abcd", (char*)string);
fmt_lpad(string, 8, 8, '4');
TEST_ASSERT_EQUAL_STRING("3333abcd", (char*)string);
fmt_lpad(string, 4, 8, 'x');
TEST_ASSERT_EQUAL_STRING((char*)string, "xxxx3333");
}
示例13: test_getSection
void test_getSection(void)
{
char* content = " echo \"\
[TcpClient] \n\
LogicName = tcpClient1 \n\
DestIp = 127.0.0.1 \n\
DestPort = 1111 \n\
LocalPort = 8888 \n\
\n\
[TcpClient] \n\
LogicName = tcpClient2 \n\
DestIp = 127.0.0.1 \n\
DestPort = 2222 \n\
LocalPort = 9999 \n\
\n\
[TcpClient] \n\
LogicName = tcpClient3 \n\
DestIp = 127.0.0.1 \n\
DestPort = 3333 \n\
LocalPort = 1234 \n\" > commModule.conf";
system(content);
char section[MAX_LEN_SECTION] = {0};
int ret = getSection("./commModule.conf", 0, "TcpClient", section);
TEST_ASSERT_EQUAL_INT(3, ret);
memset(section, 0, MAX_LEN_SECTION);
ret = getSection("./commModule.conf", 1, "TcpClient", section);
TEST_ASSERT_EQUAL_INT(TOOLS_SUCCESS, ret);
TEST_ASSERT_EQUAL_STRING("[TcpClient] \nLogicName = tcpClient1 \nDestIp = 127.0.0.1 \nDestPort = 1111 \nLocalPort = 8888 \n\n", section);
memset(section, 0, MAX_LEN_SECTION);
ret = getSection("./commModule.conf", 2, "TcpClient", section);
TEST_ASSERT_EQUAL_INT(TOOLS_SUCCESS, ret);
TEST_ASSERT_EQUAL_STRING("[TcpClient] \nLogicName = tcpClient2 \nDestIp = 127.0.0.1 \nDestPort = 2222 \nLocalPort = 9999 \n\n", section);
memset(section, 0, MAX_LEN_SECTION);
ret = getSection("./commModule.conf", 3, "TcpClient", section);
TEST_ASSERT_EQUAL_INT(TOOLS_SUCCESS, ret);
TEST_ASSERT_EQUAL_STRING("[TcpClient] \nLogicName = tcpClient3 \nDestIp = 127.0.0.1 \nDestPort = 3333 \nLocalPort = 1234 \n\n", section);
}
示例14: test_MultipleEntryHandling
void test_MultipleEntryHandling() {
char HOST1[] = "192.0.2.3";
char REASON1[] = "DENY";
char HOST2[] = "192.0.5.5";
char REASON2[] = "RATE";
char HOST3[] = "192.0.10.1";
char REASON3[] = "DENY";
add_entry(HOST1, REASON1);
add_entry(HOST2, REASON2);
add_entry(HOST3, REASON3);
struct kod_entry* result;
TEST_ASSERT_EQUAL(1, search_entry(HOST1, &result));
TEST_ASSERT_EQUAL_STRING(HOST1, result->hostname);
TEST_ASSERT_EQUAL_STRING(REASON1, result->type);
TEST_ASSERT_EQUAL(1, search_entry(HOST2, &result));
TEST_ASSERT_EQUAL_STRING(HOST2, result->hostname);
TEST_ASSERT_EQUAL_STRING(REASON2, result->type);
TEST_ASSERT_EQUAL(1, search_entry(HOST3, &result));
TEST_ASSERT_EQUAL_STRING(HOST3, result->hostname);
TEST_ASSERT_EQUAL_STRING(REASON3, result->type);
free(result);
}
示例15: convertBasedNumberToBase10Number
void test_convertBasedNumberToBase10Number_will_throw_error_when_a_symbol_inside_the_hexadecimal_expression_star_with_0x()
{
String testTokenizer;
String *testTokenizer1;
Error exception;
testTokenizer.rawString = "[email protected]";
testTokenizer.startIndex = 0;
testTokenizer.length = 6;
//Since it is work , c whether work for other symbol
Try
{
testTokenizer1 = convertBasedNumberToBase10Number(&testTokenizer);
}
Catch(exception)
{
TEST_ASSERT_EQUAL(INVALID_EXPRESSION,exception);
// Check the error message been updated or not .
TEST_ASSERT_EQUAL_STRING("[email protected]",errorMessage.rawString);
TEST_ASSERT_EQUAL(3,errorMessage.position);
TEST_ASSERT_EQUAL_STRING("Invalid expression ! ",errorMessage.message);
}
testTokenizer.rawString = "0x1$00";
testTokenizer.startIndex = 0;
testTokenizer.length = 6;
Try
{
testTokenizer1 = convertBasedNumberToBase10Number(&testTokenizer);
}
Catch(exception)
{
TEST_ASSERT_EQUAL(INVALID_EXPRESSION,exception);
// Check the error message been updated or not .
TEST_ASSERT_EQUAL_STRING("0x1$00",errorMessage.rawString);
TEST_ASSERT_EQUAL(3,errorMessage.position);
TEST_ASSERT_EQUAL_STRING("Invalid expression ! ",errorMessage.message);
}
testTokenizer.rawString = "0x1=00";
testTokenizer.startIndex = 0;
testTokenizer.length = 6;
Try
{
testTokenizer1 = convertBasedNumberToBase10Number(&testTokenizer);
}
Catch(exception)
{
TEST_ASSERT_EQUAL(INVALID_EXPRESSION,exception);
// Check the error message been updated or not .
TEST_ASSERT_EQUAL_STRING("0x1=00",errorMessage.rawString);
TEST_ASSERT_EQUAL(3,errorMessage.position);
TEST_ASSERT_EQUAL_STRING("Invalid expression ! ",errorMessage.message);
}
}