Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ (File): Read input in int16 type #1421

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading