void test_Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization_should_map_from_internal_to_public_type(void)
{
    TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__SYNCHRONIZATION__WRITETHROUGH,
                      Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization(
                          KINETIC_SYNCHRONIZATION_WRITETHROUGH));
    TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__SYNCHRONIZATION__WRITEBACK,
                      Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization(
                          KINETIC_SYNCHRONIZATION_WRITEBACK));
    TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__SYNCHRONIZATION__FLUSH,
                      Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization(
                          KINETIC_SYNCHRONIZATION_FLUSH));
    TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__SYNCHRONIZATION__INVALID_SYNCHRONIZATION,
                      Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization(
                          KINETIC_SYNCHRONIZATION_INVALID));
    TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__SYNCHRONIZATION__INVALID_SYNCHRONIZATION,
                      Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization(
                          (KineticSynchronization)((int)KINETIC_SYNCHRONIZATION_FLUSH + 1000)));
}
Ejemplo n.º 2
0
void KineticMessage_ConfigureKeyValue(KineticMessage* const message,
                                      const KineticEntry* entry)
{
    KINETIC_ASSERT(message != NULL);
    KINETIC_ASSERT(entry != NULL);

    // Enable command body and keyValue fields by pointing at
    // pre-allocated elements in message
    message->command.body = &message->body;
    message->command.body->keyvalue = &message->keyValue;

    // Set keyValue fields appropriately
    CONFIG_FIELD_BYTE_BUFFER(key,        key,        message->keyValue, entry);
    CONFIG_FIELD_BYTE_BUFFER(newVersion, newversion, message->keyValue, entry);
    CONFIG_FIELD_BYTE_BUFFER(dbVersion,  dbversion,  message->keyValue, entry);
    CONFIG_FIELD_BYTE_BUFFER(tag,        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 =
            Com__Seagate__Kinetic__Proto__Command__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 =
            Com__Seagate__Kinetic__Proto__Command__Synchronization_from_KineticSynchronization(
                entry->synchronization);
    }
}