openMSL / sl-1-0-sensor-model-repository-template

Template repository: Clone and build your ASAM OSI sensor model.
Mozilla Public License 2.0
8 stars 2 forks source link

Added test framework #24

Closed ClemensLinnhoff closed 1 year ago

ClemensLinnhoff commented 1 year ago

Reference to a related issue in the repository Fixes #17

Add a description Added google test framework and created an exemplary unit test for the coordinate transform.

Take this checklist as orientation for yourself, if this PR is ready for Maintainer Review

github-actions[bot] commented 1 year ago

:speech_balloon: Output from clang-tidy

src/HelloWorldSensor.cpp
/src/HelloWorldSensor.cpp:60:5: warning: [cppcoreguidelines-pro-type-member-init] > uninitialized record type: 'myaddr'

```cpp union Addrconv ^ ```

/src/HelloWorldSensor.cpp:69:12: warning: [cppcoreguidelines-pro-type-union-access] > do not access members of unions; use (boost::)variant instead

```cpp myaddr.base.lo = lo; ^ ```

/src/HelloWorldSensor.cpp:70:12: warning: [cppcoreguidelines-pro-type-union-access] > do not access members of unions; use (boost::)variant instead

```cpp myaddr.base.hi = hi; ^ ```

/src/HelloWorldSensor.cpp:71:12: warning: [cppcoreguidelines-pro-type-reinterpret-cast] > do not use reinterpret_cast

```cpp return reinterpret_cast(myaddr.address); ^ ```

/src/HelloWorldSensor.cpp:71:43: warning: [cppcoreguidelines-pro-type-union-access] > do not access members of unions; use (boost::)variant instead

```cpp return reinterpret_cast(myaddr.address); ^ ```

/src/HelloWorldSensor.cpp:82:5: warning: [cppcoreguidelines-pro-type-member-init] > uninitialized record type: 'myaddr'

```cpp union Addrconv ^ ```

/src/HelloWorldSensor.cpp:91:12: warning: [cppcoreguidelines-pro-type-union-access] > do not access members of unions; use (boost::)variant instead

```cpp myaddr.address = reinterpret_cast(ptr); ^ ```

/src/HelloWorldSensor.cpp:91:22: warning: [cppcoreguidelines-pro-type-reinterpret-cast] > do not use reinterpret_cast

```cpp myaddr.address = reinterpret_cast(ptr); ^ ```

/src/HelloWorldSensor.cpp:92:17: warning: [cppcoreguidelines-pro-type-union-access] > do not access members of unions; use (boost::)variant instead

```cpp hi = myaddr.base.hi; ^ ```

/src/HelloWorldSensor.cpp:93:17: warning: [cppcoreguidelines-pro-type-union-access] > do not access members of unions; use (boost::)variant instead

```cpp lo = myaddr.base.lo; ^ ```

/src/HelloWorldSensor.cpp:231:30: warning: [readability-convert-member-functions-to-static] > method 'DoStart' can be made static

```cpp fmi2Status HelloWorldSensor::DoStart(fmi2Boolean tolerance_defined, fmi2Real tolerance, fmi2Real start_time, fmi2Boolean stop_time_defined, fmi2Real stop_time) ^ ```

/src/HelloWorldSensor.cpp:236:30: warning: [readability-convert-member-functions-to-static] > method 'DoEnterInitializationMode' can be made static

```cpp fmi2Status HelloWorldSensor::DoEnterInitializationMode() ^ ```

/src/HelloWorldSensor.cpp:273:13: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp matrix_trans[j][i] = matrix_in[i][j]; ^ ```

/src/HelloWorldSensor.cpp:273:34: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp matrix_trans[j][i] = matrix_in[i][j]; ^ ```

/src/HelloWorldSensor.cpp:299:29: warning: [cppcoreguidelines-pro-bounds-array-to-pointer-decay] > do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead

```cpp TransposeRotationMatrix(matrix, matrix_trans); ^ ```

/src/HelloWorldSensor.cpp:299:37: warning: [cppcoreguidelines-pro-bounds-array-to-pointer-decay] > do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead

```cpp TransposeRotationMatrix(matrix, matrix_trans); ^ ```

/src/HelloWorldSensor.cpp:369:80: warning: [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] > 0.866025 is a magic number; consider replacing it with a named constant

```cpp if ((distance <= actual_range) && (rel_x / distance > 0.866025)) ^ ```

/src/HelloWorldSensor.cpp:374:84: warning: [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] > 2.0 is a magic number; consider replacing it with a named constant

```cpp obj->mutable_header()->set_existence_probability(cos((2.0 * distance - actual_range) / actual_range)); ^ ```

/src/HelloWorldSensor.cpp:447:30: warning: [readability-convert-member-functions-to-static] > method 'DoTerm' can be made static

```cpp fmi2Status HelloWorldSensor::DoTerm() ^ ```

/src/HelloWorldSensor.cpp:458:1: warning: [cppcoreguidelines-pro-type-member-init] > constructor does not initialize these fields: boolean_vars_, integer_vars_, real_vars_

```cpp HelloWorldSensor::HelloWorldSensor(fmi2String theinstance_name, ^ ```

/src/HelloWorldSensor.cpp:525:5: warning: [cppcoreguidelines-owning-memory] > initializing non-owner 'HelloWorldSensor *' with a newly created 'gsl::owner<>'

```cpp auto* myc = new HelloWorldSensor(instance_name, fmu_type, fmu_guid, fmu_resource_location, functions, visible, logging_on); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```

/src/HelloWorldSensor.cpp:550:9: warning: [cppcoreguidelines-owning-memory] > deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead

```cpp delete myc; ^ ~~~ /home/runner/work/sl-1-0-sensor-model-repository-template/sl-1-0-sensor-model-repository-template/src/HelloWorldSensor.cpp:525:5: note: variable declared here auto* myc = new HelloWorldSensor(instance_name, fmu_type, fmu_guid, fmu_resource_location, functions, visible, logging_on); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```

/src/HelloWorldSensor.cpp:618:24: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp value[i] = real_vars_[vr[i]]; ^ ```

/src/HelloWorldSensor.cpp:642:24: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp value[i] = integer_vars_[vr[i]]; ^ ```

/src/HelloWorldSensor.cpp:659:24: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp value[i] = boolean_vars_[vr[i]]; ^ ```

/src/HelloWorldSensor.cpp:676:24: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp value[i] = string_vars_[vr[i]].c_str(); ^ ```

/src/HelloWorldSensor.cpp:693:13: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp real_vars_[vr[i]] = value[i]; ^ ```

/src/HelloWorldSensor.cpp:710:13: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp integer_vars_[vr[i]] = value[i]; ^ ```

/src/HelloWorldSensor.cpp:727:13: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp boolean_vars_[vr[i]] = value[i]; ^ ```

/src/HelloWorldSensor.cpp:744:13: warning: [cppcoreguidelines-pro-bounds-constant-array-index] > do not use array subscript when the index is not an integer constant expression

```cpp string_vars_[vr[i]] = value[i]; ^ ```

/src/HelloWorldSensor.cpp:834:5: warning: [cppcoreguidelines-owning-memory] > deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead

```cpp delete myc; ^ ~~~ /home/runner/work/sl-1-0-sensor-model-repository-template/sl-1-0-sensor-model-repository-template/src/HelloWorldSensor.cpp:832:5: note: variable declared here auto* myc = (HelloWorldSensor*)c; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```