2022-01-14 23:53:12 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// 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 "gtest/gtest.h"
|
|
|
|
|
#include "wpi/array.h"
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
class MoveOnlyType {
|
|
|
|
|
public:
|
|
|
|
|
MoveOnlyType() = default;
|
|
|
|
|
MoveOnlyType(MoveOnlyType&&) = default;
|
|
|
|
|
MoveOnlyType& operator=(MoveOnlyType&&) = default;
|
|
|
|
|
};
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
TEST(ArrayTest, CopyableTypeCompiles) {
|
2022-05-31 20:21:29 -07:00
|
|
|
constexpr wpi::array<int, 3> arr1{1, 2, 3};
|
|
|
|
|
static_cast<void>(arr1);
|
2022-01-14 23:53:12 -08:00
|
|
|
|
|
|
|
|
// Test deduction guide
|
2022-05-31 20:21:29 -07:00
|
|
|
constexpr wpi::array arr2{1, 2, 3};
|
|
|
|
|
static_cast<void>(arr2);
|
2022-01-14 23:53:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(ArrayTest, MoveOnlyTypeCompiles) {
|
2022-05-31 20:21:29 -07:00
|
|
|
constexpr wpi::array<MoveOnlyType, 3> arr1{MoveOnlyType{}, MoveOnlyType{},
|
|
|
|
|
MoveOnlyType{}};
|
|
|
|
|
static_cast<void>(arr1);
|
2022-01-14 23:53:12 -08:00
|
|
|
|
|
|
|
|
// Test deduction guide
|
2022-05-31 20:21:29 -07:00
|
|
|
constexpr wpi::array arr2{MoveOnlyType{}, MoveOnlyType{}, MoveOnlyType{}};
|
|
|
|
|
static_cast<void>(arr2);
|
2022-01-14 23:53:12 -08:00
|
|
|
}
|