IteratorTest.cpp
MappedIteratorTest.cpp
MapVectorTest.cpp
+ MoveOnly.cpp
OptionalTest.cpp
PackedVectorTest.cpp
PointerEmbeddedIntTest.cpp
--- /dev/null
+//===- llvm/unittest/ADT/MoveOnly.cpp - Optional unit tests ---------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "MoveOnly.h"
+
+using namespace llvm;
+
+unsigned MoveOnly::MoveConstructions = 0;
+unsigned MoveOnly::Destructions = 0;
+unsigned MoveOnly::MoveAssignments = 0;
--- /dev/null
+//===- llvm/unittest/ADT/MoveOnly.h - Optional unit tests -----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_UNITTESTS_ADT_MOVEONLY_H
+#define LLVM_UNITTESTS_ADT_MOVEONLY_H
+
+namespace llvm {
+
+struct MoveOnly {
+ static unsigned MoveConstructions;
+ static unsigned Destructions;
+ static unsigned MoveAssignments;
+ int val;
+ explicit MoveOnly(int val) : val(val) {
+ }
+ MoveOnly(MoveOnly&& other) {
+ val = other.val;
+ ++MoveConstructions;
+ }
+ MoveOnly &operator=(MoveOnly&& other) {
+ val = other.val;
+ ++MoveAssignments;
+ return *this;
+ }
+ ~MoveOnly() {
+ ++Destructions;
+ }
+ static void ResetCounts() {
+ MoveConstructions = 0;
+ Destructions = 0;
+ MoveAssignments = 0;
+ }
+};
+
+} // end namespace llvm
+
+#endif // LLVM_UNITTESTS_ADT_MOVEONLY_H
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/raw_ostream.h"
+#include "MoveOnly.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
EXPECT_EQ(2u, MultiArgConstructor::Destructions);
}
-struct MoveOnly {
- static unsigned MoveConstructions;
- static unsigned Destructions;
- static unsigned MoveAssignments;
- int val;
- explicit MoveOnly(int val) : val(val) {
- }
- MoveOnly(MoveOnly&& other) {
- val = other.val;
- ++MoveConstructions;
- }
- MoveOnly &operator=(MoveOnly&& other) {
- val = other.val;
- ++MoveAssignments;
- return *this;
- }
- ~MoveOnly() {
- ++Destructions;
- }
- static void ResetCounts() {
- MoveConstructions = 0;
- Destructions = 0;
- MoveAssignments = 0;
- }
-};
-
-unsigned MoveOnly::MoveConstructions = 0;
-unsigned MoveOnly::Destructions = 0;
-unsigned MoveOnly::MoveAssignments = 0;
-
static_assert(!std::is_trivially_copyable_v<Optional<MoveOnly>>,
"not trivially copyable");