当前位置: 首页>>代码示例>>C++>>正文


C++ ASSERT_STR_EQ函数代码示例

本文整理汇总了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
}
开发者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


注:本文中的ASSERT_STR_EQ函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。