Skip to content
Snippets Groups Projects
Commit 12f26a90 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

TEST: Fixed Octave unit tests.

parent 4b7f7da5
No related branches found
No related tags found
1 merge request!3Full functionality of libcaosdb
Pipeline #12953 passed with warnings
Pipeline: caosdb-octaveinttest

#12954

    ......@@ -363,7 +363,7 @@ void assignEntityDataFromMx(ce::Entity &entity, const mxArray *array, const mwSi
    entity.SetDataType(dataTypeFromMx(mxGetField(array, index, "datatype")));
    entity.SetUnit(mxGetStdString(mxGetField(array, index, "unit")));
    entity.SetValue(valueFromMx(mxGetField(array, index, "value")));
    if (entity.GetRole() == ce::Role::FILE) { // This is necessary until caosdb-server#174 is fixed.
    if (entity.GetRole() == ce::Role::FILE) { // This is necessary until caosdb-server#174 is fixed.
    entity.SetFilePath(mxGetStdString(mxGetField(array, index, "filepath")));
    entity.SetLocalPath(mxGetStdString(mxGetField(array, index, "localpath")));
    }
    ......@@ -514,28 +514,28 @@ auto valueFromMx(const mxArray *array) -> caosdb::entity::Value {
    }
    array = mxGetCell(array, 0);
    numel = mxGetNumberOfElements(array);
    if (mxIsCell(array)) { // string cell array
    if (mxIsCell(array)) { // string cell array
    auto content = std::vector<string>(numel);
    for (size_t i = 0; i < numel; ++i) {
    auto value = mxGetStdString(mxGetCell(array, i));
    content[i] = value;
    }
    result = Value(content);
    } else if (mxIsLogical(array)) { // bool
    } else if (mxIsLogical(array)) { // bool
    auto content = std::vector<bool>(numel);
    auto data = static_cast<bool *>(mxGetData(array));
    for (size_t i = 0; i < numel; ++i) {
    content[i] = data[i];
    }
    result = Value(content);
    } else if (mxIsInt64(array)) { // int
    } else if (mxIsInt64(array)) { // int
    auto content = std::vector<INT64_T>(numel);
    auto data = static_cast<INT64_T *>(mxGetData(array));
    for (size_t i = 0; i < numel; ++i) {
    content[i] = data[i];
    }
    result = Value(content);
    } else if (mxIsDouble(array)) { // double
    } else if (mxIsDouble(array)) { // double
    auto content = std::vector<double>(numel);
    auto data = static_cast<double *>(mxGetData(array));
    for (size_t i = 0; i < numel; ++i) {
    ......@@ -547,15 +547,15 @@ auto valueFromMx(const mxArray *array) -> caosdb::entity::Value {
    boost::lexical_cast<std::string>((mxGetClassID(array))) + ")");
    }
    } else { // scalar value (no cell array)
    if (mxIsChar(array)) { // string
    if (mxIsChar(array)) { // string
    result = Value(mxGetStdString(array));
    } else if (mxIsLogical(array)) { // bool
    } else if (mxIsLogical(array)) { // bool
    auto data = *static_cast<bool *>(mxGetData(array));
    result = Value(data);
    } else if (mxIsInt64(array)) { // int
    } else if (mxIsInt64(array)) { // int
    auto data = *static_cast<INT64_T *>(mxGetData(array));
    result = Value(data);
    } else if (mxIsDouble(array)) { // double
    } else if (mxIsDouble(array)) { // double
    auto data = *static_cast<double *>(mxGetData(array));
    result = Value(data);
    } else {
    ......
    ......@@ -46,7 +46,7 @@ function test_entity_conversion()
    p1.name = "Prop 1";
    p1.description = "";
    p1.importance = "somewhat";
    p1.datatype = "DOUBLE";
    p1.set_datatype("DOUBLE");
    p1.unit = "Mt";
    p1.value = [];
    ......@@ -55,7 +55,7 @@ function test_entity_conversion()
    p2.name = "Prop 2";
    p2.description = "";
    p2.importance = "very";
    p2.datatype = "BOOLEAN";
    p2.set_datatype("BOOLEAN");
    p2.value = 1;
    par = 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