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 authored and ladislas committed Aug 26, 2024
1 parent fa3b034 commit 5f3c20b
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
{
return std::fread(buffer.data(), sizeof(int16_t), buffer.size(), _file.get());
}

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 5f3c20b

Please sign in to comment.