From 94936fd4c98ff367a495533ca1e1bdb7a93312cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 22 Aug 2024 00:04:56 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-testing:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20?= =?UTF-8?q?=D1=81=20=D0=B4=D1=80=D1=83=D0=B3=D0=B8=D0=BC=D0=B8=20=D1=84?= =?UTF-8?q?=D0=BB=D0=B0=D0=B3=D0=B0=D0=BC=D0=B8/=D0=BE=D0=BF=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=D0=BC=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/CMakeLists.txt | 7 +++++++ test/extra/dbi.c++ | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/extra/dbi.c++ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c334601d..f945255d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -124,6 +124,13 @@ if(UNIX AND NOT SUBPROJECT) set_target_properties(test_extra_crunched_delete PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON) endif() + add_executable(test_extra_dbi extra/dbi.c++) + target_include_directories(test_extra_dbi PRIVATE "${PROJECT_SOURCE_DIR}") + target_link_libraries(test_extra_dbi ${TOOL_MDBX_LIB}) + if(MDBX_CXX_STANDARD) + set_target_properties(test_extra_dbi PROPERTIES + CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON) + endif() endif() endif() diff --git a/test/extra/dbi.c++ b/test/extra/dbi.c++ new file mode 100644 index 00000000..86dd0c4d --- /dev/null +++ b/test/extra/dbi.c++ @@ -0,0 +1,41 @@ +#include "mdbx.h++" + +#include + +static char log_buffer[1024]; + +static void logger_nofmt(MDBX_log_level_t loglevel, const char *function, + int line, const char *msg, unsigned length) noexcept { + (void)length; + (void)loglevel; + fprintf(stdout, "%s:%u %s", function, line, msg); +} + +int main(int argc, const char *argv[]) { + (void)argc; + (void)argv; + + mdbx_setup_debug_nofmt(MDBX_LOG_NOTICE, MDBX_DBG_ASSERT, logger_nofmt, + log_buffer, sizeof(log_buffer)); + + mdbx::path path = "test-dbi"; + mdbx::env::remove(path); + + mdbx::env::operate_parameters operateParameters(100, 10); + mdbx::env_managed::create_parameters createParameters; + { + mdbx::env_managed env2(path, createParameters, operateParameters); + mdbx::txn_managed txn2 = env2.start_write(false); + /* mdbx::map_handle testHandle2 = */ txn2.create_map( + "fap1", mdbx::key_mode::reverse, mdbx::value_mode::single); + txn2.commit(); + } + mdbx::env_managed env(path, createParameters, operateParameters); + mdbx::txn_managed txn = env.start_write(false); + /* mdbx::map_handle testHandle = */ txn.create_map( + "fap1", mdbx::key_mode::usual, mdbx::value_mode::single); + txn.commit(); + + std::cout << "OK\n"; + return EXIT_SUCCESS; +}