Skip to content

Commit

Permalink
updated tests BaseStore realloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad1991 committed May 27, 2024
1 parent 714d5b8 commit e65f42b
Show file tree
Hide file tree
Showing 175 changed files with 28,069 additions and 7 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: C/C++ CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: configure
run: |
cmake -B ./tests/build/ .
cmake --build ./tests/build/
- name: Run tests
run: |
cd ./tests/build
./BaseStore_Tests
10 changes: 3 additions & 7 deletions include/etr_bits/Core/BaseStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ template <typename T, typename BaseTrait> struct BaseStore {
#ifdef STANDALONE_ETR
#else
BaseStore(SEXP s) {
// TODO: check if SEXP is REAL or INTEGER or LOGICAL
if (allocated) {
ass(p != nullptr, "try to delete nullptr");
delete[] p;
Expand All @@ -75,7 +76,7 @@ template <typename T, typename BaseTrait> struct BaseStore {
ass(sz_ > 0, "Size has to be larger than 0");
p = new T[capacity];
for (std::size_t i = 0; i < capacity; i++) {
p[i] = 0.0;
p[i] = T();
}
allocated = true;
}
Expand All @@ -85,18 +86,13 @@ template <typename T, typename BaseTrait> struct BaseStore {
ass(sz_ > 0, "Size has to be larger than 0");
p = new T[capacity];
for (std::size_t i = 0; i < sz; i++)
p[i] = 0.0;
p[i] = T();
allocated = true;
}
BaseStore() {
/*
// TODO: check why this is called sometimes. Furthermore, add the same
functionality default size = 0 to other containers sz = 1; capacity = 1; p =
new T[capacity]; if constexpr (std::is_same_v<T, BaseType>) { p[0] = 0.0; }
else if constexpr (std::is_same_v<T, bool>) { p[0] = false;
}
allocated = true;
mp.setMatrix(false, 0, 0);
*/
}
BaseStore(std::size_t r, std::size_t c) = delete;
Expand Down
Binary file added tests/build/BaseStore_Tests
Binary file not shown.
Binary file added tests/build/BinaryOperations_Tests
Binary file not shown.
Loading

0 comments on commit e65f42b

Please sign in to comment.