From 5f3c20b5b725ae05ec54ee07b9dfd4672f7a0ca9 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Wed, 13 Mar 2024 17:37:31 +0100 Subject: [PATCH] :sparkles: (File): Read input in int16 type --- include/interface/platform/File.h | 2 ++ libs/FileManagerKit/include/FileManagerKit.h | 2 ++ libs/FileManagerKit/source/File.cpp | 5 +++++ tests/unit/mocks/mocks/leka/File.h | 2 ++ 4 files changed, 11 insertions(+) diff --git a/include/interface/platform/File.h b/include/interface/platform/File.h index b991d7e40b..df16153fc1 100644 --- a/include/interface/platform/File.h +++ b/include/interface/platform/File.h @@ -21,6 +21,8 @@ struct File { virtual auto read(std::span buffer) -> std::size_t = 0; virtual auto write(std::span data) -> std::size_t = 0; + virtual auto read(std::span buffer) -> std::size_t = 0; + virtual auto read(std::span buffer) -> std::size_t = 0; virtual auto write(std::span data) -> std::size_t = 0; diff --git a/libs/FileManagerKit/include/FileManagerKit.h b/libs/FileManagerKit/include/FileManagerKit.h index b519adeddc..75fe88c64c 100644 --- a/libs/FileManagerKit/include/FileManagerKit.h +++ b/libs/FileManagerKit/include/FileManagerKit.h @@ -25,6 +25,8 @@ struct File : public interface::File, public mbed::NonCopyable { auto read(std::span buffer) -> std::size_t final; auto write(std::span data) -> std::size_t final; + auto read(std::span buffer) -> std::size_t final; + auto read(std::span buffer) -> std::size_t final; auto write(std::span data) -> std::size_t final; diff --git a/libs/FileManagerKit/source/File.cpp b/libs/FileManagerKit/source/File.cpp index ba30698850..35bcfdba53 100644 --- a/libs/FileManagerKit/source/File.cpp +++ b/libs/FileManagerKit/source/File.cpp @@ -60,6 +60,11 @@ auto File::read(std::span buffer) -> std::size_t return std::fread(buffer.data(), sizeof(uint8_t), buffer.size(), _file.get()); } +auto File::read(std::span buffer) -> std::size_t +{ + return std::fread(buffer.data(), sizeof(int16_t), buffer.size(), _file.get()); +} + auto File::write(std::span data) -> std::size_t { return std::fwrite(data.data(), sizeof(uint8_t), data.size(), _file.get()); diff --git a/tests/unit/mocks/mocks/leka/File.h b/tests/unit/mocks/mocks/leka/File.h index eab081d9be..87c14adbcd 100644 --- a/tests/unit/mocks/mocks/leka/File.h +++ b/tests/unit/mocks/mocks/leka/File.h @@ -27,6 +27,8 @@ class File : public interface::File MOCK_METHOD(size_t, read, (std::span), (override)); MOCK_METHOD(size_t, write, (std::span), (override)); + MOCK_METHOD(size_t, read, (std::span), (override)); + MOCK_METHOD(size_t, read, (uint8_t *, uint32_t), (override)); MOCK_METHOD(size_t, write, (const uint8_t *, uint32_t), (override));