Skip to content
Snippets Groups Projects
Verified Commit 2d63f016 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

BUG: fixed typo in ccaosdb and added tests

parent 49573d03
No related branches found
No related tags found
1 merge request!23Copy constructor for result set and entity
Pipeline #13192 passed
Pipeline: caosdb-cppinttest

#13194

    ......@@ -726,8 +726,8 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
    return 0;
    })
    ERROR_RETURN_CODE(GENERIC_ERROR,
    int caosdb_entity_entity_get_boolean_value_list_value_at(
    caosdb_entity_entity *entity, bool *out, const int index),
    int caosdb_entity_entity_get_boolean_list_value_at(caosdb_entity_entity *entity,
    bool *out, const int index),
    {
    auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity);
    auto value_list = wrapped_entity->GetValue().AsList();
    ......@@ -981,7 +981,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
    return 0;
    })
    ERROR_RETURN_CODE(GENERIC_ERROR,
    int caosdb_entity_property_get_boolean_value_list_value_at(
    int caosdb_entity_property_get_boolean_list_value_at(
    caosdb_entity_property *property, bool *out, const int index),
    {
    auto *wrapped_property = WRAPPED_PROPERTY_CAST(property);
    ......
    ......@@ -24,6 +24,7 @@
    #include "caosdb/status_code.h" // for StatusCode
    #include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_DATA_DIR
    #include "ccaosdb.h" // for caosdb_utility_get_env_fallback
    #include <cstdint> // for int64_t
    #include <cstring> // for strcmp
    #include <gtest/gtest-message.h> // for Message
    #include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl
    ......@@ -263,7 +264,7 @@ TEST_F(test_ccaosdb, test_property) {
    EXPECT_EQ(return_code, 0);
    }
    TEST_F(test_ccaosdb, test_list_property) {
    TEST_F(test_ccaosdb, test_string_list_property) {
    caosdb_entity_property property;
    int return_code(caosdb_entity_create_property(&property));
    ......@@ -285,12 +286,12 @@ TEST_F(test_ccaosdb, test_list_property) {
    EXPECT_FALSE(*is_ref);
    EXPECT_TRUE(*is_list);
    int length[] = {0}; // NOLINT
    return_code = caosdb_entity_property_get_value_list_length(&property, length);
    int length = -1; // NOLINT
    return_code = caosdb_entity_property_get_value_list_length(&property, &length);
    EXPECT_EQ(return_code, 0);
    EXPECT_EQ(*length, 3);
    EXPECT_EQ(length, 3);
    for (int i = 0; i < *length; i++) {
    for (int i = 0; i < length; i++) {
    return_code = caosdb_entity_property_get_string_list_value_at(&property, &out, i);
    EXPECT_EQ(return_code, 0);
    EXPECT_EQ(strcmp(value_list[i], out), 0); // NOLINT
    ......@@ -300,6 +301,82 @@ TEST_F(test_ccaosdb, test_list_property) {
    EXPECT_EQ(return_code, 0);
    }
    TEST_F(test_ccaosdb, test_int_list_property) {
    caosdb_entity_property property;
    int return_code(caosdb_entity_create_property(&property));
    EXPECT_EQ(return_code, 0);
    return_code = caosdb_entity_property_set_datatype(&property, "INTEGER", false, true);
    EXPECT_EQ(return_code, 0);
    const int64_t value_list[] = {1, 2, 3}; // NOLINT
    return_code = caosdb_entity_property_set_int_list_value(&property, &(value_list)[0], 3);
    EXPECT_EQ(return_code, 0);
    char *dt_out = nullptr; // NOLINT
    bool is_ref[] = {false}; // NOLINT
    bool is_list[] = {false}; // NOLINT
    return_code = caosdb_entity_property_get_datatype(&property, &dt_out, is_ref, is_list);
    EXPECT_EQ(return_code, 0);
    EXPECT_STREQ(dt_out, "INTEGER");
    EXPECT_FALSE(*is_ref);
    EXPECT_TRUE(*is_list);
    int length = -1; // NOLINT
    return_code = caosdb_entity_property_get_value_list_length(&property, &length);
    EXPECT_EQ(return_code, 0);
    EXPECT_EQ(length, 3);
    for (int i = 0; i < length; i++) {
    int64_t out = -1;
    return_code = caosdb_entity_property_get_int_list_value_at(&property, &out, i);
    EXPECT_EQ(return_code, 0);
    EXPECT_EQ(value_list[i], out); // NOLINT
    }
    return_code = caosdb_entity_delete_property(&property);
    EXPECT_EQ(return_code, 0);
    }
    TEST_F(test_ccaosdb, test_bool_list_property) {
    caosdb_entity_property property;
    int return_code(caosdb_entity_create_property(&property));
    EXPECT_EQ(return_code, 0);
    return_code = caosdb_entity_property_set_datatype(&property, "BOOLEAN", false, true);
    EXPECT_EQ(return_code, 0);
    const bool value_list[] = {true, true, false}; // NOLINT
    return_code = caosdb_entity_property_set_boolean_list_value(&property, &(value_list)[0], 3);
    EXPECT_EQ(return_code, 0);
    char *dt_out = nullptr; // NOLINT
    bool is_ref[] = {false}; // NOLINT
    bool is_list[] = {false}; // NOLINT
    return_code = caosdb_entity_property_get_datatype(&property, &dt_out, is_ref, is_list);
    EXPECT_EQ(return_code, 0);
    EXPECT_STREQ(dt_out, "BOOLEAN");
    EXPECT_FALSE(*is_ref);
    EXPECT_TRUE(*is_list);
    int length = -1; // NOLINT
    return_code = caosdb_entity_property_get_value_list_length(&property, &length);
    EXPECT_EQ(return_code, 0);
    EXPECT_EQ(length, 3);
    for (int i = 0; i < length; i++) {
    bool out = true;
    return_code = caosdb_entity_property_get_boolean_list_value_at(&property, &out, i);
    EXPECT_EQ(return_code, 0);
    EXPECT_EQ(value_list[i], out); // NOLINT
    }
    return_code = caosdb_entity_delete_property(&property);
    EXPECT_EQ(return_code, 0);
    }
    TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
    caosdb_entity_parent input_parent;
    int return_code(caosdb_entity_create_parent(&input_parent));
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment