SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -17,19 +17,19 @@ class MoveOnlyType {
TEST(ArrayTest, CopyableTypeCompiles) {
[[maybe_unused]]
constexpr wpi::array<int, 3> arr1{1, 2, 3};
constexpr wpi::util::array<int, 3> arr1{1, 2, 3};
// Test deduction guide
[[maybe_unused]]
constexpr wpi::array arr2{1, 2, 3};
constexpr wpi::util::array arr2{1, 2, 3};
}
TEST(ArrayTest, MoveOnlyTypeCompiles) {
[[maybe_unused]]
constexpr wpi::array<MoveOnlyType, 3> arr1{MoveOnlyType{}, MoveOnlyType{},
constexpr wpi::util::array<MoveOnlyType, 3> arr1{MoveOnlyType{}, MoveOnlyType{},
MoveOnlyType{}};
// Test deduction guide
[[maybe_unused]]
constexpr wpi::array arr2{MoveOnlyType{}, MoveOnlyType{}, MoveOnlyType{}};
constexpr wpi::util::array arr2{MoveOnlyType{}, MoveOnlyType{}, MoveOnlyType{}};
}

View File

@@ -9,7 +9,7 @@
#include "wpi/util/Base64.hpp"
#include "wpi/util/SmallString.hpp"
namespace wpi {
namespace wpi::util {
struct Base64TestParam {
int plain_len;
@@ -102,4 +102,4 @@ static Base64TestParam standard[] = {
INSTANTIATE_TEST_SUITE_P(Base64StandardTests, Base64Test,
::testing::ValuesIn(standard));
} // namespace wpi
} // namespace wpi::util

View File

@@ -19,7 +19,7 @@ static const std::array<double, 8> pushBackOut = {
{342.657, 234.252, 716.126, 132.344, 445.697, 22.727, 421.125, 799.913}};
TEST(CircularBufferTest, PushFront) {
wpi::circular_buffer<double> queue(8);
wpi::util::circular_buffer<double> queue(8);
for (auto& value : values) {
queue.push_front(value);
@@ -31,7 +31,7 @@ TEST(CircularBufferTest, PushFront) {
}
TEST(CircularBufferTest, PushBack) {
wpi::circular_buffer<double> queue(8);
wpi::util::circular_buffer<double> queue(8);
for (auto& value : values) {
queue.push_back(value);
@@ -43,7 +43,7 @@ TEST(CircularBufferTest, PushBack) {
}
TEST(CircularBufferTest, EmplaceFront) {
wpi::circular_buffer<double> queue(8);
wpi::util::circular_buffer<double> queue(8);
for (auto& value : values) {
queue.emplace_front(value);
@@ -55,7 +55,7 @@ TEST(CircularBufferTest, EmplaceFront) {
}
TEST(CircularBufferTest, EmplaceBack) {
wpi::circular_buffer<double> queue(8);
wpi::util::circular_buffer<double> queue(8);
for (auto& value : values) {
queue.emplace_back(value);
@@ -67,7 +67,7 @@ TEST(CircularBufferTest, EmplaceBack) {
}
TEST(CircularBufferTest, PushPop) {
wpi::circular_buffer<double> queue(3);
wpi::util::circular_buffer<double> queue(3);
// Insert three elements into the buffer
queue.push_back(1.0);
@@ -110,7 +110,7 @@ TEST(CircularBufferTest, PushPop) {
}
TEST(CircularBufferTest, Reset) {
wpi::circular_buffer<double> queue(5);
wpi::util::circular_buffer<double> queue(5);
for (size_t i = 1; i < 6; ++i) {
queue.push_back(i);
@@ -122,7 +122,7 @@ TEST(CircularBufferTest, Reset) {
}
TEST(CircularBufferTest, Resize) {
wpi::circular_buffer<double> queue(5);
wpi::util::circular_buffer<double> queue(5);
/* Buffer contains {1, 2, 3, _, _}
* ^ front
@@ -228,7 +228,7 @@ TEST(CircularBufferTest, Resize) {
}
TEST(CircularBufferTest, Iterator) {
wpi::circular_buffer<double> queue(3);
wpi::util::circular_buffer<double> queue(3);
queue.push_back(1.0);
queue.push_back(2.0);

View File

@@ -7,7 +7,7 @@
#include "wpi/util/FastQueue.hpp"
TEST(FastQueueTest, Basic) {
wpi::FastQueue<int> q;
wpi::util::FastQueue<int> q;
q.enqueue(25);
int item;

View File

@@ -7,7 +7,7 @@
#include <gtest/gtest.h>
TEST(InterpolatingMapTest, Insert) {
wpi::interpolating_map<double, double> table;
wpi::util::interpolating_map<double, double> table;
table.insert(125, 450);
table.insert(200, 510);
@@ -35,7 +35,7 @@ TEST(InterpolatingMapTest, Insert) {
}
TEST(InterpolatingMapTest, Clear) {
wpi::interpolating_map<double, double> table;
wpi::util::interpolating_map<double, double> table;
table.insert(125, 450);
table.insert(200, 510);

View File

@@ -12,7 +12,7 @@ TEST(ScopeExitTest, ScopeExit) {
int exitCount = 0;
{
wpi::scope_exit exit{[&] { ++exitCount; }};
wpi::util::scope_exit exit{[&] { ++exitCount; }};
EXPECT_EQ(0, exitCount);
}
@@ -24,16 +24,16 @@ TEST(ScopeExitTest, Release) {
int exitCount = 0;
{
wpi::scope_exit exit1{[&] { ++exitCount; }};
wpi::scope_exit exit2 = std::move(exit1);
wpi::util::scope_exit exit1{[&] { ++exitCount; }};
wpi::util::scope_exit exit2 = std::move(exit1);
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
wpi::scope_exit exit3 = std::move(exit1);
wpi::util::scope_exit exit3 = std::move(exit1);
EXPECT_EQ(0, exitCount);
}
EXPECT_EQ(1, exitCount);
{
wpi::scope_exit exit{[&] { ++exitCount; }};
wpi::util::scope_exit exit{[&] { ++exitCount; }};
exit.release();
}
EXPECT_EQ(1, exitCount);

View File

@@ -19,7 +19,7 @@ static const std::array<double, 8> pushBackOut = {
{342.657, 234.252, 716.126, 132.344, 445.697, 22.727, 421.125, 799.913}};
TEST(StaticCircularBufferTest, PushFront) {
wpi::static_circular_buffer<double, 8> queue;
wpi::util::static_circular_buffer<double, 8> queue;
for (auto& value : values) {
queue.push_front(value);
@@ -31,7 +31,7 @@ TEST(StaticCircularBufferTest, PushFront) {
}
TEST(StaticCircularBufferTest, PushBack) {
wpi::static_circular_buffer<double, 8> queue;
wpi::util::static_circular_buffer<double, 8> queue;
for (auto& value : values) {
queue.push_back(value);
@@ -43,7 +43,7 @@ TEST(StaticCircularBufferTest, PushBack) {
}
TEST(StaticCircularBufferTest, EmplaceFront) {
wpi::static_circular_buffer<double, 8> queue;
wpi::util::static_circular_buffer<double, 8> queue;
for (auto& value : values) {
queue.emplace_front(value);
@@ -55,7 +55,7 @@ TEST(StaticCircularBufferTest, EmplaceFront) {
}
TEST(StaticCircularBufferTest, EmplaceBack) {
wpi::static_circular_buffer<double, 8> queue;
wpi::util::static_circular_buffer<double, 8> queue;
for (auto& value : values) {
queue.emplace_back(value);
@@ -67,7 +67,7 @@ TEST(StaticCircularBufferTest, EmplaceBack) {
}
TEST(StaticCircularBufferTest, PushPop) {
wpi::static_circular_buffer<double, 3> queue;
wpi::util::static_circular_buffer<double, 3> queue;
// Insert three elements into the buffer
queue.push_back(1.0);
@@ -110,7 +110,7 @@ TEST(StaticCircularBufferTest, PushPop) {
}
TEST(StaticCircularBufferTest, Reset) {
wpi::static_circular_buffer<double, 5> queue;
wpi::util::static_circular_buffer<double, 5> queue;
for (size_t i = 1; i < 6; ++i) {
queue.push_back(i);
@@ -122,7 +122,7 @@ TEST(StaticCircularBufferTest, Reset) {
}
TEST(StaticCircularBufferTest, Iterator) {
wpi::static_circular_buffer<double, 3> queue;
wpi::util::static_circular_buffer<double, 3> queue;
queue.push_back(1.0);
queue.push_back(2.0);

View File

@@ -8,28 +8,28 @@
TEST(StringExtrasTest, RemovePrefix) {
std::string_view original = "wpilib";
auto modified = wpi::remove_prefix(original, "wpi");
auto modified = wpi::util::remove_prefix(original, "wpi");
EXPECT_EQ(original, "wpilib");
EXPECT_EQ(modified, std::optional{"lib"});
}
TEST(StringExtrasTest, RemoveSuffix) {
std::string_view original = "wpilib";
auto modified = wpi::remove_suffix(original, "lib");
auto modified = wpi::util::remove_suffix(original, "lib");
EXPECT_EQ(original, "wpilib");
EXPECT_EQ(modified, std::optional{"wpi"});
}
TEST(StringExtrasTest, RemovePrefixNoMatch) {
std::string_view original = "wpilib";
auto modified = wpi::remove_prefix(original, "foo");
auto modified = wpi::util::remove_prefix(original, "foo");
EXPECT_EQ(original, "wpilib");
EXPECT_EQ(modified, std::nullopt);
}
TEST(StringExtrasTest, RemoveSuffixNoMatch) {
std::string_view original = "wpilib";
auto modified = wpi::remove_suffix(original, "foo");
auto modified = wpi::util::remove_suffix(original, "foo");
EXPECT_EQ(original, "wpilib");
EXPECT_EQ(modified, std::nullopt);
}

View File

@@ -18,7 +18,7 @@
#include <gtest/gtest.h>
using namespace wpi;
using namespace wpi::util;
namespace {
@@ -163,7 +163,7 @@ TEST_F(StringMapTest, InsertAndErase) {
}
TEST_F(StringMapTest, SmallFullMap) {
wpi::StringMap<int> Map;
wpi::util::StringMap<int> Map;
Map["eins"] = 1;
Map["zwei"] = 2;
@@ -182,7 +182,7 @@ TEST_F(StringMapTest, SmallFullMap) {
}
TEST_F(StringMapTest, CopyCtor) {
wpi::StringMap<int> Map;
wpi::util::StringMap<int> Map;
Map["eins"] = 1;
Map["zwei"] = 2;
@@ -199,7 +199,7 @@ TEST_F(StringMapTest, CopyCtor) {
EXPECT_EQ(4, Map["veir"]);
EXPECT_EQ(5, Map["funf"]);
wpi::StringMap<int> Map2(Map);
wpi::util::StringMap<int> Map2(Map);
EXPECT_EQ(3u, Map2.size());
EXPECT_FALSE(Map2.contains("eins"));
EXPECT_EQ(2, Map2["zwei"]);
@@ -209,7 +209,7 @@ TEST_F(StringMapTest, CopyCtor) {
}
TEST_F(StringMapTest, At) {
wpi::StringMap<int> Map;
wpi::util::StringMap<int> Map;
// keys both found and not found on non-empty map
Map["a"] = 1;

View File

@@ -9,48 +9,48 @@
#include <gtest/gtest.h>
TEST(EventTest, AutoReset) {
auto event = wpi::CreateEvent(false, false);
std::thread thr([&] { wpi::SetEvent(event); });
wpi::WaitForObject(event);
auto event = wpi::util::CreateEvent(false, false);
std::thread thr([&] { wpi::util::SetEvent(event); });
wpi::util::WaitForObject(event);
thr.join();
bool timedOut;
wpi::WaitForObject(event, 0, &timedOut);
wpi::util::WaitForObject(event, 0, &timedOut);
ASSERT_EQ(timedOut, true);
}
TEST(EventTest, ManualReset) {
auto event = wpi::CreateEvent(true, false);
auto event = wpi::util::CreateEvent(true, false);
int done = 0;
std::thread thr([&] {
wpi::SetEvent(event);
wpi::util::SetEvent(event);
++done;
});
wpi::WaitForObject(event);
wpi::util::WaitForObject(event);
thr.join();
ASSERT_EQ(done, 1);
bool timedOut;
wpi::WaitForObject(event, 0, &timedOut);
wpi::util::WaitForObject(event, 0, &timedOut);
ASSERT_EQ(timedOut, false);
}
TEST(EventTest, InitialSet) {
auto event = wpi::CreateEvent(false, true);
auto event = wpi::util::CreateEvent(false, true);
bool timedOut;
wpi::WaitForObject(event, 0, &timedOut);
wpi::util::WaitForObject(event, 0, &timedOut);
ASSERT_EQ(timedOut, false);
}
TEST(EventTest, WaitMultiple) {
auto event1 = wpi::CreateEvent(false, false);
auto event2 = wpi::CreateEvent(false, false);
std::thread thr([&] { wpi::SetEvent(event2); });
auto event1 = wpi::util::CreateEvent(false, false);
auto event2 = wpi::util::CreateEvent(false, false);
std::thread thr([&] { wpi::util::SetEvent(event2); });
WPI_Handle signaled[2];
auto result1 = wpi::WaitForObjects({event1, event2}, signaled);
auto result1 = wpi::util::WaitForObjects({event1, event2}, signaled);
thr.join();
ASSERT_EQ(result1.size(), 1u);
ASSERT_EQ(result1[0], event2);
bool timedOut;
auto result2 = wpi::WaitForObjects({event1, event2}, signaled, 0, &timedOut);
auto result2 = wpi::util::WaitForObjects({event1, event2}, signaled, 0, &timedOut);
ASSERT_EQ(timedOut, true);
ASSERT_EQ(result2.size(), 0u);
}

View File

@@ -8,7 +8,7 @@
#include <gtest/gtest.h>
namespace wpi {
namespace wpi::util {
TEST(UidVectorTest, Empty) {
UidVector<int, 4> v;
@@ -46,4 +46,4 @@ TEST(UidVectorTest, Iterate) {
EXPECT_EQ(out[1], 1);
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -7,7 +7,7 @@
#include "wpi/util/SmallString.hpp"
#include "wpi/util/StringExtras.hpp"
using namespace wpi;
using namespace wpi::util;
namespace {

View File

@@ -7,7 +7,7 @@
#include "wpi/util/argparse.hpp"
TEST(ArgparseTest, Basic) {
wpi::ArgumentParser program("ArgparseTest");
wpi::util::ArgumentParser program("ArgparseTest");
program.add_argument("test").help("Test argument").scan<'i', int>();

View File

@@ -10,28 +10,28 @@
#include <gtest/gtest.h>
TEST(CtStringTest, Concat) {
using namespace wpi::literals;
using namespace wpi::util::literals;
constexpr std::string_view astring = "name";
constexpr int arrsize = 5;
constexpr auto str = Concat(
wpi::ct_string<char, std::char_traits<char>, astring.size()>{astring},
"["_ct_string, wpi::NumToCtString<arrsize>(), "]"_ct_string);
wpi::util::ct_string<char, std::char_traits<char>, astring.size()>{astring},
"["_ct_string, wpi::util::NumToCtString<arrsize>(), "]"_ct_string);
static_assert(str.size() == 7);
ASSERT_EQ(std::string{str}, "name[5]");
}
TEST(CtStringTest, OperatorPlus) {
using namespace wpi::literals;
using namespace wpi::util::literals;
constexpr std::string_view astring = "name";
constexpr auto str =
wpi::ct_string<char, std::char_traits<char>, astring.size()>{astring} +
wpi::util::ct_string<char, std::char_traits<char>, astring.size()>{astring} +
"[]"_ct_string;
static_assert(str.size() == 6);
ASSERT_EQ(std::string{str}, "name[]");
}
TEST(CtStringTest, StringViewConversion) {
using namespace wpi::literals;
using namespace wpi::util::literals;
constexpr auto str = "[]"_ct_string;
std::string_view sv = str;
ASSERT_EQ(sv, "[]");

View File

@@ -6,5 +6,5 @@
#include <gtest/gtest.h>
TEST(DebuggingTest, IsDebuggerPresent) {
EXPECT_FALSE(wpi::is_debugger_present());
EXPECT_FALSE(wpi::util::is_debugger_present());
}

View File

@@ -25,14 +25,14 @@ struct TakesInitAndVariadic {
TEST(ExpectedTest, Emplace) {
{
wpi::expected<std::unique_ptr<int>, int> e;
wpi::util::expected<std::unique_ptr<int>, int> e;
e.emplace(new int{42});
EXPECT_TRUE(e);
EXPECT_EQ(**e, 42);
}
{
wpi::expected<std::vector<int>, int> e;
wpi::util::expected<std::vector<int>, int> e;
e.emplace({0, 1});
EXPECT_TRUE(e);
EXPECT_EQ((*e)[0], 0);
@@ -40,7 +40,7 @@ TEST(ExpectedTest, Emplace) {
}
{
wpi::expected<std::tuple<int, int>, int> e;
wpi::util::expected<std::tuple<int, int>, int> e;
e.emplace(2, 3);
EXPECT_TRUE(e);
EXPECT_EQ(std::get<0>(*e), 2);
@@ -48,7 +48,7 @@ TEST(ExpectedTest, Emplace) {
}
{
wpi::expected<TakesInitAndVariadic, int> e = wpi::make_unexpected(0);
wpi::util::expected<TakesInitAndVariadic, int> e = wpi::util::make_unexpected(0);
e.emplace({0, 1}, 2, 3);
EXPECT_TRUE(e);
EXPECT_EQ(e->v[0], 0);

View File

@@ -8,7 +8,7 @@
#include <gtest/gtest.h>
namespace wpi {
namespace wpi::util {
TEST(FutureTest, Then) {
promise<bool> inPromise;
@@ -78,4 +78,4 @@ TEST(FutureTest, MoveVoid) {
ASSERT_TRUE(outFuture.is_ready());
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -9,8 +9,8 @@
#include "wpi/util/Chrono.hpp"
#include "gtest/gtest.h"
using namespace wpi;
using namespace wpi::sys;
using namespace wpi::util;
using namespace wpi::util::sys;
using namespace std::chrono;
namespace {

View File

@@ -13,7 +13,7 @@
#include <string>
#include <vector>
using namespace wpi;
using namespace wpi::util;
TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
// Src is the look of disapproval.

View File

@@ -8,7 +8,7 @@
#include "CountCopyAndMove.hpp"
using namespace wpi;
using namespace wpi::util;
int CountCopyAndMove::DefaultConstructions = 0;
int CountCopyAndMove::ValueConstructions = 0;

View File

@@ -9,7 +9,7 @@
#ifndef LLVM_UNITTESTS_ADT_COUNTCOPYANDMOVE_H
#define LLVM_UNITTESTS_ADT_COUNTCOPYANDMOVE_H
namespace wpi {
namespace wpi::util {
struct CountCopyAndMove {
static int DefaultConstructions;
@@ -61,6 +61,6 @@ struct CountCopyAndMove {
static int TotalMoves() { return MoveConstructions + MoveAssignments; }
};
} // end namespace wpi
} // end namespace wpi::util
#endif // LLVM_UNITTESTS_ADT_COUNTCOPYANDMOVE_H

View File

@@ -22,7 +22,7 @@
#include <utility>
#include <variant>
using namespace wpi;
using namespace wpi::util;
namespace {
uint32_t getTestKey(int i, uint32_t *) { return i; }
@@ -701,7 +701,7 @@ struct AlwaysEqType {
};
} // namespace
namespace wpi {
namespace wpi::util {
template <typename T>
struct DenseMapInfo<T, std::enable_if_t<std::is_base_of_v<A, T>>> {
static inline T getEmptyKey() { return {static_cast<int>(~0)}; }
@@ -721,7 +721,7 @@ template <> struct DenseMapInfo<AlwaysEqType> {
return false;
}
};
} // namespace wpi
} // namespace wpi::util
namespace {
TEST(DenseMapCustomTest, SFINAEMapInfo) {

View File

@@ -10,7 +10,7 @@
#include "gtest/gtest.h"
#include <cstdlib>
#include <ctime>
using namespace wpi;
using namespace wpi::util;
using namespace support;
#undef max
@@ -23,34 +23,34 @@ TEST(Endian, Read) {
unsigned char littleval[] = {0x00, 0x04, 0x03, 0x02, 0x01};
int32_t BigAsHost = 0x00010203;
EXPECT_EQ(BigAsHost,
(endian::read<int32_t, wpi::endianness::big, unaligned>(bigval)));
(endian::read<int32_t, wpi::util::endianness::big, unaligned>(bigval)));
int32_t LittleAsHost = 0x02030400;
EXPECT_EQ(
LittleAsHost,
(endian::read<int32_t, wpi::endianness::little, unaligned>(littleval)));
(endian::read<int32_t, wpi::util::endianness::little, unaligned>(littleval)));
EXPECT_EQ(
(endian::read<int32_t, wpi::endianness::big, unaligned>(bigval + 1)),
(endian::read<int32_t, wpi::endianness::little, unaligned>(littleval +
(endian::read<int32_t, wpi::util::endianness::big, unaligned>(bigval + 1)),
(endian::read<int32_t, wpi::util::endianness::little, unaligned>(littleval +
1)));
}
TEST(Endian, WriteNext) {
unsigned char bigval[] = {0x00, 0x00}, *p = bigval;
endian::writeNext<int16_t, wpi::endianness::big>(p, short(0xaabb));
endian::writeNext<int16_t, wpi::util::endianness::big>(p, short(0xaabb));
EXPECT_EQ(bigval[0], 0xaa);
EXPECT_EQ(bigval[1], 0xbb);
EXPECT_EQ(p, bigval + 2);
char littleval[8] = {}, *q = littleval;
endian::writeNext<uint32_t, wpi::endianness::little>(q, 0x44556677);
endian::writeNext<uint32_t, wpi::util::endianness::little>(q, 0x44556677);
EXPECT_EQ(littleval[0], 0x77);
EXPECT_EQ(littleval[1], 0x66);
EXPECT_EQ(littleval[2], 0x55);
EXPECT_EQ(littleval[3], 0x44);
EXPECT_EQ(q, littleval + 4);
endian::writeNext<uint32_t>(q, 0x11223344, wpi::endianness::little);
endian::writeNext<uint32_t>(q, 0x11223344, wpi::util::endianness::little);
EXPECT_EQ(littleval[4], 0x44);
EXPECT_EQ(littleval[5], 0x33);
EXPECT_EQ(littleval[6], 0x22);
@@ -63,10 +63,10 @@ TEST(Endian, ReadBitAligned) {
unsigned char littleval[] = {0x3f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff};
unsigned char bigval[] = {0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xc0};
EXPECT_EQ(
(endian::readAtBitAlignment<int, wpi::endianness::little, unaligned>(
(endian::readAtBitAlignment<int, wpi::util::endianness::little, unaligned>(
&littleval[0], 6)),
0x0);
EXPECT_EQ((endian::readAtBitAlignment<int, wpi::endianness::big, unaligned>(
EXPECT_EQ((endian::readAtBitAlignment<int, wpi::util::endianness::big, unaligned>(
&bigval[0], 6)),
0x0);
// Test to make sure that signed right shift of 0xf0000000 is masked
@@ -74,18 +74,18 @@ TEST(Endian, ReadBitAligned) {
unsigned char littleval2[] = {0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00};
unsigned char bigval2[] = {0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
EXPECT_EQ(
(endian::readAtBitAlignment<int, wpi::endianness::little, unaligned>(
(endian::readAtBitAlignment<int, wpi::util::endianness::little, unaligned>(
&littleval2[0], 4)),
0x0f000000);
EXPECT_EQ((endian::readAtBitAlignment<int, wpi::endianness::big, unaligned>(
EXPECT_EQ((endian::readAtBitAlignment<int, wpi::util::endianness::big, unaligned>(
&bigval2[0], 4)),
0x0f000000);
// Test to make sure left shift of start bit doesn't overflow.
EXPECT_EQ(
(endian::readAtBitAlignment<int, wpi::endianness::little, unaligned>(
(endian::readAtBitAlignment<int, wpi::util::endianness::little, unaligned>(
&littleval2[0], 1)),
0x78000000);
EXPECT_EQ((endian::readAtBitAlignment<int, wpi::endianness::big, unaligned>(
EXPECT_EQ((endian::readAtBitAlignment<int, wpi::util::endianness::big, unaligned>(
&bigval2[0], 1)),
0x78000000);
// Test to make sure 64-bit int doesn't overflow.
@@ -94,11 +94,11 @@ TEST(Endian, ReadBitAligned) {
unsigned char bigval3[] = {0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
EXPECT_EQ(
(endian::readAtBitAlignment<int64_t, wpi::endianness::little, unaligned>(
(endian::readAtBitAlignment<int64_t, wpi::util::endianness::little, unaligned>(
&littleval3[0], 4)),
0x0f00000000000000);
EXPECT_EQ(
(endian::readAtBitAlignment<int64_t, wpi::endianness::big, unaligned>(
(endian::readAtBitAlignment<int64_t, wpi::util::endianness::big, unaligned>(
&bigval3[0], 4)),
0x0f00000000000000);
}
@@ -107,7 +107,7 @@ TEST(Endian, WriteBitAligned) {
// This test ensures that signed right shift of 0xffffaa is masked
// properly.
unsigned char bigval[8] = {0x00};
endian::writeAtBitAlignment<int32_t, wpi::endianness::big, unaligned>(
endian::writeAtBitAlignment<int32_t, wpi::util::endianness::big, unaligned>(
bigval, (int)0xffffaaaa, 4);
EXPECT_EQ(bigval[0], 0xff);
EXPECT_EQ(bigval[1], 0xfa);
@@ -119,7 +119,7 @@ TEST(Endian, WriteBitAligned) {
EXPECT_EQ(bigval[7], 0x0f);
unsigned char littleval[8] = {0x00};
endian::writeAtBitAlignment<int32_t, wpi::endianness::little, unaligned>(
endian::writeAtBitAlignment<int32_t, wpi::util::endianness::little, unaligned>(
littleval, (int)0xffffaaaa, 4);
EXPECT_EQ(littleval[0], 0xa0);
EXPECT_EQ(littleval[1], 0xaa);
@@ -133,7 +133,7 @@ TEST(Endian, WriteBitAligned) {
// This test makes sure 1<<31 doesn't overflow.
// Test to make sure left shift of start bit doesn't overflow.
unsigned char bigval2[8] = {0x00};
endian::writeAtBitAlignment<int32_t, wpi::endianness::big, unaligned>(
endian::writeAtBitAlignment<int32_t, wpi::util::endianness::big, unaligned>(
bigval2, (int)0xffffffff, 1);
EXPECT_EQ(bigval2[0], 0xff);
EXPECT_EQ(bigval2[1], 0xff);
@@ -145,7 +145,7 @@ TEST(Endian, WriteBitAligned) {
EXPECT_EQ(bigval2[7], 0x01);
unsigned char littleval2[8] = {0x00};
endian::writeAtBitAlignment<int32_t, wpi::endianness::little, unaligned>(
endian::writeAtBitAlignment<int32_t, wpi::util::endianness::little, unaligned>(
littleval2, (int)0xffffffff, 1);
EXPECT_EQ(littleval2[0], 0xfe);
EXPECT_EQ(littleval2[1], 0xff);
@@ -158,7 +158,7 @@ TEST(Endian, WriteBitAligned) {
// Test to make sure 64-bit int doesn't overflow.
unsigned char bigval64[16] = {0x00};
endian::writeAtBitAlignment<int64_t, wpi::endianness::big, unaligned>(
endian::writeAtBitAlignment<int64_t, wpi::util::endianness::big, unaligned>(
bigval64, (int64_t)0xffffffffffffffff, 1);
EXPECT_EQ(bigval64[0], 0xff);
EXPECT_EQ(bigval64[1], 0xff);
@@ -178,7 +178,7 @@ TEST(Endian, WriteBitAligned) {
EXPECT_EQ(bigval64[15], 0x01);
unsigned char littleval64[16] = {0x00};
endian::writeAtBitAlignment<int64_t, wpi::endianness::little, unaligned>(
endian::writeAtBitAlignment<int64_t, wpi::util::endianness::little, unaligned>(
littleval64, (int64_t)0xffffffffffffffff, 1);
EXPECT_EQ(littleval64[0], 0xfe);
EXPECT_EQ(littleval64[1], 0xff);
@@ -200,25 +200,25 @@ TEST(Endian, WriteBitAligned) {
TEST(Endian, Write) {
unsigned char data[5];
endian::write<int32_t, wpi::endianness::big, unaligned>(data, -1362446643);
endian::write<int32_t, wpi::util::endianness::big, unaligned>(data, -1362446643);
EXPECT_EQ(data[0], 0xAE);
EXPECT_EQ(data[1], 0xCA);
EXPECT_EQ(data[2], 0xB6);
EXPECT_EQ(data[3], 0xCD);
endian::write<int32_t, wpi::endianness::big, unaligned>(data + 1,
endian::write<int32_t, wpi::util::endianness::big, unaligned>(data + 1,
-1362446643);
EXPECT_EQ(data[1], 0xAE);
EXPECT_EQ(data[2], 0xCA);
EXPECT_EQ(data[3], 0xB6);
EXPECT_EQ(data[4], 0xCD);
endian::write<int32_t, wpi::endianness::little, unaligned>(data,
endian::write<int32_t, wpi::util::endianness::little, unaligned>(data,
-1362446643);
EXPECT_EQ(data[0], 0xCD);
EXPECT_EQ(data[1], 0xB6);
EXPECT_EQ(data[2], 0xCA);
EXPECT_EQ(data[3], 0xAE);
endian::write<int32_t, wpi::endianness::little, unaligned>(data + 1,
endian::write<int32_t, wpi::util::endianness::little, unaligned>(data + 1,
-1362446643);
EXPECT_EQ(data[1], 0xCD);
EXPECT_EQ(data[2], 0xB6);

View File

@@ -9,7 +9,7 @@
#include "wpi/util/Errno.hpp"
#include "gtest/gtest.h"
using namespace wpi::sys;
using namespace wpi::util::sys;
TEST(ErrnoTest, RetryAfterSignal) {
EXPECT_EQ(1, RetryAfterSignal(-1, [] { return 1; }));

View File

@@ -13,7 +13,7 @@
#include <memory>
#include <type_traits>
using namespace wpi;
using namespace wpi::util;
namespace {

View File

@@ -10,7 +10,7 @@
#include "gtest/gtest.h"
#include <limits>
using namespace wpi;
using namespace wpi::util;
namespace {

View File

@@ -9,7 +9,7 @@
#include "wpi/util/PointerIntPair.hpp"
#include "gtest/gtest.h"
#include <limits>
using namespace wpi;
using namespace wpi::util;
namespace {

View File

@@ -8,7 +8,7 @@
#include "wpi/util/PointerUnion.hpp"
#include "gtest/gtest.h"
using namespace wpi;
using namespace wpi::util;
namespace {

View File

@@ -36,34 +36,34 @@ TYPED_TEST(STLForwardCompatRemoveCVRefTest, RemoveCVRef) {
using From = typename TypeParam::first_type;
using To = typename TypeParam::second_type;
EXPECT_TRUE(
(std::is_same<typename wpi::remove_cvref<From>::type, To>::value));
(std::is_same<typename wpi::util::remove_cvref<From>::type, To>::value));
}
TYPED_TEST(STLForwardCompatRemoveCVRefTest, RemoveCVRefT) {
using From = typename TypeParam::first_type;
EXPECT_TRUE((std::is_same<typename wpi::remove_cvref<From>::type,
wpi::remove_cvref_t<From>>::value));
EXPECT_TRUE((std::is_same<typename wpi::util::remove_cvref<From>::type,
wpi::util::remove_cvref_t<From>>::value));
}
TEST(TransformTest, TransformStd) {
std::optional<int> A;
std::optional<int> B = wpi::transformOptional(A, [&](int N) { return N + 1; });
std::optional<int> B = wpi::util::transformOptional(A, [&](int N) { return N + 1; });
EXPECT_FALSE(B.has_value());
A = 3;
std::optional<int> C = wpi::transformOptional(A, [&](int N) { return N + 1; });
std::optional<int> C = wpi::util::transformOptional(A, [&](int N) { return N + 1; });
EXPECT_TRUE(C.has_value());
EXPECT_EQ(4, *C);
}
TEST(TransformTest, MoveTransformStd) {
using wpi::CountCopyAndMove;
using wpi::util::CountCopyAndMove;
std::optional<CountCopyAndMove> A;
CountCopyAndMove::ResetCounts();
std::optional<int> B = wpi::transformOptional(
std::optional<int> B = wpi::util::transformOptional(
std::move(A), [&](const CountCopyAndMove &M) { return M.val + 2; });
EXPECT_FALSE(B.has_value());
EXPECT_EQ(0, CountCopyAndMove::TotalCopies());
@@ -73,7 +73,7 @@ TEST(TransformTest, MoveTransformStd) {
A = CountCopyAndMove(5);
CountCopyAndMove::ResetCounts();
std::optional<int> C = wpi::transformOptional(
std::optional<int> C = wpi::util::transformOptional(
std::move(A), [&](const CountCopyAndMove &M) { return M.val + 2; });
EXPECT_TRUE(C.has_value());
EXPECT_EQ(7, *C);
@@ -87,23 +87,23 @@ TEST(TransformTest, TransformLlvm) {
std::optional<int> A;
std::optional<int> B =
wpi::transformOptional(A, [&](int N) { return N + 1; });
wpi::util::transformOptional(A, [&](int N) { return N + 1; });
EXPECT_FALSE(B.has_value());
A = 3;
std::optional<int> C =
wpi::transformOptional(A, [&](int N) { return N + 1; });
wpi::util::transformOptional(A, [&](int N) { return N + 1; });
EXPECT_TRUE(C.has_value());
EXPECT_EQ(4, *C);
}
TEST(TransformTest, MoveTransformLlvm) {
using wpi::CountCopyAndMove;
using wpi::util::CountCopyAndMove;
std::optional<CountCopyAndMove> A;
CountCopyAndMove::ResetCounts();
std::optional<int> B = wpi::transformOptional(
std::optional<int> B = wpi::util::transformOptional(
std::move(A), [&](const CountCopyAndMove &M) { return M.val + 2; });
EXPECT_FALSE(B.has_value());
EXPECT_EQ(0, CountCopyAndMove::TotalCopies());
@@ -113,7 +113,7 @@ TEST(TransformTest, MoveTransformLlvm) {
A = CountCopyAndMove(5);
CountCopyAndMove::ResetCounts();
std::optional<int> C = wpi::transformOptional(
std::optional<int> C = wpi::util::transformOptional(
std::move(A), [&](const CountCopyAndMove &M) { return M.val + 2; });
EXPECT_TRUE(C.has_value());
EXPECT_EQ(7, *C);
@@ -125,19 +125,19 @@ TEST(TransformTest, MoveTransformLlvm) {
TEST(TransformTest, ToUnderlying) {
enum E { A1 = 0, B1 = -1 };
static_assert(wpi::to_underlying(A1) == 0);
static_assert(wpi::to_underlying(B1) == -1);
static_assert(wpi::util::to_underlying(A1) == 0);
static_assert(wpi::util::to_underlying(B1) == -1);
enum E2 : unsigned char { A2 = 0, B2 };
static_assert(
std::is_same_v<unsigned char, decltype(wpi::to_underlying(A2))>);
static_assert(wpi::to_underlying(A2) == 0);
static_assert(wpi::to_underlying(B2) == 1);
std::is_same_v<unsigned char, decltype(wpi::util::to_underlying(A2))>);
static_assert(wpi::util::to_underlying(A2) == 0);
static_assert(wpi::util::to_underlying(B2) == 1);
enum class E3 { A3 = -1, B3 };
static_assert(std::is_same_v<int, decltype(wpi::to_underlying(E3::A3))>);
static_assert(wpi::to_underlying(E3::A3) == -1);
static_assert(wpi::to_underlying(E3::B3) == 0);
static_assert(std::is_same_v<int, decltype(wpi::util::to_underlying(E3::A3))>);
static_assert(wpi::util::to_underlying(E3::A3) == -1);
static_assert(wpi::util::to_underlying(E3::B3) == 0);
}
} // namespace

View File

@@ -18,7 +18,7 @@
#include <algorithm>
using namespace wpi;
using namespace wpi::util;
using testing::UnorderedElementsAre;
TEST(SmallPtrSetTest, Assignment) {

View File

@@ -16,7 +16,7 @@
#include <algorithm>
#include <string>
using namespace wpi;
using namespace wpi::util;
TEST(SmallSetTest, ConstructorIteratorPair) {
std::initializer_list<int> L = {1, 2, 3, 4, 5};
@@ -27,7 +27,7 @@ TEST(SmallSetTest, ConstructorIteratorPair) {
TEST(SmallSet, ConstructorRange) {
std::initializer_list<int> L = {1, 2, 3, 4, 5};
SmallSet<int, 4> S(wpi::make_range(std::begin(L), std::end(L)));
SmallSet<int, 4> S(wpi::util::make_range(std::begin(L), std::end(L)));
EXPECT_THAT(S, testing::UnorderedElementsAreArray(L));
}

View File

@@ -16,7 +16,7 @@
#include <cstring>
#include <stdarg.h>
using namespace wpi;
using namespace wpi::util;
namespace {

View File

@@ -22,7 +22,7 @@
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
using namespace wpi;
using namespace wpi::util;
namespace {
@@ -1175,14 +1175,14 @@ TEST(SmallVectorTest, ConstructFromSpanOfConvertibleType) {
std::vector<From> StdVector = {From(to1), From(to2), From(to3)};
std::span<const From> Array = StdVector;
{
wpi::SmallVector<To> Vector(Array);
wpi::util::SmallVector<To> Vector(Array);
ASSERT_EQ(Array.size(), Vector.size());
for (size_t I = 0; I < Array.size(); ++I)
EXPECT_EQ(Array[I], Vector[I]);
}
{
wpi::SmallVector<To, 4> Vector(Array);
wpi::util::SmallVector<To, 4> Vector(Array);
ASSERT_EQ(Array.size(), Vector.size());
ASSERT_EQ(4u, NumBuiltinElts(Vector));
@@ -1195,14 +1195,14 @@ TEST(SmallVectorTest, ToVectorOf) {
To to1{1}, to2{2}, to3{3};
std::vector<From> StdVector = {From(to1), From(to2), From(to3)};
{
wpi::SmallVector<To> Vector = wpi::to_vector_of<To>(StdVector);
wpi::util::SmallVector<To> Vector = wpi::util::to_vector_of<To>(StdVector);
ASSERT_EQ(StdVector.size(), Vector.size());
for (size_t I = 0; I < StdVector.size(); ++I)
EXPECT_EQ(StdVector[I], Vector[I]);
}
{
auto Vector = wpi::to_vector_of<To, 4>(StdVector);
auto Vector = wpi::util::to_vector_of<To, 4>(StdVector);
ASSERT_EQ(StdVector.size(), Vector.size());
static_assert(NumBuiltinElts(Vector) == 4u);

View File

@@ -10,7 +10,7 @@
#include "gtest/gtest.h"
#include <cstdlib>
#include <ctime>
using namespace wpi;
using namespace wpi::util;
#undef max

View File

@@ -10,7 +10,7 @@
#include <gtest/gtest.h>
namespace wpi {
namespace wpi::util {
#ifdef WPI_HAVE_PRIORITY_MUTEX
@@ -265,4 +265,4 @@ TEST(MutexTest, ReentrantTryLock) {
#endif // WPI_HAVE_PRIORITY_MUTEX
} // namespace wpi
} // namespace wpi::util

View File

@@ -32,18 +32,18 @@ struct TestProto {
};
template <>
struct wpi::Protobuf<TestProto> {
struct wpi::util::Protobuf<TestProto> {
using MessageStruct = wpi_proto_TestProto;
using InputStream = wpi::ProtoInputStream<TestProto>;
using OutputStream = wpi::ProtoOutputStream<TestProto>;
using InputStream = wpi::util::ProtoInputStream<TestProto>;
using OutputStream = wpi::util::ProtoOutputStream<TestProto>;
static std::optional<TestProto> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const TestProto& value);
};
std::optional<TestProto> wpi::Protobuf<TestProto>::Unpack(InputStream& stream) {
wpi::UnpackCallback<std::string> str;
wpi::UnpackCallback<std::vector<uint8_t>> bytes;
wpi::UnpackCallback<TestProtoInner> inner;
std::optional<TestProto> wpi::util::Protobuf<TestProto>::Unpack(InputStream& stream) {
wpi::util::UnpackCallback<std::string> str;
wpi::util::UnpackCallback<std::vector<uint8_t>> bytes;
wpi::util::UnpackCallback<TestProtoInner> inner;
wpi_proto_TestProto msg;
msg.string_msg = str.Callback();
msg.bytes_msg = bytes.Callback();
@@ -80,11 +80,11 @@ std::optional<TestProto> wpi::Protobuf<TestProto>::Unpack(InputStream& stream) {
};
}
bool wpi::Protobuf<TestProto>::Pack(OutputStream& stream,
bool wpi::util::Protobuf<TestProto>::Pack(OutputStream& stream,
const TestProto& value) {
wpi::PackCallback str{&value.string_msg};
wpi::PackCallback bytes{&value.bytes_msg};
wpi::PackCallback inner{&value.TestProtoInner_msg};
wpi::util::PackCallback str{&value.string_msg};
wpi::util::PackCallback bytes{&value.bytes_msg};
wpi::util::PackCallback inner{&value.TestProtoInner_msg};
wpi_proto_TestProto msg{
.double_msg = value.double_msg,
.float_msg = value.float_msg,
@@ -107,14 +107,14 @@ bool wpi::Protobuf<TestProto>::Pack(OutputStream& stream,
}
namespace {
using ProtoType = wpi::Protobuf<TestProto>;
using ProtoType = wpi::util::Protobuf<TestProto>;
} // namespace
TEST(TestProtoTest, RoundtripNanopb) {
const TestProto kExpectedData = TestProto{};
wpi::ProtobufMessage<TestProto> message;
wpi::SmallVector<uint8_t, 64> buf;
wpi::util::ProtobufMessage<TestProto> message;
wpi::util::SmallVector<uint8_t, 64> buf;
ASSERT_TRUE(message.Pack(buf, kExpectedData));
std::optional<TestProto> unpacked_data = message.Unpack(buf);

View File

@@ -12,9 +12,9 @@
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
#include "wpiutil.npb.h"
std::optional<TestProtoInner> wpi::Protobuf<TestProtoInner>::Unpack(
wpi::ProtoInputStream<TestProtoInner>& stream) {
wpi::UnpackCallback<std::string> str;
std::optional<TestProtoInner> wpi::util::Protobuf<TestProtoInner>::Unpack(
wpi::util::ProtoInputStream<TestProtoInner>& stream) {
wpi::util::UnpackCallback<std::string> str;
wpi_proto_TestProtoInner msg{
.msg = str.Callback(),
};
@@ -31,10 +31,10 @@ std::optional<TestProtoInner> wpi::Protobuf<TestProtoInner>::Unpack(
return TestProtoInner{std::move(istr[0])};
}
bool wpi::Protobuf<TestProtoInner>::Pack(
wpi::ProtoOutputStream<TestProtoInner>& stream,
bool wpi::util::Protobuf<TestProtoInner>::Pack(
wpi::util::ProtoOutputStream<TestProtoInner>& stream,
const TestProtoInner& value) {
wpi::PackCallback str{&value.msg};
wpi::util::PackCallback str{&value.msg};
wpi_proto_TestProtoInner msg{
.msg = str.Callback(),
};
@@ -42,14 +42,14 @@ bool wpi::Protobuf<TestProtoInner>::Pack(
}
namespace {
using ProtoType = wpi::Protobuf<TestProtoInner>;
using ProtoType = wpi::util::Protobuf<TestProtoInner>;
} // namespace
TEST(TestProtoInnerTest, RoundtripNanopb) {
const TestProtoInner kExpectedData = TestProtoInner{"Hello!"};
wpi::ProtobufMessage<TestProtoInner> message;
wpi::SmallVector<uint8_t, 64> buf;
wpi::util::ProtobufMessage<TestProtoInner> message;
wpi::util::SmallVector<uint8_t, 64> buf;
ASSERT_TRUE(message.Pack(buf, kExpectedData));
std::optional<TestProtoInner> unpacked_data = message.Unpack(buf);
@@ -60,8 +60,8 @@ TEST(TestProtoInnerTest, RoundtripNanopb) {
TEST(TestProtoInnerTest, RoundtripNanopbEmpty) {
const TestProtoInner kExpectedData = TestProtoInner{"Hello!"};
wpi::ProtobufMessage<decltype(kExpectedData)> message;
wpi::SmallVector<uint8_t, 64> buf;
wpi::util::ProtobufMessage<decltype(kExpectedData)> message;
wpi::util::SmallVector<uint8_t, 64> buf;
ASSERT_TRUE(message.Pack(buf, kExpectedData));
auto unpacked_data = message.Unpack(buf);

View File

@@ -14,10 +14,10 @@ struct TestProtoInner {
};
template <>
struct wpi::Protobuf<TestProtoInner> {
struct wpi::util::Protobuf<TestProtoInner> {
using MessageStruct = wpi_proto_TestProtoInner;
using InputStream = wpi::ProtoInputStream<TestProtoInner>;
using OutputStream = wpi::ProtoOutputStream<TestProtoInner>;
using InputStream = wpi::util::ProtoInputStream<TestProtoInner>;
using OutputStream = wpi::util::ProtoOutputStream<TestProtoInner>;
static std::optional<TestProtoInner> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const TestProtoInner& value);
};

View File

@@ -25,57 +25,57 @@ struct RepeatedTestProto {
std::vector<uint64_t> fixed64_msg;
std::vector<int32_t> sfixed32_msg;
std::vector<int64_t> sfixed64_msg;
wpi::SmallVector<bool, 128> bool_msg;
wpi::util::SmallVector<bool, 128> bool_msg;
std::vector<std::string> string_msg;
std::vector<std::vector<uint8_t>> bytes_msg;
std::vector<TestProtoInner> TestProtoInner_msg;
};
template <>
struct wpi::Protobuf<RepeatedTestProto> {
struct wpi::util::Protobuf<RepeatedTestProto> {
using MessageStruct = wpi_proto_RepeatedTestProto;
using InputStream = wpi::ProtoInputStream<RepeatedTestProto>;
using OutputStream = wpi::ProtoOutputStream<RepeatedTestProto>;
using InputStream = wpi::util::ProtoInputStream<RepeatedTestProto>;
using OutputStream = wpi::util::ProtoOutputStream<RepeatedTestProto>;
static std::optional<RepeatedTestProto> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const RepeatedTestProto& value);
};
std::optional<RepeatedTestProto> wpi::Protobuf<RepeatedTestProto>::Unpack(
std::optional<RepeatedTestProto> wpi::util::Protobuf<RepeatedTestProto>::Unpack(
InputStream& stream) {
RepeatedTestProto toRet;
wpi::DirectUnpackCallback<double, std::vector<double>> double_msg{
wpi::util::DirectUnpackCallback<double, std::vector<double>> double_msg{
toRet.double_msg};
wpi::DirectUnpackCallback<float, std::vector<float>> float_msg{
wpi::util::DirectUnpackCallback<float, std::vector<float>> float_msg{
toRet.float_msg};
wpi::DirectUnpackCallback<int32_t, std::vector<int32_t>> int32_msg{
wpi::util::DirectUnpackCallback<int32_t, std::vector<int32_t>> int32_msg{
toRet.int32_msg};
wpi::DirectUnpackCallback<int64_t, std::vector<int64_t>> int64_msg{
wpi::util::DirectUnpackCallback<int64_t, std::vector<int64_t>> int64_msg{
toRet.int64_msg};
wpi::DirectUnpackCallback<uint32_t, std::vector<uint32_t>> uint32_msg{
wpi::util::DirectUnpackCallback<uint32_t, std::vector<uint32_t>> uint32_msg{
toRet.uint32_msg};
wpi::DirectUnpackCallback<uint64_t, std::vector<uint64_t>> uint64_msg{
wpi::util::DirectUnpackCallback<uint64_t, std::vector<uint64_t>> uint64_msg{
toRet.uint64_msg};
wpi::DirectUnpackCallback<int32_t, std::vector<int32_t>> sint32_msg{
wpi::util::DirectUnpackCallback<int32_t, std::vector<int32_t>> sint32_msg{
toRet.sint32_msg};
wpi::DirectUnpackCallback<int64_t, std::vector<int64_t>> sint64_msg{
wpi::util::DirectUnpackCallback<int64_t, std::vector<int64_t>> sint64_msg{
toRet.sint64_msg};
wpi::DirectUnpackCallback<uint32_t, std::vector<uint32_t>> fixed32_msg{
wpi::util::DirectUnpackCallback<uint32_t, std::vector<uint32_t>> fixed32_msg{
toRet.fixed32_msg};
wpi::DirectUnpackCallback<uint64_t, std::vector<uint64_t>> fixed64_msg{
wpi::util::DirectUnpackCallback<uint64_t, std::vector<uint64_t>> fixed64_msg{
toRet.fixed64_msg};
wpi::DirectUnpackCallback<int32_t, std::vector<int32_t>> sfixed32_msg{
wpi::util::DirectUnpackCallback<int32_t, std::vector<int32_t>> sfixed32_msg{
toRet.sfixed32_msg};
wpi::DirectUnpackCallback<int64_t, std::vector<int64_t>> sfixed64_msg{
wpi::util::DirectUnpackCallback<int64_t, std::vector<int64_t>> sfixed64_msg{
toRet.sfixed64_msg};
wpi::DirectUnpackCallback<bool, wpi::SmallVector<bool, 128>> bool_msg{
wpi::util::DirectUnpackCallback<bool, wpi::util::SmallVector<bool, 128>> bool_msg{
toRet.bool_msg};
wpi::DirectUnpackCallback<std::string, std::vector<std::string>> string_msg{
wpi::util::DirectUnpackCallback<std::string, std::vector<std::string>> string_msg{
toRet.string_msg};
wpi::DirectUnpackCallback<std::vector<uint8_t>,
wpi::util::DirectUnpackCallback<std::vector<uint8_t>,
std::vector<std::vector<uint8_t>>>
bytes_msg{toRet.bytes_msg};
wpi::DirectUnpackCallback<TestProtoInner, std::vector<TestProtoInner>>
wpi::util::DirectUnpackCallback<TestProtoInner, std::vector<TestProtoInner>>
TestProtoInner_msg{toRet.TestProtoInner_msg};
wpi_proto_RepeatedTestProto msg{
@@ -104,24 +104,24 @@ std::optional<RepeatedTestProto> wpi::Protobuf<RepeatedTestProto>::Unpack(
return toRet;
}
bool wpi::Protobuf<RepeatedTestProto>::Pack(OutputStream& stream,
bool wpi::util::Protobuf<RepeatedTestProto>::Pack(OutputStream& stream,
const RepeatedTestProto& value) {
wpi::PackCallback<double> double_msg{value.double_msg};
wpi::PackCallback<float> float_msg{value.float_msg};
wpi::PackCallback<int32_t> int32_msg{value.int32_msg};
wpi::PackCallback<int64_t> int64_msg{value.int64_msg};
wpi::PackCallback<uint32_t> uint32_msg{value.uint32_msg};
wpi::PackCallback<uint64_t> uint64_msg{value.uint64_msg};
wpi::PackCallback<int32_t> sint32_msg{value.sint32_msg};
wpi::PackCallback<int64_t> sint64_msg{value.sint64_msg};
wpi::PackCallback<uint32_t> fixed32_msg{value.fixed32_msg};
wpi::PackCallback<uint64_t> fixed64_msg{value.fixed64_msg};
wpi::PackCallback<int32_t> sfixed32_msg{value.sfixed32_msg};
wpi::PackCallback<int64_t> sfixed64_msg{value.sfixed64_msg};
wpi::PackCallback<bool> bool_msg{value.bool_msg};
wpi::PackCallback<std::string> string_msg{value.string_msg};
wpi::PackCallback<std::vector<uint8_t>> bytes_msg{value.bytes_msg};
wpi::PackCallback<TestProtoInner> TestProtoInner_msg{
wpi::util::PackCallback<double> double_msg{value.double_msg};
wpi::util::PackCallback<float> float_msg{value.float_msg};
wpi::util::PackCallback<int32_t> int32_msg{value.int32_msg};
wpi::util::PackCallback<int64_t> int64_msg{value.int64_msg};
wpi::util::PackCallback<uint32_t> uint32_msg{value.uint32_msg};
wpi::util::PackCallback<uint64_t> uint64_msg{value.uint64_msg};
wpi::util::PackCallback<int32_t> sint32_msg{value.sint32_msg};
wpi::util::PackCallback<int64_t> sint64_msg{value.sint64_msg};
wpi::util::PackCallback<uint32_t> fixed32_msg{value.fixed32_msg};
wpi::util::PackCallback<uint64_t> fixed64_msg{value.fixed64_msg};
wpi::util::PackCallback<int32_t> sfixed32_msg{value.sfixed32_msg};
wpi::util::PackCallback<int64_t> sfixed64_msg{value.sfixed64_msg};
wpi::util::PackCallback<bool> bool_msg{value.bool_msg};
wpi::util::PackCallback<std::string> string_msg{value.string_msg};
wpi::util::PackCallback<std::vector<uint8_t>> bytes_msg{value.bytes_msg};
wpi::util::PackCallback<TestProtoInner> TestProtoInner_msg{
value.TestProtoInner_msg};
wpi_proto_RepeatedTestProto msg{
.double_msg = double_msg.Callback(),
@@ -145,7 +145,7 @@ bool wpi::Protobuf<RepeatedTestProto>::Pack(OutputStream& stream,
}
namespace {
using ProtoType = wpi::Protobuf<RepeatedTestProto>;
using ProtoType = wpi::util::Protobuf<RepeatedTestProto>;
} // namespace
TEST(RepeatedTestProtoTest, RoundtripNanopb) {
@@ -155,8 +155,8 @@ TEST(RepeatedTestProtoTest, RoundtripNanopb) {
kExpectedData.double_msg.emplace_back(5.05);
wpi::ProtobufMessage<decltype(kExpectedData)> message;
wpi::SmallVector<uint8_t, 64> buf;
wpi::util::ProtobufMessage<decltype(kExpectedData)> message;
wpi::util::SmallVector<uint8_t, 64> buf;
ASSERT_TRUE(message.Pack(buf, kExpectedData));
auto unpacked_data = message.Unpack(buf);

View File

@@ -27,107 +27,107 @@ static std::vector<int> vec_values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
TEST(CircularSpanTest, Constexpr) {
{
constexpr wpi::rotated_span<const int, 10> sp{cesarr_values};
constexpr wpi::util::rotated_span<const int, 10> sp{cesarr_values};
static_assert(sp[5] == cesarr_values[5]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cearr_values};
constexpr wpi::util::rotated_span<const int, 10> sp{cearr_values};
static_assert(sp[5] == cearr_values[5]);
}
}
TEST(CircularSpanTest, ConstructConst) {
{
wpi::rotated_span<const int, 10> sp{csarr_values};
wpi::util::rotated_span<const int, 10> sp{csarr_values};
EXPECT_EQ(sp[5], sarr_values[5]);
}
{
wpi::rotated_span<const int> sp{csarr_values};
wpi::util::rotated_span<const int> sp{csarr_values};
EXPECT_EQ(sp[5], sarr_values[5]);
}
{
wpi::rotated_span<const int, 10> sp{carr_values};
wpi::util::rotated_span<const int, 10> sp{carr_values};
EXPECT_EQ(sp[5], arr_values[5]);
}
{
wpi::rotated_span<const int> sp{carr_values};
wpi::util::rotated_span<const int> sp{carr_values};
EXPECT_EQ(sp[5], arr_values[5]);
}
{
wpi::rotated_span<const int> sp{cvec_values.begin(), cvec_values.end()};
wpi::util::rotated_span<const int> sp{cvec_values.begin(), cvec_values.end()};
EXPECT_EQ(sp[5], vec_values[5]);
}
{
wpi::rotated_span<const int> sp{cvec_values.data(), cvec_values.size()};
wpi::util::rotated_span<const int> sp{cvec_values.data(), cvec_values.size()};
EXPECT_EQ(sp[5], vec_values[5]);
}
}
TEST(CircularSpanTest, ConstructNonConst) {
{
wpi::rotated_span<int, 10> sp{sarr_values};
wpi::util::rotated_span<int, 10> sp{sarr_values};
EXPECT_EQ(sp[5], sarr_values[5]);
}
{
wpi::rotated_span<int> sp{sarr_values};
wpi::util::rotated_span<int> sp{sarr_values};
EXPECT_EQ(sp[5], sarr_values[5]);
}
{
wpi::rotated_span<int, 10> sp{arr_values};
wpi::util::rotated_span<int, 10> sp{arr_values};
EXPECT_EQ(sp[5], arr_values[5]);
}
{
wpi::rotated_span<int> sp{arr_values};
wpi::util::rotated_span<int> sp{arr_values};
EXPECT_EQ(sp[5], arr_values[5]);
}
{
wpi::rotated_span<int> sp{vec_values.begin(), vec_values.end()};
wpi::util::rotated_span<int> sp{vec_values.begin(), vec_values.end()};
EXPECT_EQ(sp[5], vec_values[5]);
}
{
wpi::rotated_span<int> sp{vec_values.data(), vec_values.size()};
wpi::util::rotated_span<int> sp{vec_values.data(), vec_values.size()};
EXPECT_EQ(sp[5], vec_values[5]);
}
}
TEST(CircularSpanTest, ConstructRotated) {
{
constexpr wpi::rotated_span<const int, 10> sp{cesarr_values, 1};
constexpr wpi::util::rotated_span<const int, 10> sp{cesarr_values, 1};
static_assert(sp[5] == cesarr_values[6]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cesarr_values, 9};
constexpr wpi::util::rotated_span<const int, 10> sp{cesarr_values, 9};
static_assert(sp[5] == cesarr_values[4]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cesarr_values, 10};
constexpr wpi::util::rotated_span<const int, 10> sp{cesarr_values, 10};
static_assert(sp[5] == cesarr_values[5]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cesarr_values, 11};
constexpr wpi::util::rotated_span<const int, 10> sp{cesarr_values, 11};
static_assert(sp[5] == cesarr_values[6]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cearr_values, -1};
constexpr wpi::util::rotated_span<const int, 10> sp{cearr_values, -1};
static_assert(sp[5] == cearr_values[4]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cearr_values, -9};
constexpr wpi::util::rotated_span<const int, 10> sp{cearr_values, -9};
static_assert(sp[5] == cearr_values[6]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cearr_values, -10};
constexpr wpi::util::rotated_span<const int, 10> sp{cearr_values, -10};
static_assert(sp[5] == cearr_values[5]);
}
{
constexpr wpi::rotated_span<const int, 10> sp{cearr_values, -11};
constexpr wpi::util::rotated_span<const int, 10> sp{cearr_values, -11};
static_assert(sp[5] == cearr_values[4]);
}
}
TEST(CircularSpanTest, Rotate) {
constexpr wpi::rotated_span<const int, 10> sp{cesarr_values, 1};
constexpr wpi::util::rotated_span<const int, 10> sp{cesarr_values, 1};
static_assert(sp[5] == cesarr_values[6]);
static_assert(sp.rotate(2)[5] == cesarr_values[8]);
static_assert(sp.rotate(9)[5] == cesarr_values[5]);
@@ -140,10 +140,10 @@ TEST(CircularSpanTest, Rotate) {
static_assert(sp.rotate(-11)[5] == cesarr_values[5]);
}
void unsized_func(wpi::rotated_span<int>) {}
void const_unsized_func(wpi::rotated_span<const int>) {}
void sized_func(wpi::rotated_span<int, 10>) {}
void const_sized_func(wpi::rotated_span<const int, 10>) {}
void unsized_func(wpi::util::rotated_span<int>) {}
void const_unsized_func(wpi::util::rotated_span<const int>) {}
void sized_func(wpi::util::rotated_span<int, 10>) {}
void const_sized_func(wpi::util::rotated_span<const int, 10>) {}
TEST(CircularSpanTest, Implicit) {
// unsized_func(csarr_values); // error
@@ -168,7 +168,7 @@ TEST(CircularSpanTest, Implicit) {
}
TEST(CircularSpanTest, IteratorConst) {
wpi::rotated_span<const int> sp_sarr{csarr_values};
wpi::util::rotated_span<const int> sp_sarr{csarr_values};
// iterator
int i = 0;
@@ -186,7 +186,7 @@ TEST(CircularSpanTest, IteratorConst) {
}
TEST(CircularSpanTest, IteratorNonConst) {
wpi::rotated_span<int> sp_sarr{sarr_values};
wpi::util::rotated_span<int> sp_sarr{sarr_values};
// iterator
int i = 0;

View File

@@ -25,7 +25,7 @@
#include "wpi/util/sha1.hpp"
namespace wpi {
namespace wpi::util {
/*
* The 3 test vectors from FIPS PUB 180-1
@@ -87,4 +87,4 @@ TEST(SHA1Test, Concurrent) {
"a9993e364706816aba3e25717850c26c9cd0d89d"); /* "abc" */
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -37,7 +37,7 @@ SOFTWARE.
#include <gtest/gtest.h>
using namespace wpi::sig::trait;
using namespace wpi::util::sig::trait;
namespace {
@@ -114,7 +114,7 @@ static_assert(is_callable_v<t, o8>, "");
} // namespace
namespace wpi {
namespace wpi::util {
TEST(SignalTest, FunctionTraits) {
auto l1 = [](int, char, float) {};
@@ -129,4 +129,4 @@ TEST(SignalTest, FunctionTraits) {
f2(0, '0', 0.0);
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -56,12 +56,12 @@ struct object {
}
T v;
wpi::sig::Signal_r<T> sig;
wpi::util::sig::Signal_r<T> sig;
};
} // namespace
namespace wpi {
namespace wpi::util {
TEST(SignalTest, Recursive) {
object<int> i1(-1);
@@ -78,7 +78,7 @@ TEST(SignalTest, Recursive) {
TEST(SignalTest, SelfRecursive) {
int i = 0;
wpi::sig::Signal_r<int> s;
wpi::util::sig::Signal_r<int> s;
s.connect([&](int v) {
if (i < 10) {
i++;
@@ -91,4 +91,4 @@ TEST(SignalTest, SelfRecursive) {
ASSERT_EQ(i, 10);
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -35,7 +35,7 @@ SOFTWARE.
#include <gtest/gtest.h>
using namespace wpi::sig;
using namespace wpi::util::sig;
namespace {
@@ -66,7 +66,7 @@ struct o {
} // namespace
namespace wpi {
namespace wpi::util {
TEST(SignalExtendedTest, FreeConnection) {
sum = 0;
@@ -134,4 +134,4 @@ TEST(SignalExtendedTest, LambdaConnection) {
ASSERT_EQ(sum, 3);
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -39,7 +39,7 @@ SOFTWARE.
#include <gtest/gtest.h>
using namespace wpi::sig;
using namespace wpi::util::sig;
namespace {
@@ -66,7 +66,7 @@ void connect_emit(Signal_mt<int>& sig) {
} // namespace
namespace wpi {
namespace wpi::util {
TEST(SignalTest, ThreadedMix) {
sum = 0;
@@ -101,4 +101,4 @@ TEST(SignalTest, ThreadedEmission) {
ASSERT_EQ(sum, 100000);
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -40,7 +40,7 @@ SOFTWARE.
#include <gtest/gtest.h>
using namespace wpi::sig;
using namespace wpi::util::sig;
namespace {
@@ -71,7 +71,7 @@ static_assert(trait::is_callable_v<trait::typelist<int>, decltype(&s::f1),
} // namespace
namespace wpi {
namespace wpi::util {
TEST(SignalTest, TrackShared) {
sum = 0;
@@ -178,4 +178,4 @@ TEST(SignalTest, TrackGenericLambda) {
ASSERT_EQ(s.str(), "1foo4.1");
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -40,7 +40,7 @@ SOFTWARE.
#include <gtest/gtest.h>
using namespace wpi::sig;
using namespace wpi::util::sig;
namespace {
@@ -99,7 +99,7 @@ struct o8 {
} // namespace
namespace wpi {
namespace wpi::util {
TEST(SignalTest, FreeConnection) {
sum = 0;
@@ -539,4 +539,4 @@ TEST(SignalTest, Loop) {
ASSERT_EQ(i2.val(), 1);
}
} // namespace wpi
} // namespace wpi::util

View File

@@ -15,12 +15,12 @@
static std::mutex std_mutex;
static std::recursive_mutex std_recursive_mutex;
static wpi::mutex wpi_mutex;
static wpi::recursive_mutex wpi_recursive_mutex;
static wpi::spinlock spinlock;
static wpi::recursive_spinlock1 recursive_spinlock1;
static wpi::recursive_spinlock2 recursive_spinlock2;
static wpi::recursive_spinlock recursive_spinlock;
static wpi::util::mutex wpi_mutex;
static wpi::util::recursive_mutex wpi_recursive_mutex;
static wpi::util::spinlock spinlock;
static wpi::util::recursive_spinlock1 recursive_spinlock1;
static wpi::util::recursive_spinlock2 recursive_spinlock2;
static wpi::util::recursive_spinlock recursive_spinlock;
TEST(SpinlockTest, Benchmark) {
using std::chrono::duration_cast;
@@ -52,7 +52,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("std::mutex sizeof: {} time: {} value: {}\n", sizeof(std_mutex),
wpi::util::print("std::mutex sizeof: {} time: {} value: {}\n", sizeof(std_mutex),
duration_cast<microseconds>(stop - start).count(), value);
});
thrb.join();
@@ -66,7 +66,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("std::recursive_mutex sizeof: {} time: {} value: {}\n",
wpi::util::print("std::recursive_mutex sizeof: {} time: {} value: {}\n",
sizeof(std_recursive_mutex),
duration_cast<microseconds>(stop - start).count(), value);
});
@@ -81,7 +81,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("wpi::mutex sizeof: {} time: {} value: {}\n", sizeof(wpi_mutex),
wpi::util::print("wpi::util::mutex sizeof: {} time: {} value: {}\n", sizeof(wpi_mutex),
duration_cast<microseconds>(stop - start).count(), value);
});
thr2.join();
@@ -95,7 +95,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("wpi::recursive_mutex sizeof: {} time: {} value: {}\n",
wpi::util::print("wpi::util::recursive_mutex sizeof: {} time: {} value: {}\n",
sizeof(wpi_recursive_mutex),
duration_cast<microseconds>(stop - start).count(), value);
});
@@ -110,7 +110,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("spinlock sizeof: {} time: {} value: {}\n", sizeof(spinlock),
wpi::util::print("spinlock sizeof: {} time: {} value: {}\n", sizeof(spinlock),
duration_cast<microseconds>(stop - start).count(), value);
});
thr3.join();
@@ -124,7 +124,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("recursive_spinlock1 sizeof: {} time: {} value: {}\n",
wpi::util::print("recursive_spinlock1 sizeof: {} time: {} value: {}\n",
sizeof(recursive_spinlock1),
duration_cast<microseconds>(stop - start).count(), value);
});
@@ -139,7 +139,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("recursive_spinlock2 sizeof: {} time: {} value: {}\n",
wpi::util::print("recursive_spinlock2 sizeof: {} time: {} value: {}\n",
sizeof(recursive_spinlock2),
duration_cast<microseconds>(stop - start).count(), value);
});
@@ -154,7 +154,7 @@ TEST(SpinlockTest, Benchmark) {
++value;
}
auto stop = high_resolution_clock::now();
wpi::print("recursive_spinlock sizeof: {} time: {} value: {}\n",
wpi::util::print("recursive_spinlock sizeof: {} time: {} value: {}\n",
sizeof(recursive_spinlock),
duration_cast<microseconds>(stop - start).count(), value);
});

View File

@@ -13,7 +13,7 @@
#include <gtest/gtest.h>
using namespace wpi;
using namespace wpi::util;
class DynamicStructTest : public ::testing::Test {
protected:
@@ -299,7 +299,7 @@ TEST_F(DynamicStructTest, StringAllZeros) {
uint8_t data[32];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_EQ(dynamic.GetStringField(field), "");
}
@@ -309,7 +309,7 @@ TEST_F(DynamicStructTest, StringRoundTrip) {
uint8_t data[32];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_TRUE(dynamic.SetStringField(field, "abc"));
EXPECT_EQ(dynamic.GetStringField(field), "abc");
@@ -320,7 +320,7 @@ TEST_F(DynamicStructTest, StringRoundTripEmbeddedNull) {
uint8_t data[32];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
std::string check{"ab\0c", 4};
ASSERT_EQ(check.size(), 4u);
@@ -335,7 +335,7 @@ TEST_F(DynamicStructTest, StringRoundTripTooLong) {
uint8_t data[2];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, "abc"));
auto get = dynamic.GetStringField(field);
@@ -348,7 +348,7 @@ TEST_F(DynamicStructTest, StringRoundTripPartial2ByteUtf8) {
uint8_t data[2];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, "a\u0234"));
auto get = dynamic.GetStringField(field);
@@ -361,7 +361,7 @@ TEST_F(DynamicStructTest, StringRoundTrip2ByteUtf8) {
uint8_t data[3];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_TRUE(dynamic.SetStringField(field, "a\u0234"));
auto get = dynamic.GetStringField(field);
@@ -374,7 +374,7 @@ TEST_F(DynamicStructTest, StringRoundTrip3ByteUtf8) {
uint8_t data[4];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_TRUE(dynamic.SetStringField(field, "a\u1234"));
auto get = dynamic.GetStringField(field);
@@ -387,7 +387,7 @@ TEST_F(DynamicStructTest, StringRoundTrip3ByteUtf8PartialFirstByte) {
uint8_t data[2];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, "a\u1234"));
auto get = dynamic.GetStringField(field);
@@ -400,7 +400,7 @@ TEST_F(DynamicStructTest, StringRoundTrip3ByteUtf8PartialSecondByte) {
uint8_t data[3];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, "a\u1234"));
auto get = dynamic.GetStringField(field);
@@ -420,7 +420,7 @@ TEST_F(DynamicStructTest, StringRoundTrip4ByteUtf8) {
uint8_t data[5];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_TRUE(dynamic.SetStringField(field, fourByteUtf8String));
auto get = dynamic.GetStringField(field);
@@ -433,7 +433,7 @@ TEST_F(DynamicStructTest, StringRoundTrip4ByteUtf8PartialFirstByte) {
uint8_t data[2];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, fourByteUtf8String));
auto get = dynamic.GetStringField(field);
@@ -446,7 +446,7 @@ TEST_F(DynamicStructTest, StringRoundTrip4ByteUtf8PartialSecondByte) {
uint8_t data[3];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, fourByteUtf8String));
auto get = dynamic.GetStringField(field);
@@ -459,7 +459,7 @@ TEST_F(DynamicStructTest, StringRoundTrip4ByteUtf8PartialThirdByte) {
uint8_t data[4];
std::memset(data, 0, sizeof(data));
ASSERT_EQ(desc->GetSize(), sizeof(data) / sizeof(data[0]));
wpi::MutableDynamicStruct dynamic{desc, data};
wpi::util::MutableDynamicStruct dynamic{desc, data};
auto field = desc->FindFieldByName("a");
EXPECT_FALSE(dynamic.SetStringField(field, fourByteUtf8String));
auto get = dynamic.GetStringField(field);
@@ -559,7 +559,7 @@ TEST_P(DynamicSimpleStructTest, IntRoundTrip) {
std::vector<uint8_t> dest(desc->GetSize());
auto field = desc->FindFieldByName("a");
ASSERT_TRUE(field);
wpi::MutableDynamicStruct dynamic(desc, dest);
wpi::util::MutableDynamicStruct dynamic(desc, dest);
if (GetParam().isInt) {
{
int64_t value = SignExtend(GetParam().minVal, field->GetSize());

View File

@@ -6,7 +6,7 @@
#include <gtest/gtest.h>
using namespace wpi::structparser;
using namespace wpi::util::structparser;
TEST(StructParserTest, Empty) {
Parser p{""};

View File

@@ -17,7 +17,7 @@
#include "wpi/util/TestPrinters.hpp"
namespace wpi {
namespace wpi::util {
template <typename T>
class SpanMatcher : public ::testing::MatcherInterface<std::span<T>> {
@@ -68,7 +68,7 @@ void SpanMatcher<T>::DescribeNegationTo(::std::ostream* os) const {
PrintTo(std::span<T>{good}, os);
}
} // namespace wpi
} // namespace wpi::util
inline std::span<const uint8_t> operator""_us(const char* str, size_t len) {
return {reinterpret_cast<const uint8_t*>(str), len};

View File

@@ -13,7 +13,7 @@
#include "wpi/util/json.hpp"
namespace wpi {
namespace wpi::util {
inline void PrintTo(std::string_view str, ::std::ostream* os) {
::testing::internal::PrintStringTo(std::string{str}, os);
@@ -38,4 +38,4 @@ inline void PrintTo(const json& val, ::std::ostream* os) {
*os << val.dump();
}
} // namespace wpi
} // namespace wpi::util