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

TST: add tests for ccaosdb

parent cba6eb76
No related branches found
No related tags found
1 merge request!22Return to int64 for integer values
Pipeline #13203 passed
Pipeline: caosdb-cppinttest

#13219

    Pipeline: caosdb-cppinttest

    #13217

      Pipeline: caosdb-cppinttest

      #13204

        ......@@ -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