summaryrefslogtreecommitdiff
path: root/src/compat/option_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat/option_test.cpp')
-rw-r--r--src/compat/option_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/compat/option_test.cpp b/src/compat/option_test.cpp
index b963a29..ac95424 100644
--- a/src/compat/option_test.cpp
+++ b/src/compat/option_test.cpp
@@ -117,6 +117,41 @@ TEST(Option, customrepr)
}
}
+TEST(Option, destruct)
+{
+ struct BugCheck
+ {
+ bool *destroyed;
+
+ BugCheck(bool *d)
+ : destroyed(d)
+ {}
+ BugCheck(BugCheck&& r)
+ : destroyed(r.destroyed)
+ {
+ r.destroyed = nullptr;
+ }
+ BugCheck& operator = (BugCheck&& r)
+ {
+ std::swap(destroyed, r.destroyed);
+ return *this;
+ }
+ ~BugCheck()
+ {
+ if (!destroyed)
+ return;
+ if (*destroyed)
+ abort();
+ *destroyed = true;
+ }
+ };
+
+ bool destroyed = false;
+
+ Option<BugCheck> bug = Some(BugCheck(&destroyed));
+ bug = None;
+}
+
TEST(Option, def)
{
struct Tracked