void test_KineticProto_Synchronization_from_KineticSynchronization_should_map_from_internal_to_public_type(void)
{
    TEST_ASSERT_EQUAL(KINETIC_PROTO_SYNCHRONIZATION_WRITETHROUGH,
        KineticProto_Synchronization_from_KineticSynchronization(
            KINETIC_SYNCHRONIZATION_WRITETHROUGH));
    TEST_ASSERT_EQUAL(KINETIC_PROTO_SYNCHRONIZATION_WRITEBACK,
        KineticProto_Synchronization_from_KineticSynchronization(
            KINETIC_SYNCHRONIZATION_WRITEBACK));
    TEST_ASSERT_EQUAL(KINETIC_PROTO_SYNCHRONIZATION_FLUSH,
        KineticProto_Synchronization_from_KineticSynchronization(
            KINETIC_SYNCHRONIZATION_FLUSH));
    TEST_ASSERT_EQUAL(KINETIC_PROTO_SYNCHRONIZATION_INVALID_SYNCHRONIZATION,
        KineticProto_Synchronization_from_KineticSynchronization(
            KINETIC_SYNCHRONIZATION_INVALID));
    TEST_ASSERT_EQUAL(KINETIC_PROTO_SYNCHRONIZATION_INVALID_SYNCHRONIZATION,
        KineticProto_Synchronization_from_KineticSynchronization(
            (KineticSynchronization)((int)KINETIC_SYNCHRONIZATION_FLUSH + 1000)));
}
示例#2
0
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);
    }
}