void test_KineticProto_Algorithm_from_KineticAlgorithm_should_map_from_public_to_internal_type(void) { TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_SHA1, KineticProto_Algorithm_from_KineticAlgorithm(KINETIC_ALGORITHM_SHA1)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_SHA2, KineticProto_Algorithm_from_KineticAlgorithm(KINETIC_ALGORITHM_SHA2)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_SHA3, KineticProto_Algorithm_from_KineticAlgorithm(KINETIC_ALGORITHM_SHA3)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_CRC32, KineticProto_Algorithm_from_KineticAlgorithm(KINETIC_ALGORITHM_CRC32)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_CRC64, KineticProto_Algorithm_from_KineticAlgorithm(KINETIC_ALGORITHM_CRC64)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_INVALID_ALGORITHM, KineticProto_Algorithm_from_KineticAlgorithm(KINETIC_ALGORITHM_INVALID)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_INVALID_ALGORITHM, KineticProto_Algorithm_from_KineticAlgorithm((KineticAlgorithm)1000)); TEST_ASSERT_EQUAL( KINETIC_PROTO_ALGORITHM_INVALID_ALGORITHM, KineticProto_Algorithm_from_KineticAlgorithm((KineticAlgorithm) - 19)); }
void KineticMessage_ConfigureKeyValue(KineticMessage* const message, const KineticEntry* entry) { assert(message != NULL); assert(entry != NULL); // Enable command body and keyValue fields by pointing at // pre-allocated elements in message message->command.body = &message->body; message->proto.command->body = &message->body; message->command.body->keyValue = &message->keyValue; message->proto.command->body->keyValue = &message->keyValue; // Set keyValue fields appropriately CONFIG_FIELD_BYTE_BUFFER(key, message->keyValue, entry); CONFIG_FIELD_BYTE_BUFFER(newVersion, message->keyValue, entry); CONFIG_FIELD_BYTE_BUFFER(dbVersion, message->keyValue, entry); CONFIG_FIELD_BYTE_BUFFER(tag, message->keyValue, entry); message->keyValue.has_force = (bool)((int)entry->force); if (message->keyValue.has_force) { message->keyValue.force = entry->force; } message->keyValue.has_algorithm = (bool)((int)entry->algorithm > 0); if (message->keyValue.has_algorithm) { message->keyValue.algorithm = KineticProto_Algorithm_from_KineticAlgorithm(entry->algorithm); } message->keyValue.has_metadataOnly = entry->metadataOnly; if (message->keyValue.has_metadataOnly) { message->keyValue.metadataOnly = entry->metadataOnly; } message->keyValue.has_synchronization = (entry->synchronization > 0); if (message->keyValue.has_synchronization) { message->keyValue.synchronization = KineticProto_Synchronization_from_KineticSynchronization( entry->synchronization); } }