From cd1e3c115d0cfea7ce2de75fec04e62d4db92f0c Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 14 Nov 2019 06:00:06 +0300 Subject: [PATCH] unittests: added db_accessor_tests.dtor_without_init (exposes a minor bug) --- tests/unit_tests/db_accessors.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit_tests/db_accessors.cpp b/tests/unit_tests/db_accessors.cpp index c2be6870..823a0358 100644 --- a/tests/unit_tests/db_accessors.cpp +++ b/tests/unit_tests/db_accessors.cpp @@ -428,3 +428,23 @@ TEST(db_accessor_tests, median_db_cache_test) m_naive_median.print_to_file(folder_name + "/naive_median_2.txt"); } + + +TEST(db_accessor_tests, dtor_without_init) +{ + epee::shared_recursive_mutex m_rw_lock; + + { + tools::db::basic_db_accessor m_db(nullptr, m_rw_lock); + ASSERT_FALSE(m_db.is_open()); + } + + // make sure dtor called successfully with no exceptions + + { + tools::db::basic_db_accessor m_db(nullptr, m_rw_lock); + m_db.close(); + ASSERT_FALSE(m_db.is_open()); + } + +}