本文整理汇总了C++中ASSERT_STR_EQ函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_STR_EQ函数的具体用法?C++ ASSERT_STR_EQ怎么用?C++ ASSERT_STR_EQ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_STR_EQ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_append_from_base16
static void
test_append_from_base16(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
const char to_decode[] = "546573742001090a0f2048656c6c6f";
int err;
#define B16_DECODED "Test \x01\x09\x0a\x0f Hello"
sol_buffer_init(&buf);
slice = sol_str_slice_from_str("XYZ");
err = sol_buffer_append_slice(&buf, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("XYZ"));
ASSERT_STR_EQ(buf.data, "XYZ");
slice = sol_str_slice_from_str(to_decode);
err = sol_buffer_append_from_base16(&buf, slice, SOL_DECODE_LOWERCASE);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("XYZ" B16_DECODED));
ASSERT_STR_EQ(buf.data, "XYZ" B16_DECODED);
sol_buffer_fini(&buf);
#undef B16_DECODED
}
示例2: test_getset_parameter_node_value
static void test_getset_parameter_node_value (abts_case *tc, void *data)
{
cwmp_t * c = (cwmp_t*)data;
parameter_node_t * param;
char * name = "InternetGatewayDevice.DeviceInfo.SoftwareVersion";
char * retval;
char * value ;
pool_t * pool = pool_create(POOL_DEFAULT_SIZE);
FUNCTION_TRACE();
param = cwmp_get_parameter_path_node(c->root, name);
ASSERT_NOTNULL(param);
value = "V1.3.x";
cwmp_set_parameter_node_value(c, param, name, value, strlen(value));
retval = cwmp_data_get_parameter_value(c, param, name, pool);
printf("retval ------------------is %s\n", retval);
ASSERT_STR_EQ(value, retval);
value = "V1.4.x";
cwmp_set_parameter_node_value(c, param, name, value, strlen(value));
retval = cwmp_data_get_parameter_value(c, param, name, pool);
ASSERT_STR_EQ(value, retval);
pool_destroy(pool);
}
示例3: TEST_START
TEST_END
TEST_START(pushes_buf_kv)
{
clax_kv_list_t list;
clax_kv_list_init(&list);
clax_kv_list_pushn(&list, "foo", 3, "bar", 3);
ASSERT_EQ(list.size, 1);
ASSERT_STR_EQ(clax_kv_list_find(&list, "foo"), "bar");
clax_kv_list_pushn(&list, "", 0, "bar", 3);
ASSERT_EQ(list.size, 2);
ASSERT_STR_EQ(clax_kv_list_find(&list, ""), "bar");
clax_kv_list_pushn(&list, "baz", 3, "", 0);
ASSERT_EQ(list.size, 3);
ASSERT_STR_EQ(clax_kv_list_find(&list, "baz"), "");
clax_kv_list_pushn(&list, "", 0, "", 0);
ASSERT_EQ(list.size, 4);
size_t start = 3;
ASSERT_STR_EQ(clax_kv_list_find_all(&list, "", &start), "");
clax_kv_list_free(&list);
}
示例4: test_insert_as_base16
static void
test_insert_as_base16(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
const char to_encode[] = "Test \x01\x09\x0a\x0f Hello";
int err;
#define B16_ENCODED "546573742001090a0f2048656c6c6f"
sol_buffer_init(&buf);
slice = sol_str_slice_from_str("World");
err = sol_buffer_insert_slice(&buf, 0, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("World"));
ASSERT_STR_EQ(buf.data, "World");
slice = sol_str_slice_from_str("Hello");
err = sol_buffer_insert_slice(&buf, 0, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("HelloWorld"));
ASSERT_STR_EQ(buf.data, "HelloWorld");
slice = sol_str_slice_from_str(to_encode);
err = sol_buffer_insert_as_base16(&buf, strlen("Hello"), slice, false);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("Hello" B16_ENCODED "World"));
ASSERT_STR_EQ(buf.data, "Hello" B16_ENCODED "World");
sol_buffer_fini(&buf);
#undef B16_ENCODED
}
示例5: test_insert_as_base64
static void
test_insert_as_base64(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
const char to_encode[] = "This is a message that is multiple of 3 chars";
int err;
#define B64_ENCODED "VGhpcyBpcyBhIG1lc3NhZ2UgdGhhdCBpcyBtdWx0aXBsZSBvZiAzIGNoYXJz"
sol_buffer_init(&buf);
slice = sol_str_slice_from_str("World");
err = sol_buffer_insert_slice(&buf, 0, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("World"));
ASSERT_STR_EQ(buf.data, "World");
slice = sol_str_slice_from_str("Hello");
err = sol_buffer_insert_slice(&buf, 0, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("HelloWorld"));
ASSERT_STR_EQ(buf.data, "HelloWorld");
slice = sol_str_slice_from_str(to_encode);
err = sol_buffer_insert_as_base64(&buf, strlen("Hello"), slice, SOL_BASE64_MAP);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("Hello" B64_ENCODED "World"));
ASSERT_STR_EQ(buf.data, "Hello" B64_ENCODED "World");
sol_buffer_fini(&buf);
#undef B64_ENCODED
}
示例6: test_append_from_base64
static void
test_append_from_base64(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
const char to_decode[] = "VGhpcyBpcyBhIG1lc3NhZ2UgdGhhdCBpcyBtdWx0aXBsZSBvZiAzIGNoYXJz";
int err;
#define B64_DECODED "This is a message that is multiple of 3 chars"
sol_buffer_init(&buf);
slice = sol_str_slice_from_str("XYZ");
err = sol_buffer_append_slice(&buf, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("XYZ"));
ASSERT_STR_EQ(buf.data, "XYZ");
slice = sol_str_slice_from_str(to_decode);
err = sol_buffer_append_from_base64(&buf, slice, SOL_BASE64_MAP);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("XYZ" B64_DECODED));
ASSERT_STR_EQ(buf.data, "XYZ" B64_DECODED);
sol_buffer_fini(&buf);
#undef B64_DECODED
}
示例7: test_insert_slice
static void
test_insert_slice(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
int err;
sol_buffer_init(&buf);
slice = sol_str_slice_from_str("World");
err = sol_buffer_insert_slice(&buf, 0, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("World"));
ASSERT_STR_EQ(buf.data, "World");
slice = sol_str_slice_from_str("Hello");
err = sol_buffer_insert_slice(&buf, 0, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("HelloWorld"));
ASSERT_STR_EQ(buf.data, "HelloWorld");
slice = sol_str_slice_from_str(" -*- ");
err = sol_buffer_insert_slice(&buf, strlen("Hello"), slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("Hello -*- World"));
ASSERT_STR_EQ(buf.data, "Hello -*- World");
sol_buffer_fini(&buf);
}
示例8: test_set_slice
static void
test_set_slice(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
const char *str = "Hello";
char *backend;
int err;
backend = strdup(str);
slice = sol_str_slice_from_str(backend);
sol_buffer_init(&buf);
err = sol_buffer_set_slice(&buf, slice);
ASSERT(err >= 0);
ASSERT_INT_EQ(buf.used, strlen(backend));
ASSERT_STR_EQ(buf.data, backend);
backend[1] = 'a';
ASSERT_STR_NE(buf.data, backend);
ASSERT_STR_EQ(buf.data, str);
sol_buffer_fini(&buf);
free(backend);
}
示例9: test_large_map
TEST test_large_map(void)
{
struct mushroom_map *map = mushroom_map_new();
ASSERT_EQ_FMT((size_t)0, mushroom_map_get_count(map), "%zu");
int key_number = 300;
for (int i = 0; i < key_number; i++) {
char key[10];
sprintf(key, "key-%d", i);
mushroom_map_put(map, key, key);
}
char *value = mushroom_map_get(map, "key-9");
ASSERT(value != NULL);
ASSERT_STR_EQ("key-9", value);
for (int i = 0; i < key_number; i++) {
char key[10];
sprintf(key, "key-%d", i);
mushroom_map_put(map, key, key);
value = mushroom_map_get(map, key);
ASSERT(value != NULL);
ASSERT_STR_EQ(key, value);
}
value = mushroom_map_get(map, "key-9");
ASSERT(value != NULL);
ASSERT_STR_EQ("key-9", value);
ASSERT_EQ_FMT((size_t)300, mushroom_map_get_count(map), "%zu");
mushroom_map_free(map);
PASS();
}
示例10: TEST
TEST(ZXTestCAssertionTest, AssertStrEq) {
const char* str1 = "a";
const char* str2 = "a";
EXPECT_STR_EQ(str1, str2, "ASSERT_STR_EQ failed to identify equal strings.");
EXPECT_STR_EQ(str1, str1, "ASSERT_STR_EQ failed to identify equal strings.");
ASSERT_STR_EQ(str1, str2, "ASSERT_STR_EQ failed to identify equal strings.");
ASSERT_STR_EQ(str1, str1, "ASSERT_STR_EQ failed to identify equal strings.");
// No failures
ZX_ASSERT_MSG(!_ZXTEST_ABORT_IF_ERROR, "Assert was did not abort test.");
}
示例11: write_flushes_multiple_times
TEST write_flushes_multiple_times(void) {
enum status s;
s = NORM_INIT(h);
ASSERT_EQ(status_ok, s);
char b[] = "hello$me$how$are$you?";
s = buf_write(&h, b, sizeof(b));
ASSERT_STR_EQ("hello$me$how$are$", (char *)flush_buffer);
ASSERT_STR_EQ("you?", (char *)buffer);
PASS();
}
示例12: write_flushes_on_terminator
TEST write_flushes_on_terminator(void) {
enum status s;
s = NORM_INIT(h);
ASSERT_EQ(status_ok, s);
char b[] = "hello$ me";
s = buf_write(&h, b, sizeof(b));
ASSERT_STR_EQ("hello$", (char *)flush_buffer);
ASSERT_STR_EQ(" me", (char *)buffer);
PASS();
}
示例13: close_works
TEST close_works(void) {
char b[] = "hello";
ASSERT_EQ(status_ok, NORM_INIT(h));
ASSERT_EQ(status_ok, buf_write(&h, b, sizeof(b)));
ASSERT_STR_EQ("", (char *)flush_buffer);
ASSERT_STR_EQ("hello", (char *)buffer);
ASSERT_EQ(status_ok, buf_close(&h));
ASSERT_STR_EQ("hello", (char *)flush_buffer);
PASS();
};
示例14: write_flushes_on_multi_char_term
TEST write_flushes_on_multi_char_term(void) {
enum status s;
s = MULT_INIT(h);
ASSERT_EQ(status_ok, s);
char b[] = "hello^me^@how are you?";
s = buf_write(&h, b, sizeof(b));
ASSERT_STR_EQ("hello^me^@", (char *)flush_buffer);
ASSERT_STR_EQ("how are you?", (char *)buffer);
PASS();
}
示例15: write_flushes_when_out_of_space
TEST write_flushes_when_out_of_space(void) {
enum status s;
s = CUST_BLEN_INIT(h, 5);
ASSERT_EQ(status_ok, s);
char b[] = "hello me";
s = buf_write(&h, b, sizeof(b));
ASSERT_EQ(status_ok, s);
ASSERT_STR_EQ("hello", (char *)flush_buffer);
ASSERT_STR_EQ(" me", (char *)buffer);
PASS();
}