本文整理汇总了C++中ASSERT_STR_EQ函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_STR_EQ函数的具体用法?C++ ASSERT_STR_EQ怎么用?C++ ASSERT_STR_EQ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_STR_EQ函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:Achint08,项目名称:soletta,代码行数:27,代码来源:test-buffer.c
示例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);
}
开发者ID:HankMa,项目名称:netcwmp,代码行数:32,代码来源:test_rpc.c
示例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);
}
开发者ID:clarive,项目名称:clax,代码行数:27,代码来源:test_clax_util.c
示例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
}
开发者ID:Achint08,项目名称:soletta,代码行数:33,代码来源:test-buffer.c
示例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
}
开发者ID:Achint08,项目名称:soletta,代码行数:33,代码来源:test-buffer.c
示例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
}
开发者ID:Achint08,项目名称:soletta,代码行数:27,代码来源:test-buffer.c
示例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);
}
开发者ID:Achint08,项目名称:soletta,代码行数:28,代码来源:test-buffer.c
示例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);
}
开发者ID:Achint08,项目名称:soletta,代码行数:27,代码来源:test-buffer.c
示例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();
}
开发者ID:kragniz,项目名称:mushroom,代码行数:35,代码来源:map_test.c
示例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.");
}
开发者ID:saltstar,项目名称:smartnix,代码行数:11,代码来源:assertions_test.c
示例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();
}
开发者ID:sw17ch,项目名称:inversion_demo,代码行数:14,代码来源:test.c
示例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();
}
开发者ID:sw17ch,项目名称:inversion_demo,代码行数:15,代码来源:test.c
示例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();
};
开发者ID:sw17ch,项目名称:inversion_demo,代码行数:15,代码来源:test.c
示例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();
}
开发者ID:sw17ch,项目名称:inversion_demo,代码行数:15,代码来源:test.c
示例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();
}
开发者ID:sw17ch,项目名称:inversion_demo,代码行数:16,代码来源:test.c
示例16: serialize
TEST serialize(void) {
sl2_t a, b;
unsigned char bufa[256] = {0};
char bufb[256], bufc[256];
int i;
for (i = 0; i < 1024; i++) {
sl2_rand(a);
sl2_serialize(a, bufa);
sl2_unserialize(b, bufa);
ASSERT_STR_EQ(gf2p127_hex(bufb, a[0][0]), gf2p127_hex(bufc, b[0][0]));
ASSERT_STR_EQ(gf2p127_hex(bufb, a[0][1]), gf2p127_hex(bufc, b[0][1]));
ASSERT_STR_EQ(gf2p127_hex(bufb, a[1][0]), gf2p127_hex(bufc, b[1][0]));
ASSERT_STR_EQ(gf2p127_hex(bufb, a[1][1]), gf2p127_hex(bufc, b[1][1]));
}
PASS();
}
开发者ID:kfish,项目名称:hwsl2,代码行数:16,代码来源:sl2.c
示例17: multiplication_special_bit_right
TEST multiplication_special_bit_right(void) {
sl2_t a, b, m[2];
char bufa[1024], bufb[1024];
int i;
sl2_init(m);
for (i = 0; i < 1024; i++) {
sl2_rand(a);
sl2_mul(b, a, m[i % 2]);
sl2_mul_bit_right(&a[0][0], &a[0][1], &a[1][0], &a[1][1], _mm_load_si128(&minmax[i % 2]));
ASSERT_STR_EQ(gf2p127_hex(bufa, a[0][0]), gf2p127_hex(bufb, b[0][0]));
ASSERT_STR_EQ(gf2p127_hex(bufa, a[0][1]), gf2p127_hex(bufb, b[0][1]));
ASSERT_STR_EQ(gf2p127_hex(bufa, a[1][0]), gf2p127_hex(bufb, b[1][0]));
ASSERT_STR_EQ(gf2p127_hex(bufa, a[1][1]), gf2p127_hex(bufb, b[1][1]));
}
PASS();
}
开发者ID:kfish,项目名称:hwsl2,代码行数:16,代码来源:sl2.c
示例18: test_dbfr_getline_2
/* tests all conditions which should hold when reading to the end of the file. */
int test_dbfr_getline_2() {
dbfr_t *reader = dbfr_open(TEST_FILENAME);
ssize_t retval;
int i = 0;
char expected[80];
unittest_has_error = 0;
ASSERT_TRUE(reader != NULL, "dbfr_open: return non-null");
if (! reader) {
return 1;
}
while (i < LINES_IN_TEST_FILE) {
i++;
dbfr_getline(reader);
ASSERT_LONG_EQ(i, reader->line_no, "dbfr_getline: line_no incremented");
}
ASSERT_TRUE(reader->current_line != NULL, "current_line not NULL at EOF");
ASSERT_TRUE(reader->next_line == NULL, "next_line NULL at EOF");
sprintf(expected, "this is line %d\n", LINES_IN_TEST_FILE);
ASSERT_STR_EQ(expected, reader->current_line, "current_line intact at EOF");
retval = dbfr_getline(reader);
ASSERT_LONG_GT(0, retval, "dbfr_getline() returns < 0 at EOF");
ASSERT_TRUE(reader->eof, "dbfr_t.eof set at EOF");
dbfr_close(reader);
return 0;
}
开发者ID:bathtub,项目名称:crush-tools,代码行数:32,代码来源:dbfr_test.c
示例19: test_remove_data
static void
test_remove_data(void)
{
struct sol_buffer buf;
struct sol_str_slice slice;
int err;
sol_buffer_init(&buf);
slice = sol_str_slice_from_str("ABCDEFGHI");
err = sol_buffer_append_slice(&buf, slice);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("ABCDEFGHI"));
ASSERT_STR_EQ(buf.data, "ABCDEFGHI");
err = sol_buffer_remove_data(&buf, strlen("ABC"), 0);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("DEFGHI"));
err = sol_buffer_remove_data(&buf, strlen("GHI"), 3);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, strlen("DEF"));
err = sol_buffer_remove_data(&buf, strlen("DEF"), 0);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, 0);
err = sol_buffer_remove_data(&buf, 100, 0);
ASSERT_INT_EQ(err, 0);
ASSERT_INT_EQ(buf.used, 0);
err = sol_buffer_remove_data(&buf, 0, 100);
ASSERT_INT_EQ(err, -EINVAL);
sol_buffer_fini(&buf);
}
开发者ID:Achint08,项目名称:soletta,代码行数:35,代码来源:test-buffer.c
示例20: basic_test
static bool basic_test(void) {
BEGIN_TEST;
zx::socket client, server;
ASSERT_EQ(ZX_OK, zx::socket::create(ZX_SOCKET_HAS_CONTROL, &client, &server));
async_loop_t* loop = nullptr;
ASSERT_EQ(ZX_OK, async_loop_create(&kAsyncLoopConfigNoAttachToThread, &loop), "");
ASSERT_EQ(ZX_OK, async_loop_start_thread(loop, "spaceship-dispatcher", nullptr), "");
async_dispatcher_t* dispatcher = async_loop_get_dispatcher(loop);
ASSERT_EQ(ZX_OK, fidl_bind_socket(dispatcher, server.release(),
reinterpret_cast<fidl_dispatch_t*>(fidl_test_fakesocket_Control_dispatch),
nullptr, &kOps));
ASSERT_EQ(ZX_OK, fidl_test_fakesocket_ControlBind(client.get(), "xy", 2u));
char buffer[64];
memset(buffer, 0, sizeof(buffer));
size_t actual = 0u;
ASSERT_EQ(ZX_OK, fidl_test_fakesocket_ControlGetPeerAddr(client.get(), 5, buffer, sizeof(buffer), &actual));
ASSERT_EQ(3u, actual);
buffer[3] = '\0';
ASSERT_STR_EQ("abc", buffer);
client.reset();
async_loop_destroy(loop);
END_TEST;
}
开发者ID:saltstar,项目名称:smartnix,代码行数:32,代码来源:fakesocket_tests.cpp
注:本文中的ASSERT_STR_EQ函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论