diff --git a/include/SFML/Graphics/Transform.hpp b/include/SFML/Graphics/Transform.hpp index 8ccf091fe..8d9182462 100644 --- a/include/SFML/Graphics/Transform.hpp +++ b/include/SFML/Graphics/Transform.hpp @@ -33,6 +33,8 @@ #include +#include + namespace sf { @@ -267,10 +269,10 @@ private: // Member data //////////////////////////////////////////////////////////// // clang-format off - float m_matrix[16]{1.f, 0.f, 0.f, 0.f, - 0.f, 1.f, 0.f, 0.f, - 0.f, 0.f, 1.f, 0.f, - 0.f, 0.f, 0.f, 1.f}; //!< 4x4 matrix defining the transformation + std::array m_matrix{1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f}; //!< 4x4 matrix defining the transformation // clang-format off }; diff --git a/include/SFML/Graphics/Transform.inl b/include/SFML/Graphics/Transform.inl index 945c1d615..6aee63b2d 100644 --- a/include/SFML/Graphics/Transform.inl +++ b/include/SFML/Graphics/Transform.inl @@ -55,7 +55,7 @@ constexpr Transform::Transform(float a00, float a01, float a02, //////////////////////////////////////////////////////////// constexpr const float* Transform::getMatrix() const { - return m_matrix; + return m_matrix.data(); } @@ -133,8 +133,8 @@ constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const //////////////////////////////////////////////////////////// constexpr Transform& Transform::combine(const Transform& transform) { - const float* a = m_matrix; - const float* b = transform.m_matrix; + const auto& a = m_matrix; + const auto& b = transform.m_matrix; // clang-format off *this = Transform(a[0] * b[0] + a[4] * b[1] + a[12] * b[3], diff --git a/include/SFML/System/Utf.hpp b/include/SFML/System/Utf.hpp index f0759f2ec..8773af89d 100644 --- a/include/SFML/System/Utf.hpp +++ b/include/SFML/System/Utf.hpp @@ -29,6 +29,7 @@ //////////////////////////////////////////////////////////// #include +#include #include #include diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index be072f6e5..4bdf48632 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -56,7 +56,7 @@ In Utf<8>::decode(In begin, In end, std::uint32_t& output, std::uint32_t replace { // clang-format off // Some useful precomputed data - static constexpr int trailing[256] = + static constexpr std::array trailing = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -68,14 +68,14 @@ In Utf<8>::decode(In begin, In end, std::uint32_t& output, std::uint32_t replace 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; - static constexpr std::uint32_t offsets[6] = + static constexpr std::array offsets = { 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080 }; // clang-format on // decode the character - const int trailingBytes = trailing[static_cast(*begin)]; + const auto trailingBytes = trailing[static_cast(*begin)]; if (trailingBytes < std::distance(begin, end)) { output = 0; @@ -110,7 +110,7 @@ template Out Utf<8>::encode(std::uint32_t input, Out output, std::uint8_t replacement) { // Some useful precomputed data - static constexpr std::uint8_t firstBytes[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; + static constexpr std::array firstBytes = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; // encode the character if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF))) @@ -134,7 +134,7 @@ Out Utf<8>::encode(std::uint32_t input, Out output, std::uint8_t replacement) // clang-format on // Extract the bytes to write - std::byte bytes[4]; + std::array bytes{}; // clang-format off switch (bytestoWrite) @@ -147,7 +147,7 @@ Out Utf<8>::encode(std::uint32_t input, Out output, std::uint8_t replacement) // clang-format on // Add them to the output - output = priv::copy(bytes, bytes + bytestoWrite, output); + output = priv::copy(bytes.data(), bytes.data() + bytestoWrite, output); } return output; diff --git a/src/SFML/Audio/SoundFileWriterOgg.hpp b/src/SFML/Audio/SoundFileWriterOgg.hpp index 50cf05b4c..7e9ce98e3 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.hpp +++ b/src/SFML/Audio/SoundFileWriterOgg.hpp @@ -31,6 +31,7 @@ #include +#include #include #include @@ -103,12 +104,12 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - unsigned int m_channelCount{}; //!< Channel count of the sound being written - std::size_t m_remapTable[8]{}; //!< Table we use to remap source to target channel order - std::ofstream m_file; //!< Output file - ogg_stream_state m_ogg{}; //!< OGG stream - vorbis_info m_vorbis{}; //!< Vorbis handle - vorbis_dsp_state m_state{}; //!< Current encoding state + unsigned int m_channelCount{}; //!< Channel count of the sound being written + std::array m_remapTable{}; //!< Table we use to remap source to target channel order + std::ofstream m_file; //!< Output file + ogg_stream_state m_ogg{}; //!< OGG stream + vorbis_info m_vorbis{}; //!< Vorbis handle + vorbis_dsp_state m_state{}; //!< Current encoding state }; } // namespace sf::priv diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index 9af6e43fe..d7fdaf8fd 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -45,25 +46,25 @@ namespace void encode(std::ostream& stream, std::int16_t value) { - const std::byte bytes[] = {static_cast(value & 0xFF), static_cast(value >> 8)}; - stream.write(reinterpret_cast(bytes), sizeof(bytes)); + const std::array bytes = {static_cast(value & 0xFF), static_cast(value >> 8)}; + stream.write(bytes.data(), bytes.size()); } void encode(std::ostream& stream, std::uint16_t value) { - const std::byte bytes[] = {static_cast(value & 0xFF), static_cast(value >> 8)}; - stream.write(reinterpret_cast(bytes), sizeof(bytes)); + const std::array bytes = {static_cast(value & 0xFF), static_cast(value >> 8)}; + stream.write(bytes.data(), bytes.size()); } void encode(std::ostream& stream, std::uint32_t value) { - const std::byte bytes[] = { - static_cast(value & 0x000000FF), - static_cast((value & 0x0000FF00) >> 8), - static_cast((value & 0x00FF0000) >> 16), - static_cast((value & 0xFF000000) >> 24), + const std::array bytes = { + static_cast(value & 0x000000FF), + static_cast((value & 0x0000FF00) >> 8), + static_cast((value & 0x00FF0000) >> 16), + static_cast((value & 0xFF000000) >> 24), }; - stream.write(reinterpret_cast(bytes), sizeof(bytes)); + stream.write(bytes.data(), bytes.size()); } } // namespace @@ -247,17 +248,17 @@ void SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann assert(m_file.good() && "Most recent I/O operation failed"); // Write the main chunk ID - char mainChunkId[4] = {'R', 'I', 'F', 'F'}; - m_file.write(mainChunkId, sizeof(mainChunkId)); + std::array mainChunkId = {'R', 'I', 'F', 'F'}; + m_file.write(mainChunkId.data(), mainChunkId.size()); // Write the main chunk header encode(m_file, static_cast(0)); // 0 is a placeholder, will be written later - char mainChunkFormat[4] = {'W', 'A', 'V', 'E'}; - m_file.write(mainChunkFormat, sizeof(mainChunkFormat)); + std::array mainChunkFormat = {'W', 'A', 'V', 'E'}; + m_file.write(mainChunkFormat.data(), mainChunkFormat.size()); // Write the sub-chunk 1 ("format") id and size - char fmtChunkId[4] = {'f', 'm', 't', ' '}; - m_file.write(fmtChunkId, sizeof(fmtChunkId)); + std::array fmtChunkId = {'f', 'm', 't', ' '}; + m_file.write(fmtChunkId.data(), fmtChunkId.size()); if (channelCount > 2) { @@ -295,14 +296,14 @@ void SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann encode(m_file, bitsPerSample); encode(m_file, channelMask); // Write the subformat (PCM) - char subformat[16] = + std::array subformat = {'\x01', '\x00', '\x00', '\x00', '\x00', '\x00', '\x10', '\x00', '\x80', '\x00', '\x00', '\xAA', '\x00', '\x38', '\x9B', '\x71'}; - m_file.write(subformat, sizeof(subformat)); + m_file.write(subformat.data(), subformat.size()); } // Write the sub-chunk 2 ("data") id and size - char dataChunkId[4] = {'d', 'a', 't', 'a'}; - m_file.write(dataChunkId, sizeof(dataChunkId)); + std::array dataChunkId = {'d', 'a', 't', 'a'}; + m_file.write(dataChunkId.data(), dataChunkId.size()); const std::uint32_t dataChunkSize = 0; // placeholder, will be written later encode(m_file, dataChunkSize); } diff --git a/src/SFML/Audio/SoundFileWriterWav.hpp b/src/SFML/Audio/SoundFileWriterWav.hpp index 4faf8f652..75f7c95ab 100644 --- a/src/SFML/Audio/SoundFileWriterWav.hpp +++ b/src/SFML/Audio/SoundFileWriterWav.hpp @@ -29,6 +29,7 @@ //////////////////////////////////////////////////////////// #include +#include #include #include @@ -105,9 +106,9 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - std::ofstream m_file; //!< File stream to write to - unsigned int m_channelCount{}; //!< Channel count of the sound being written - std::size_t m_remapTable[18]{}; //!< Table we use to remap source to target channel order + std::ofstream m_file; //!< File stream to write to + unsigned int m_channelCount{}; //!< Channel count of the sound being written + std::array m_remapTable{}; //!< Table we use to remap source to target channel order }; } // namespace sf::priv diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 113557515..dd933de10 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -861,10 +862,10 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType) if ((coordinateType == CoordinateType::Pixels) || texture->m_pixelsFlipped) { // clang-format off - GLfloat matrix[16] = {1.f, 0.f, 0.f, 0.f, - 0.f, 1.f, 0.f, 0.f, - 0.f, 0.f, 1.f, 0.f, - 0.f, 0.f, 0.f, 1.f}; + std::array matrix = {1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f}; // clang-format on // If non-normalized coordinates (= pixels) are requested, we need to @@ -884,7 +885,7 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType) // Load the matrix glCheck(glMatrixMode(GL_TEXTURE)); - glCheck(glLoadMatrixf(matrix)); + glCheck(glLoadMatrixf(matrix.data())); } else { diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index 498c14677..e639c049a 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include #include @@ -212,8 +214,8 @@ Packet& Packet::operator>>(std::uint64_t& data) { // Since ntohll is not available everywhere, we have to convert // to network byte order (big endian) manually - std::byte bytes[sizeof(data)]; - std::memcpy(bytes, &m_data[m_readPos], sizeof(data)); + std::array bytes{}; + std::memcpy(bytes.data(), &m_data[m_readPos], sizeof(data)); data = toInteger(bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]); @@ -427,14 +429,14 @@ Packet& Packet::operator<<(std::int64_t data) // Since htonll is not available everywhere, we have to convert // to network byte order (big endian) manually - std::uint8_t toWrite[] = {static_cast((data >> 56) & 0xFF), - static_cast((data >> 48) & 0xFF), - static_cast((data >> 40) & 0xFF), - static_cast((data >> 32) & 0xFF), - static_cast((data >> 24) & 0xFF), - static_cast((data >> 16) & 0xFF), - static_cast((data >> 8) & 0xFF), - static_cast((data)&0xFF)}; + std::array toWrite = {static_cast((data >> 56) & 0xFF), + static_cast((data >> 48) & 0xFF), + static_cast((data >> 40) & 0xFF), + static_cast((data >> 32) & 0xFF), + static_cast((data >> 24) & 0xFF), + static_cast((data >> 16) & 0xFF), + static_cast((data >> 8) & 0xFF), + static_cast((data)&0xFF)}; append(&toWrite, sizeof(toWrite)); return *this; @@ -447,14 +449,14 @@ Packet& Packet::operator<<(std::uint64_t data) // Since htonll is not available everywhere, we have to convert // to network byte order (big endian) manually - std::uint8_t toWrite[] = {static_cast((data >> 56) & 0xFF), - static_cast((data >> 48) & 0xFF), - static_cast((data >> 40) & 0xFF), - static_cast((data >> 32) & 0xFF), - static_cast((data >> 24) & 0xFF), - static_cast((data >> 16) & 0xFF), - static_cast((data >> 8) & 0xFF), - static_cast((data)&0xFF)}; + std::array toWrite = {static_cast((data >> 56) & 0xFF), + static_cast((data >> 48) & 0xFF), + static_cast((data >> 40) & 0xFF), + static_cast((data >> 32) & 0xFF), + static_cast((data >> 24) & 0xFF), + static_cast((data >> 16) & 0xFF), + static_cast((data >> 8) & 0xFF), + static_cast((data)&0xFF)}; append(&toWrite, sizeof(toWrite)); return *this; diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 31a6249e0..fb24f2f16 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -401,12 +402,12 @@ Socket::Status TcpSocket::receive(Packet& packet) } // Loop until we receive all the packet data - char buffer[1024]; + std::array buffer{}; while (m_pendingPacket.data.size() < packetSize) { // Receive a chunk of data const std::size_t sizeToGet = std::min(packetSize - m_pendingPacket.data.size(), sizeof(buffer)); - const Status status = receive(buffer, sizeToGet, received); + const Status status = receive(buffer.data(), sizeToGet, received); if (status != Status::Done) return status; @@ -415,7 +416,7 @@ Socket::Status TcpSocket::receive(Packet& packet) { m_pendingPacket.data.resize(m_pendingPacket.data.size() + received); std::byte* begin = m_pendingPacket.data.data() + m_pendingPacket.data.size() - received; - std::memcpy(begin, buffer, received); + std::memcpy(begin, buffer.data(), received); } } diff --git a/src/SFML/Window/JoystickImpl.hpp b/src/SFML/Window/JoystickImpl.hpp index 7ef509bc9..350a3fdf9 100644 --- a/src/SFML/Window/JoystickImpl.hpp +++ b/src/SFML/Window/JoystickImpl.hpp @@ -55,7 +55,7 @@ struct JoystickState { bool connected{}; //!< Is the joystick currently connected? EnumArray axes{}; //!< Position of each axis, in range [-100, 100] - bool buttons[Joystick::ButtonCount]{}; //!< Status of each button (true = pressed) + std::array buttons{}; //!< Status of each button (true = pressed) }; } // namespace sf::priv diff --git a/src/SFML/Window/JoystickManager.hpp b/src/SFML/Window/JoystickManager.hpp index a26ceaf5e..585b3ddf4 100644 --- a/src/SFML/Window/JoystickManager.hpp +++ b/src/SFML/Window/JoystickManager.hpp @@ -30,6 +30,8 @@ #include #include +#include + namespace sf::priv { @@ -124,7 +126,7 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - Item m_joysticks[Joystick::Count]; //!< Joysticks information and state + std::array m_joysticks; //!< Joysticks information and state }; } // namespace sf::priv diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp index 842d43338..1f1629f8d 100644 --- a/src/SFML/Window/Unix/GlxContext.cpp +++ b/src/SFML/Window/Unix/GlxContext.cpp @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -513,10 +514,10 @@ void GlxContext::createSurface(GlxContext* shared, const Vector2u& size, unsigne if (config) { - int attributes[] = + std::array attributes = {GLX_PBUFFER_WIDTH, static_cast(size.x), GLX_PBUFFER_HEIGHT, static_cast(size.y), 0, 0}; - m_pbuffer = glXCreatePbuffer(m_display.get(), *config, attributes); + m_pbuffer = glXCreatePbuffer(m_display.get(), *config, attributes.data()); updateSettingsFromVisualInfo(&visualInfo); @@ -578,11 +579,11 @@ void GlxContext::createContext(GlxContext* shared) glXQueryDrawable(m_display.get(), m_pbuffer, GLX_FBCONFIG_ID, &fbConfigId); - int attributes[] = {GLX_FBCONFIG_ID, static_cast(fbConfigId), 0, 0}; + std::array attributes = {GLX_FBCONFIG_ID, static_cast(fbConfigId), 0, 0}; int count = 0; const auto fbconfig = X11Ptr( - glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), attributes, &count)); + glXChooseFBConfig(m_display.get(), DefaultScreen(m_display.get()), attributes.data(), &count)); if (count == 1) visualInfo = X11Ptr(glXGetVisualFromFBConfig(m_display.get(), *fbconfig)); diff --git a/src/SFML/Window/Unix/JoystickImpl.cpp b/src/SFML/Window/Unix/JoystickImpl.cpp index 308037993..316898cf6 100644 --- a/src/SFML/Window/Unix/JoystickImpl.cpp +++ b/src/SFML/Window/Unix/JoystickImpl.cpp @@ -400,14 +400,13 @@ std::string getJoystickName(unsigned int index) if (fd >= 0) { // Get the name - char name[128] = {}; - - const int result = ioctl(fd, JSIOCGNAME(sizeof(name)), name); + std::array name{}; + const int result = ioctl(fd, JSIOCGNAME(name.size()), name.data()); ::close(fd); if (result >= 0) - return name; + return name.data(); } // Fall back to manual USB chain walk via udev @@ -600,7 +599,7 @@ JoystickCaps JoystickImpl::getCapabilities() const ioctl(m_file, JSIOCGAXES, &axesCount); for (int i = 0; i < axesCount; ++i) { - switch (m_mapping[i]) + switch (m_mapping[static_cast(i)]) { // clang-format off case ABS_X: caps.axes[Joystick::Axis::X] = true; break; @@ -650,7 +649,7 @@ JoystickState JoystickImpl::JoystickImpl::update() { const float value = joyState.value * 100.f / 32767.f; - if (joyState.number < ABS_MAX + 1) + if (joyState.number < m_mapping.size()) { switch (m_mapping[joyState.number]) { diff --git a/src/SFML/Window/Unix/JoystickImpl.hpp b/src/SFML/Window/Unix/JoystickImpl.hpp index b65b9a0f2..843b983c5 100644 --- a/src/SFML/Window/Unix/JoystickImpl.hpp +++ b/src/SFML/Window/Unix/JoystickImpl.hpp @@ -105,10 +105,10 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - int m_file{-1}; ///< File descriptor of the joystick - char m_mapping[ABS_MAX + 1]{0}; ///< Axes mapping (index to axis id) - JoystickState m_state; ///< Current state of the joystick - Joystick::Identification m_identification; ///< Identification of the joystick + int m_file{-1}; ///< File descriptor of the joystick + std::array m_mapping{}; ///< Axes mapping (index to axis id) + JoystickState m_state; ///< Current state of the joystick + Joystick::Identification m_identification; ///< Identification of the joystick }; } // namespace sf::priv diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 8306f9abb..c903a7f87 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -96,7 +97,7 @@ namespace sf::priv //////////////////////////////////////////////////////////// struct WindowImpl::JoystickStatesImpl { - JoystickState states[Joystick::Count]{}; //!< Previous state of the joysticks + std::array states{}; //!< Previous state of the joysticks }; diff --git a/src/SFML/Window/macOS/HIDJoystickManager.cpp b/src/SFML/Window/macOS/HIDJoystickManager.cpp index 0589bdd18..3c05db8cc 100644 --- a/src/SFML/Window/macOS/HIDJoystickManager.cpp +++ b/src/SFML/Window/macOS/HIDJoystickManager.cpp @@ -29,6 +29,8 @@ #include #include +#include + //////////////////////////////////////////////////////////// // Private data //////////////////////////////////////////////////////////// @@ -75,11 +77,8 @@ HIDJoystickManager::HIDJoystickManager() CFDictionaryRef mask1 = HIDInputManager::copyDevicesMask(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad); - CFDictionaryRef maskArray[2]; - maskArray[0] = mask0; - maskArray[1] = mask1; - - CFArrayRef mask = CFArrayCreate(nullptr, reinterpret_cast(maskArray), 2, nullptr); + std::array maskArray = {mask0, mask1}; + CFArrayRef mask = CFArrayCreate(nullptr, reinterpret_cast(maskArray.data()), maskArray.size(), nullptr); IOHIDManagerSetDeviceMatchingMultiple(m_manager, mask); CFRelease(mask); diff --git a/src/SFML/Window/macOS/JoystickImpl.hpp b/src/SFML/Window/macOS/JoystickImpl.hpp index 6c411f27b..d998a1a10 100644 --- a/src/SFML/Window/macOS/JoystickImpl.hpp +++ b/src/SFML/Window/macOS/JoystickImpl.hpp @@ -121,7 +121,7 @@ private: Joystick::Identification m_identification; ///< Joystick identification // NOLINTNEXTLINE(readability-identifier-naming) - static inline Location m_locationIDs[Joystick::Count]{}; ///< Global Joystick register + static inline std::array m_locationIDs{}; ///< Global Joystick register /// For a corresponding SFML index, m_locationIDs is either some USB /// location or 0 if there isn't currently a connected joystick device }; diff --git a/test/System/MemoryInputStream.test.cpp b/test/System/MemoryInputStream.test.cpp index 06a12fddd..5b5845d65 100644 --- a/test/System/MemoryInputStream.test.cpp +++ b/test/System/MemoryInputStream.test.cpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -32,9 +33,9 @@ TEST_CASE("[System] sf::MemoryInputStream") sf::MemoryInputStream mis; mis.open(memoryContents.data(), sizeof(char) * memoryContents.size()); - char buffer[32]; - CHECK(mis.read(buffer, 5) == 5); - CHECK(std::string_view(buffer, 5) == std::string_view(memoryContents.data(), 5)); + std::array buffer{}; + CHECK(mis.read(buffer.data(), 5) == 5); + CHECK(std::string_view(buffer.data(), 5) == std::string_view(memoryContents.data(), 5)); CHECK(mis.seek(10) == 10); CHECK(mis.tell() == 10); CHECK(mis.getSize() == 11);