pw_toolchain: Test trivially destructible class
Change-Id: I6500802d60e3c2f1a52368aec0daf10079faad20
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/159232
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
diff --git a/pw_toolchain/no_destructor_test.cc b/pw_toolchain/no_destructor_test.cc
index 936cedd..38f3c59 100644
--- a/pw_toolchain/no_destructor_test.cc
+++ b/pw_toolchain/no_destructor_test.cc
@@ -43,6 +43,13 @@
~CrashInDestructor() { PW_CRASH("This destructor should never execute!"); }
};
+class TrivialDestructor {
+ public:
+ TrivialDestructor(int initial_value) : value(initial_value) {}
+
+ int value;
+};
+
TEST(NoDestructor, ShouldNotCallDestructor) {
bool destructor_called = false;
@@ -63,6 +70,14 @@
EXPECT_EQ(no_destructor.operator->(), no_destructor->MyAddress());
}
+TEST(NoDestructor, TrivialDestructor) {
+ NoDestructor<TrivialDestructor> no_destructor(555);
+
+ EXPECT_EQ(no_destructor->value, 555);
+ no_destructor->value = 123;
+ EXPECT_EQ(no_destructor->value, 123);
+}
+
TEST(NoDestructor, TrivialType) {
NoDestructor<int> no_destructor;