Skip to content
Snippets Groups Projects

Return to int64 for integer values

Merged Timm Fitschen requested to merge f-int64 into dev
1 file
+ 82
5
Compare changes
  • Side-by-side
  • Inline
+ 82
5
@@ -24,6 +24,7 @@
@@ -24,6 +24,7 @@
#include "caosdb/status_code.h" // for StatusCode
#include "caosdb/status_code.h" // for StatusCode
#include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_DATA_DIR
#include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_DATA_DIR
#include "ccaosdb.h" // for caosdb_utility_get_env_fallback
#include "ccaosdb.h" // for caosdb_utility_get_env_fallback
 
#include <cstdint> // for int64_t
#include <cstring> // for strcmp
#include <cstring> // for strcmp
#include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl
@@ -263,7 +264,7 @@ TEST_F(test_ccaosdb, test_property) {
@@ -263,7 +264,7 @@ TEST_F(test_ccaosdb, test_property) {
EXPECT_EQ(return_code, 0);
EXPECT_EQ(return_code, 0);
}
}
TEST_F(test_ccaosdb, test_list_property) {
TEST_F(test_ccaosdb, test_string_list_property) {
caosdb_entity_property property;
caosdb_entity_property property;
int return_code(caosdb_entity_create_property(&property));
int return_code(caosdb_entity_create_property(&property));
@@ -285,12 +286,12 @@ TEST_F(test_ccaosdb, test_list_property) {
@@ -285,12 +286,12 @@ TEST_F(test_ccaosdb, test_list_property) {
EXPECT_FALSE(*is_ref);
EXPECT_FALSE(*is_ref);
EXPECT_TRUE(*is_list);
EXPECT_TRUE(*is_list);
int length[] = {0}; // NOLINT
int length = -1; // NOLINT
return_code = caosdb_entity_property_get_value_list_length(&property, length);
return_code = caosdb_entity_property_get_value_list_length(&property, &length);
EXPECT_EQ(return_code, 0);
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);
return_code = caosdb_entity_property_get_string_list_value_at(&property, &out, i);
EXPECT_EQ(return_code, 0);
EXPECT_EQ(return_code, 0);
EXPECT_EQ(strcmp(value_list[i], out), 0); // NOLINT
EXPECT_EQ(strcmp(value_list[i], out), 0); // NOLINT
@@ -300,6 +301,82 @@ TEST_F(test_ccaosdb, test_list_property) {
@@ -300,6 +301,82 @@ TEST_F(test_ccaosdb, test_list_property) {
EXPECT_EQ(return_code, 0);
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) {
TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
caosdb_entity_parent input_parent;
caosdb_entity_parent input_parent;
int return_code(caosdb_entity_create_parent(&input_parent));
int return_code(caosdb_entity_create_parent(&input_parent));
Loading