From: Shane Jaroch Date: Thu, 22 Jan 2026 05:37:22 +0000 (-0500) Subject: add some tests X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=2f934d17647573adc1dcf0b0f3629c0aaa35d1ca;p=nutratech%2Fgui.git add some tests --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a171700..f4c8dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,12 @@ target_link_libraries(test_nutra PRIVATE Qt${QT_VERSION_MAJOR}::Test Qt${QT_VERS add_test(NAME FoodRepoTest COMMAND test_nutra) -add_executable(test_databasemanager tests/test_databasemanager.cpp src/db/databasemanager.cpp src/db/foodrepository.cpp src/utils/string_utils.cpp) +file(GLOB_RECURSE TEST_DB_SOURCES + tests/test_databasemanager.cpp + src/db/*.cpp + src/utils/*.cpp +) +add_executable(test_databasemanager ${TEST_DB_SOURCES}) target_include_directories(test_databasemanager PRIVATE ${CMAKE_SOURCE_DIR}/include) target_link_libraries(test_databasemanager PRIVATE Qt${QT_VERSION_MAJOR}::Test Qt${QT_VERSION_MAJOR}::Sql) add_test(NAME DatabaseManagerTest COMMAND test_databasemanager) diff --git a/src/widgets/preferencesdialog.cpp b/src/widgets/preferencesdialog.cpp index 9ae17ec..3586636 100644 --- a/src/widgets/preferencesdialog.cpp +++ b/src/widgets/preferencesdialog.cpp @@ -122,7 +122,7 @@ void PreferencesDialog::save() { settings.setValue("searchDebounce", debounceSpin->value()); // Save Profile - if (profileWidget) profileWidget->save(); + if (profileWidget != nullptr) profileWidget->save(); // RDA saves automatically on edit in its own widget (checking RDASettingsWidget design // recommended, assuming yes for now or needs explicit save call if it supports it) Actually diff --git a/src/widgets/profilesettingswidget.cpp b/src/widgets/profilesettingswidget.cpp index 339e371..5493055 100644 --- a/src/widgets/profilesettingswidget.cpp +++ b/src/widgets/profilesettingswidget.cpp @@ -145,8 +145,8 @@ void ProfileSettingsWidget::loadProfile() { heightSpin->setValue(q.value(4).toDouble()); int act = q.value(5).toInt(); - if (act < 1) act = 1; - if (act > 5) act = 5; + act = std::max(act, 1); + act = std::min(act, 5); activitySlider->setValue(act); } else { // Default insert if missing? diff --git a/src/widgets/searchwidget.cpp b/src/widgets/searchwidget.cpp index 4760db0..2f2cce8 100644 --- a/src/widgets/searchwidget.cpp +++ b/src/widgets/searchwidget.cpp @@ -251,6 +251,6 @@ void SearchWidget::onCompleterActivated(const QString& text) { void SearchWidget::reloadSettings() { QSettings settings("NutraTech", "Nutra"); int debounce = settings.value("searchDebounce", 600).toInt(); - if (debounce < 250) debounce = 250; + debounce = std::max(debounce, 250); searchTimer->setInterval(debounce); }