mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Upgrade to C++20 (#4239)
* Use explicit this capture required by C++20 * Use C++20 span * Replace wpi::numbers with std::numbers * Fix C++20 clang-tidy warning false positive in fmt * Remove ciso646 include since C++20 removed that header * Fix global-buffer-overflow asan warnings in ntcore tests * Add DIOSetProxy constructor to HAL * Upgrade MSVC compiler to 2022 * Bump native-utils to 2023.2.7 (changes to std=c++20) Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -36,7 +36,7 @@ class MockNetworkStartupInterface : public NetworkStartupInterface {
|
||||
const wpi::json& properties, const PubSubOptions& options),
|
||||
(override));
|
||||
MOCK_METHOD(void, Subscribe,
|
||||
(NT_Subscriber subHandle, wpi::span<const std::string> prefixes,
|
||||
(NT_Subscriber subHandle, std::span<const std::string> prefixes,
|
||||
const PubSubOptions& options),
|
||||
(override));
|
||||
MOCK_METHOD(void, SetValue, (NT_Publisher pubHandle, const Value& value),
|
||||
@@ -57,7 +57,7 @@ class MockNetworkInterface : public NetworkInterface {
|
||||
const wpi::json& update),
|
||||
(override));
|
||||
MOCK_METHOD(void, Subscribe,
|
||||
(NT_Subscriber subHandle, wpi::span<const std::string> prefixes,
|
||||
(NT_Subscriber subHandle, std::span<const std::string> prefixes,
|
||||
const PubSubOptions& options),
|
||||
(override));
|
||||
MOCK_METHOD(void, Unsubscribe, (NT_Subscriber subHandle), (override));
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "net/WireConnection.h"
|
||||
@@ -28,7 +28,7 @@ class MockWireConnection : public WireConnection {
|
||||
BinaryWriter SendBinary() override { return {m_binary_os, *this}; }
|
||||
|
||||
MOCK_METHOD(void, Text, (std::string_view contents));
|
||||
MOCK_METHOD(void, Binary, (wpi::span<const uint8_t> contents));
|
||||
MOCK_METHOD(void, Binary, (std::span<const uint8_t> contents));
|
||||
|
||||
MOCK_METHOD(void, Flush, (), (override));
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class MockClientMessageHandler : public net::ClientMessageHandler {
|
||||
MOCK_METHOD2(ClientSetProperties,
|
||||
void(std::string_view name, const wpi::json& update));
|
||||
MOCK_METHOD3(ClientSubscribe,
|
||||
void(int64_t subuid, wpi::span<const std::string> prefixes,
|
||||
void(int64_t subuid, std::span<const std::string> prefixes,
|
||||
const PubSubOptions& options));
|
||||
MOCK_METHOD1(ClientUnsubscribe, void(int64_t subuid));
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -65,7 +66,7 @@ TEST_F(WireEncoderTextTest, SetProperties) {
|
||||
}
|
||||
|
||||
TEST_F(WireEncoderTextTest, Subscribe) {
|
||||
net::WireEncodeSubscribe(os, 5, std::vector<std::string_view>{{"a", "b"}},
|
||||
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},
|
||||
PubSubOptions{});
|
||||
ASSERT_EQ(os.str(),
|
||||
"{\"method\":\"subscribe\",\"params\":{"
|
||||
@@ -75,7 +76,7 @@ TEST_F(WireEncoderTextTest, Subscribe) {
|
||||
TEST_F(WireEncoderTextTest, SubscribeSendAll) {
|
||||
PubSubOptions options;
|
||||
options.sendAll = true;
|
||||
net::WireEncodeSubscribe(os, 5, std::vector<std::string_view>{{"a", "b"}},
|
||||
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},
|
||||
options);
|
||||
ASSERT_EQ(os.str(),
|
||||
"{\"method\":\"subscribe\",\"params\":{"
|
||||
@@ -86,7 +87,7 @@ TEST_F(WireEncoderTextTest, SubscribeSendAll) {
|
||||
TEST_F(WireEncoderTextTest, SubscribePeriodic) {
|
||||
PubSubOptions options;
|
||||
options.periodic = 0.5;
|
||||
net::WireEncodeSubscribe(os, 5, std::vector<std::string_view>{{"a", "b"}},
|
||||
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},
|
||||
options);
|
||||
ASSERT_EQ(os.str(),
|
||||
"{\"method\":\"subscribe\",\"params\":{"
|
||||
@@ -98,7 +99,7 @@ TEST_F(WireEncoderTextTest, SubscribeAllOptions) {
|
||||
PubSubOptions options;
|
||||
options.sendAll = true;
|
||||
options.periodic = 0.5;
|
||||
net::WireEncodeSubscribe(os, 5, std::vector<std::string_view>{{"a", "b"}},
|
||||
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},
|
||||
options);
|
||||
ASSERT_EQ(os.str(),
|
||||
"{\"method\":\"subscribe\",\"params\":{"
|
||||
|
||||
Reference in New Issue
Block a user