diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..de8caaa --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: runTests + +on: + push: + branches: [ master, main ] + pull_request: + workflow_dispatch: + +jobs: + build-and-test: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install cmake ninja + + - name: Configure (Linux / macOS) + if: runner.os != 'Windows' + run: | + cmake -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DESFA_BUILD_TESTS=ON + + - name: Configure (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cmake -B build ` + -DCMAKE_BUILD_TYPE=Release ` + -DESFA_BUILD_TESTS=ON + + - name: Build (Linux / macOS) + if: runner.os != 'Windows' + run: cmake --build build + + - name: Build (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: cmake --build build --config Release + + - name: Test (Linux / macOS) + if: runner.os != 'Windows' + run: ctest --test-dir build/test --output-on-failure + + - name: Test (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: ctest --test-dir build/test --build-config Release --output-on-failure diff --git a/include/esfa/esfa.hpp b/include/esfa/esfa.hpp index 190d513..fbde7f3 100644 --- a/include/esfa/esfa.hpp +++ b/include/esfa/esfa.hpp @@ -8,15 +8,9 @@ namespace esfa { class Processor { public: - explicit Processor(const interface::Registry& registry) - : mRegistry(registry) - { - } - - const interface::Registry& GetRegistry() - { - return mRegistry; - } + explicit Processor(const interface::Registry& registry) : mRegistry(registry) {} + + const interface::Registry& GetRegistry() const { return mRegistry; } std::shared_ptr ParseAsset( const std::string& typeKey, diff --git a/src/processing/binary/reader.cpp b/src/processing/binary/reader.cpp index 77deb62..677d59d 100644 --- a/src/processing/binary/reader.cpp +++ b/src/processing/binary/reader.cpp @@ -1,4 +1,3 @@ -#include #include #include "esfa/processing/binary/reader.hpp" @@ -128,7 +127,7 @@ uint64_t Reader::ReadUInt64() float Reader::ReadSingle() { - float result; + float result = 0.f; stream->Read((char*)&result, sizeof(float)); @@ -146,7 +145,7 @@ float Reader::ReadSingle() double Reader::ReadDouble() { - double result = NAN; + double result = 0.0; stream->Read((char*)&result, sizeof(double)); @@ -160,9 +159,6 @@ double Reader::ReadDouble() result = tmp; } - if (std::isnan(result)) - throw std::runtime_error("Reader::ReadDouble(): Error reading stream"); - return result; } diff --git a/src/processing/stream/memory_stream.cpp b/src/processing/stream/memory_stream.cpp index 0e0be41..026d585 100644 --- a/src/processing/stream/memory_stream.cpp +++ b/src/processing/stream/memory_stream.cpp @@ -67,13 +67,10 @@ void MemoryStream::Read(char* dest, size_t length) } if (mPosition + length > mBuffer.size()) { - std::string msg = - "MemoryStream::Read: position " + std::to_string(mPosition) + - " + length " + std::to_string(length) + - " = " + std::to_string(mPosition + length) + - " > buffer size " + std::to_string(mBuffer.size()); - - throw std::runtime_error(msg); + throw std::runtime_error( + "MemoryStream::Read: short read (past end of buffer) pos=" + + std::to_string(mPosition) + " len=" + std::to_string(length) + + " size=" + std::to_string(mBuffer.size())); } std::memcpy(dest, mBuffer.data() + mPosition, length); mPosition += length;