tests: adjust self-copy tests
There are a couple tests which attempt to copy an object onto itself via
a `std::move`. GCC 13 catches this as a "move onto self" and flags it
as an error. Rather than use the `std::move`, perform a static_cast
into an r-value reference so that the same copy-constructor is called
as if the std::move were successfully used.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I097889578492b1a3ab456e8cb21a668aa0855be4
diff --git a/phosphor-regulators/test/temporary_file_tests.cpp b/phosphor-regulators/test/temporary_file_tests.cpp
index 7fe0a4d..b3bcb60 100644
--- a/phosphor-regulators/test/temporary_file_tests.cpp
+++ b/phosphor-regulators/test/temporary_file_tests.cpp
@@ -112,7 +112,7 @@
fs::path path = file.getPath();
// Try to move object into itself; should do nothing
- file = std::move(file);
+ file = static_cast<TemporaryFile&&>(file);
// Verify object still owns same temporary file and file exists
EXPECT_EQ(file.getPath(), path);
diff --git a/test/file_descriptor_tests.cpp b/test/file_descriptor_tests.cpp
index 4273086..ad63dd7 100644
--- a/test/file_descriptor_tests.cpp
+++ b/test/file_descriptor_tests.cpp
@@ -131,7 +131,7 @@
EXPECT_TRUE(isValid(fd));
// Try to move object into itself
- descriptor = std::move(descriptor);
+ descriptor = static_cast<FileDescriptor&&>(descriptor);
// Verify object still contains file descriptor
EXPECT_EQ(descriptor(), fd);