• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ASSERT_EQUAL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ASSERT_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_EQUAL函数的具体用法?C++ ASSERT_EQUAL怎么用?C++ ASSERT_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ASSERT_EQUAL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_create_request

void test_create_request(void **state)
{
    (void)state;

    kaa_user_log_record_t *test_log_record = kaa_test_log_record_create();
    test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
    size_t test_log_record_size = test_log_record->get_size(test_log_record);

    kaa_log_collector_t *log_collector = NULL;
    kaa_error_t error_code = kaa_log_collector_create(&log_collector, status,
            channel_manager, logger);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    mock_strategy_context_t strategy;
    memset(&strategy, 0, sizeof(mock_strategy_context_t));
    strategy.decision = NOOP;
    strategy.max_parallel_uploads = UINT32_MAX;

    kaa_log_bucket_constraints_t constraints = {
        .max_bucket_size = 2 * test_log_record_size,
        .max_bucket_log_count = UINT32_MAX,
    };

    error_code = kaa_logging_init(log_collector, create_mock_storage(), &strategy, &constraints);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    size_t expected_size = 0;
    error_code = kaa_logging_request_get_size(log_collector, &expected_size);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    uint8_t buffer[expected_size];
    kaa_platform_message_writer_t *writer = NULL;
    error_code = kaa_platform_message_writer_create(&writer, buffer, expected_size);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    ASSERT_NOT_NULL(writer);

    error_code = kaa_logging_request_serialize(log_collector, writer);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    kaa_platform_message_writer_destroy(writer);

    uint8_t *buf_cursor = buffer;
    ASSERT_EQUAL(KAA_EXTENSION_LOGGING, KAA_HTONS(*(uint16_t *)buf_cursor));
    buf_cursor += sizeof(uint16_t);

    uint8_t options[] = { 0x00, 0x01 };
    ASSERT_EQUAL(memcmp(buf_cursor, options, 2), 0);
    buf_cursor += 2;

    ASSERT_EQUAL(*(uint32_t *) buf_cursor, KAA_HTONL(20));
    buf_cursor += sizeof(uint32_t);

    uint8_t request_id_records_count[]  = { 0x00, 0x01, 0x00, 0x01 };
    ASSERT_EQUAL(memcmp(buf_cursor, request_id_records_count, 4), 0);
    buf_cursor += 4;

    uint8_t record_buf[test_log_record_size];
    avro_writer_t avro_writer = avro_writer_memory((char *)record_buf, test_log_record_size);
    test_log_record->serialize(avro_writer, test_log_record);
    avro_writer_free(avro_writer);

    ASSERT_EQUAL(*(uint32_t *) buf_cursor, KAA_HTONL(test_log_record_size));
    buf_cursor += sizeof(uint32_t);

    ASSERT_EQUAL(memcmp(buf_cursor, record_buf, test_log_record_size), 0);

    kaa_log_collector_destroy(log_collector);
    test_log_record->destroy(test_log_record);
}



void test_response(void **state)
{
    (void)state;

    srand(time(NULL));

    kaa_log_collector_t *log_collector = NULL;
    kaa_error_t error_code = kaa_log_collector_create(&log_collector, status, channel_manager, logger);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    mock_strategy_context_t strategy;
    memset(&strategy, 0, sizeof(mock_strategy_context_t));

    mock_storage_context_t *storage = create_mock_storage();

    kaa_log_bucket_constraints_t constraints = {
        .max_bucket_size = 1024,
        .max_bucket_log_count = UINT32_MAX,
    };

    error_code = kaa_logging_init(log_collector, storage, &strategy, &constraints);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    uint32_t response_count = 2;
    size_t response_buffer_size = sizeof(uint32_t) + sizeof(uint32_t) * response_count;
    uint8_t response_buffer[response_buffer_size];
//.........这里部分代码省略.........
开发者ID:Kirill380,项目名称:kaa,代码行数:101,代码来源:test_kaa_log.c


示例2: testSetAtWithInt

void testSetAtWithInt() {
	IndexableSet<int> indexSet{1,2,3,4};
	int i = indexSet.at(1);
	ASSERT_EQUAL(2, i);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例3: testBracketOperatorBackWithInt

void testBracketOperatorBackWithInt() {
	IndexableSet<int> indexSet{1,2,3,4};
	int i = indexSet[3];
	ASSERT_EQUAL(4, i);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例4: testCaselessCompare

void testCaselessCompare() {
	IndexableSet<std::string, CaselessComparator> indexSet {"hallo","Hallo","Test","taste"};
	ASSERT_EQUAL(3, indexSet.size());
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:4,代码来源:Test.cpp


示例5: testIndexSetBackWithInt

void testIndexSetBackWithInt() {
	IndexableSet<int> indexSet{1,2,3,4};
	int i = indexSet.back();
	ASSERT_EQUAL(4, i);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例6: testDefaultConstructor

void testDefaultConstructor() {
	IndexableSet<int> indexSet{};
	indexSet.insert(1);
	ASSERT_EQUAL(1, indexSet[0] );
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例7: testCopyConstructor

void testCopyConstructor() {
	IndexableSet<int> indexSet {1, 2, 3, 4, 5};
	IndexableSet<int> copiedIndexSet(indexSet);
	ASSERT_EQUAL(3, indexSet[2]);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例8: testSubtraction

void testSubtraction(){
	Ring5 two{2};
	ASSERT_EQUAL(Ring5{0}, two-two);
	ASSERT_EQUAL(Ring5{0}, Ring5{4}-Ring5{4});
}
开发者ID:MattPD,项目名称:Prog3,代码行数:5,代码来源:Test.cpp


示例9: testMultiplication

void testMultiplication(){
    Ring5 four{4};
    Ring5 three{3};
    Ring5 two = four * three;
    ASSERT_EQUAL(Ring5{2},two);
}
开发者ID:MattPD,项目名称:Prog3,代码行数:6,代码来源:Test.cpp


示例10: testAddition

void testAddition() {
    Ring5 two{2};
    Ring5 four = two+two;
    ASSERT_EQUAL(4,four.value());
}
开发者ID:MattPD,项目名称:Prog3,代码行数:5,代码来源:Test.cpp


示例11: testAdditionWrap

void testAdditionWrap(){
    Ring5 four{4};
    Ring5 three = four + four;
    ASSERT_EQUAL(3,three.value());
}
开发者ID:MattPD,项目名称:Prog3,代码行数:5,代码来源:Test.cpp


示例12: testOutputOperator

// define operator<< format
void testOutputOperator(){
    std::ostringstream out;
    out << Ring5{4};
    ASSERT_EQUAL("Ring5{4}",out.str());
}
开发者ID:MattPD,项目名称:Prog3,代码行数:6,代码来源:Test.cpp


示例13: testValueCtorWithLargeInput

// operator==, operator<< for failures
void testValueCtorWithLargeInput(){
    Ring5 four{19};
    ASSERT_EQUAL(Ring5{4},four);
}
开发者ID:MattPD,项目名称:Prog3,代码行数:5,代码来源:Test.cpp


示例14: test_meta_extension_serialize

void test_meta_extension_serialize(void)
{
    KAA_TRACE_IN(logger);

    size_t meta_extension_size;
    kaa_error_t error_code = kaa_meta_data_request_get_size(&meta_extension_size);
    char buffer[meta_extension_size];

    kaa_platform_message_writer_t *writer;
    error_code = kaa_platform_message_writer_create(&writer, buffer, meta_extension_size);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    uint32_t expected_timeout = KAA_SYNC_TIMEOUT;
    kaa_digest expected_public_key_hash = {0x74, 0xc7, 0x51, 0x43, 0x00, 0xf7, 0xb8, 0x21, 0x2c, 0xc3, 0x6b, 0xa5, 0x9c, 0xb4, 0x03, 0xef, 0xc2, 0x5c, 0x65, 0x6c};
    kaa_digest expected_profile_hash = {0xfa, 0x71, 0xb5, 0x02, 0xe7, 0xdf, 0x96, 0x86, 0x6c, 0xdc, 0xe1, 0x4a, 0x17, 0x35, 0x7f, 0xd9, 0xa8, 0xfb, 0x71, 0x09};

    error_code = ext_copy_sha_hash(status->endpoint_public_key_hash, expected_public_key_hash);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    error_code = ext_copy_sha_hash(status->profile_hash, expected_profile_hash);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    kaa_context_t *context = NULL;
    kaa_init(&context);
    kaa_platform_protocol_t *protocol = NULL;
    kaa_platform_protocol_create(&protocol, context, status);

    error_code = kaa_meta_data_request_serialize(protocol, writer, 1);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    kaa_deinit(context);

    kaa_platform_message_reader_t *reader;
    error_code = kaa_platform_message_reader_create(&reader, buffer, meta_extension_size);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    uint16_t extension_type;
    uint16_t extension_options;
    uint32_t extension_payload;

    error_code = kaa_platform_message_read_extension_header(
                    reader, &extension_type, &extension_options, &extension_payload);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    ASSERT_EQUAL(extension_type, KAA_META_DATA_EXTENSION_TYPE);
    ASSERT_EQUAL(extension_options, (TIMEOUT_VALUE | PUBLIC_KEY_HASH_VALUE | PROFILE_HASH_VALUE | APP_TOKEN_VALUE));
    ASSERT_EQUAL(extension_payload, meta_extension_size - KAA_EXTENSION_HEADER_SIZE);

    uint32_t request_id;
    uint32_t timeout;
    kaa_digest public_key_hash;
    kaa_digest profile_hash;
    char sdk_token[KAA_SDK_TOKEN_LENGTH];

    error_code = kaa_platform_message_read(reader, &request_id, sizeof(uint32_t));
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    ASSERT_EQUAL(KAA_NTOHL(request_id), 1);
    error_code = kaa_platform_message_read(reader, &timeout, sizeof(uint32_t));
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    timeout = KAA_NTOHL(timeout);
    ASSERT_EQUAL(expected_timeout, timeout);

    error_code = kaa_platform_message_read_aligned(reader, public_key_hash, SHA_1_DIGEST_LENGTH);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    error_code = (memcmp(public_key_hash, expected_public_key_hash, SHA_1_DIGEST_LENGTH) == 0 ? KAA_ERR_NONE : KAA_ERR_READ_FAILED);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    error_code = kaa_platform_message_read_aligned(reader, profile_hash, SHA_1_DIGEST_LENGTH);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    error_code = (memcmp(profile_hash, expected_profile_hash, SHA_1_DIGEST_LENGTH) == 0 ? KAA_ERR_NONE : KAA_ERR_READ_FAILED);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    error_code = kaa_platform_message_read_aligned(reader, sdk_token, KAA_SDK_TOKEN_LENGTH);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);
    error_code = (memcmp(sdk_token, KAA_SDK_TOKEN, KAA_SDK_TOKEN_LENGTH) == 0 ? KAA_ERR_NONE : KAA_ERR_READ_FAILED);
    ASSERT_EQUAL(error_code, KAA_ERR_NONE);

    kaa_platform_message_reader_destroy(reader);
    kaa_platform_message_writer_destroy(writer);
}
开发者ID:BillTheBest,项目名称:kaa,代码行数:79,代码来源:test_meta_extension.c


示例15: testBracketOperatorBackWithString

void testBracketOperatorBackWithString() {
	IndexableSet<std::string> indexSet{"Hallo","Hoi","Test","Tester"};
	std::string compareString = indexSet[3];
	ASSERT_EQUAL("Tester", compareString);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例16: testDefaultCtor

void testDefaultCtor() {
    Ring5 v{};
    ASSERT_EQUAL(0,v.value());
}
开发者ID:MattPD,项目名称:Prog3,代码行数:4,代码来源:Test.cpp


示例17: testNegativeBracketToPositiveIndexString

void testNegativeBracketToPositiveIndexString() {
	IndexableSet<std::string> indexSet{"Hallo","Hoi","Test","Tester"};
	std::string compareString = indexSet[-1];
	ASSERT_EQUAL("Tester", compareString);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例18: testValueCtor

void testValueCtor(){
    Ring5 four{4};
    ASSERT_EQUAL(4,four.value());
}
开发者ID:MattPD,项目名称:Prog3,代码行数:4,代码来源:Test.cpp


示例19: testRangeConstructor

void testRangeConstructor() {
	std::vector<int> myInts = {1, 2, 3, 4, 5};
	IndexableSet<int> indexSet(myInts.begin() , myInts.end());
	ASSERT_EQUAL(3, indexSet[2]);
}
开发者ID:ginging,项目名称:cplusplus_testat3,代码行数:5,代码来源:Test.cpp


示例20: CTEST

// Test _xl_get_row().
CTEST(utility, _xl_get_row) {

    ASSERT_EQUAL(0,       lxw_get_row("A1"));
    ASSERT_EQUAL(1,       lxw_get_row("B2"));
    ASSERT_EQUAL(2,       lxw_get_row("C3"));
    ASSERT_EQUAL(9,       lxw_get_row("J10"));
    ASSERT_EQUAL(24,      lxw_get_row("Y25"));
    ASSERT_EQUAL(25,      lxw_get_row("Z26"));
    ASSERT_EQUAL(26,      lxw_get_row("AA27"));
    ASSERT_EQUAL(254,     lxw_get_row("IU255"));
    ASSERT_EQUAL(255,     lxw_get_row("IV256"));
    ASSERT_EQUAL(256,     lxw_get_row("IW257"));
    ASSERT_EQUAL(16383,   lxw_get_row("XFD16384"));
    ASSERT_EQUAL(16384,   lxw_get_row("XFE16385"));
    ASSERT_EQUAL(1048576, lxw_get_row("XFE1048577"));
}
开发者ID:douuubt,项目名称:libxlsxwriter,代码行数:17,代码来源:test_xl_get_row.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ASSERT_EQUALS函数代码示例发布时间:2022-05-30
下一篇:
C++ ASSERT_EFI_ERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap