diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6c53e81 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + build-and-test: + name: macOS / C++23 / CTest + runs-on: macos-26 + timeout-minutes: 10 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Configure + run: | + cmake -S . -B build \ + -DDSA_ENABLE_TESTS=ON \ + -DDSA_ENABLE_WARNINGS=ON \ + -DCMAKE_BUILD_TYPE=Release + + - name: Build + run: cmake --build build --parallel + + - name: Run automated tests + run: ctest --test-dir build --output-on-failure --no-tests=error \ No newline at end of file diff --git a/src/algorithms/counting_sort.cpp b/src/algorithms/counting_sort.cpp index 6455bd8..4ab4d01 100644 --- a/src/algorithms/counting_sort.cpp +++ b/src/algorithms/counting_sort.cpp @@ -1,5 +1,7 @@ #include "algorithms/counting_sort.hpp" +#include + namespace { int digit_at(int value, int exponent) { diff --git a/src/algorithms/radix_sort.cpp b/src/algorithms/radix_sort.cpp index 16477e5..b0515cf 100644 --- a/src/algorithms/radix_sort.cpp +++ b/src/algorithms/radix_sort.cpp @@ -2,6 +2,8 @@ #include "algorithms/counting_sort.hpp" +#include + namespace dsa::algorithms { void radix_sort( diff --git a/src/data_structures/direct_access_table.cpp b/src/data_structures/direct_access_table.cpp index 8f511f1..0486c00 100644 --- a/src/data_structures/direct_access_table.cpp +++ b/src/data_structures/direct_access_table.cpp @@ -85,11 +85,7 @@ void DirectAccessTable::direct_access_insert(Node* x) { throw std::invalid_argument("x cannot be a null pointer"); } - if (x->key < 0) { - throw std::invalid_argument("Key cannot be negative"); - } - - if (static_cast(x->key) >= capacity_) { + if (x->key >= capacity_) { throw std::out_of_range("Key is outside the table range"); } @@ -100,10 +96,6 @@ void DirectAccessTable::direct_access_delete(Node* x) { if (x == nullptr) { throw std::invalid_argument("x cannot be a null pointer"); } - - if (x->key < 0) { - throw std::invalid_argument("Key cannot be negative"); - } if (static_cast(x->key) >= capacity_) { throw std::out_of_range("Key is outside the table range"); diff --git a/src/data_structures/static_hash_chained_table.cpp b/src/data_structures/static_hash_chained_table.cpp index 2c799c5..4a8f9df 100644 --- a/src/data_structures/static_hash_chained_table.cpp +++ b/src/data_structures/static_hash_chained_table.cpp @@ -229,6 +229,8 @@ std::size_t StaticHashChainedTable::hash_function(std::size_t k) const { case HashFunctionType::MultiplyShift: return multiply_shift_hash(k); } + + throw std::logic_error("Unknown hash function type"); } } // namespace dsa::data_structures \ No newline at end of file