本文整理汇总了C++中ASSERT_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_EQUAL函数的具体用法?C++ ASSERT_EQUAL怎么用?C++ ASSERT_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_EQUAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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];
//.........这里部分代码省略.........
示例2: testSetAtWithInt
void testSetAtWithInt() {
IndexableSet<int> indexSet{1,2,3,4};
int i = indexSet.at(1);
ASSERT_EQUAL(2, i);
}
示例3: testBracketOperatorBackWithInt
void testBracketOperatorBackWithInt() {
IndexableSet<int> indexSet{1,2,3,4};
int i = indexSet[3];
ASSERT_EQUAL(4, i);
}
示例4: testCaselessCompare
void testCaselessCompare() {
IndexableSet<std::string, CaselessComparator> indexSet {"hallo","Hallo","Test","taste"};
ASSERT_EQUAL(3, indexSet.size());
}
示例5: testIndexSetBackWithInt
void testIndexSetBackWithInt() {
IndexableSet<int> indexSet{1,2,3,4};
int i = indexSet.back();
ASSERT_EQUAL(4, i);
}
示例6: testDefaultConstructor
void testDefaultConstructor() {
IndexableSet<int> indexSet{};
indexSet.insert(1);
ASSERT_EQUAL(1, indexSet[0] );
}
示例7: testCopyConstructor
void testCopyConstructor() {
IndexableSet<int> indexSet {1, 2, 3, 4, 5};
IndexableSet<int> copiedIndexSet(indexSet);
ASSERT_EQUAL(3, indexSet[2]);
}
示例8: testSubtraction
void testSubtraction(){
Ring5 two{2};
ASSERT_EQUAL(Ring5{0}, two-two);
ASSERT_EQUAL(Ring5{0}, Ring5{4}-Ring5{4});
}
示例9: testMultiplication
void testMultiplication(){
Ring5 four{4};
Ring5 three{3};
Ring5 two = four * three;
ASSERT_EQUAL(Ring5{2},two);
}
示例10: testAddition
void testAddition() {
Ring5 two{2};
Ring5 four = two+two;
ASSERT_EQUAL(4,four.value());
}
示例11: testAdditionWrap
void testAdditionWrap(){
Ring5 four{4};
Ring5 three = four + four;
ASSERT_EQUAL(3,three.value());
}
示例12: testOutputOperator
// define operator<< format
void testOutputOperator(){
std::ostringstream out;
out << Ring5{4};
ASSERT_EQUAL("Ring5{4}",out.str());
}
示例13: testValueCtorWithLargeInput
// operator==, operator<< for failures
void testValueCtorWithLargeInput(){
Ring5 four{19};
ASSERT_EQUAL(Ring5{4},four);
}
示例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);
}
示例15: testBracketOperatorBackWithString
void testBracketOperatorBackWithString() {
IndexableSet<std::string> indexSet{"Hallo","Hoi","Test","Tester"};
std::string compareString = indexSet[3];
ASSERT_EQUAL("Tester", compareString);
}