Skip to content

Commit

Permalink
✨ (File): Read input in int16 type
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Mar 14, 2024
1 parent 9da3fb3 commit 23cff2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/interface/platform/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ struct File {
virtual auto read(std::span<uint8_t> buffer) -> std::size_t = 0;
virtual auto write(std::span<uint8_t> data) -> std::size_t = 0;

virtual auto read(std::span<int16_t> buffer) -> std::size_t = 0;

virtual auto read(std::span<char> buffer) -> std::size_t = 0;
virtual auto write(std::span<char> data) -> std::size_t = 0;

Expand Down
2 changes: 2 additions & 0 deletions libs/FileManagerKit/include/FileManagerKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct File : public interface::File, public mbed::NonCopyable<File> {
auto read(std::span<uint8_t> buffer) -> std::size_t final;
auto write(std::span<uint8_t> data) -> std::size_t final;

auto read(std::span<int16_t> buffer) -> std::size_t final;

auto read(std::span<char> buffer) -> std::size_t final;
auto write(std::span<char> data) -> std::size_t final;

Expand Down
5 changes: 5 additions & 0 deletions libs/FileManagerKit/source/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ auto File::read(std::span<uint8_t> buffer) -> std::size_t
return std::fread(buffer.data(), sizeof(uint8_t), buffer.size(), _file.get());
}

auto File::read(std::span<int16_t> buffer) -> std::size_t

Check warning on line 63 in libs/FileManagerKit/source/File.cpp

View check run for this annotation

Codecov / codecov/patch

libs/FileManagerKit/source/File.cpp#L63

Added line #L63 was not covered by tests
{
return std::fread(buffer.data(), sizeof(int16_t), buffer.size(), _file.get());

Check warning on line 65 in libs/FileManagerKit/source/File.cpp

View check run for this annotation

Codecov / codecov/patch

libs/FileManagerKit/source/File.cpp#L65

Added line #L65 was not covered by tests
}

auto File::write(std::span<uint8_t> data) -> std::size_t
{
return std::fwrite(data.data(), sizeof(uint8_t), data.size(), _file.get());
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/mocks/mocks/leka/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class File : public interface::File
MOCK_METHOD(size_t, read, (std::span<char>), (override));
MOCK_METHOD(size_t, write, (std::span<char>), (override));

MOCK_METHOD(size_t, read, (std::span<int16_t>), (override));

MOCK_METHOD(size_t, read, (uint8_t *, uint32_t), (override));
MOCK_METHOD(size_t, write, (const uint8_t *, uint32_t), (override));

Expand Down

0 comments on commit 23cff2e

Please sign in to comment.