From ef73a2bd322c7df43922cd4b4ed4f49440b1b92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 27 Nov 2016 00:40:02 +0100 Subject: NOISSUE fix Windows kernel numbers and add unit test for them --- libraries/ganalytics/CMakeLists.txt | 6 ++++++ libraries/ganalytics/src/sys_test.cpp | 22 ++++++++++++++++++++++ libraries/ganalytics/src/sys_win32.cpp | 1 + 3 files changed, 29 insertions(+) create mode 100644 libraries/ganalytics/src/sys_test.cpp (limited to 'libraries/ganalytics') diff --git a/libraries/ganalytics/CMakeLists.txt b/libraries/ganalytics/CMakeLists.txt index 1f2ff4e2..9d218c6d 100644 --- a/libraries/ganalytics/CMakeLists.txt +++ b/libraries/ganalytics/CMakeLists.txt @@ -25,3 +25,9 @@ endif() add_library(ganalytics STATIC ${ganalytics_SOURCES}) qt5_use_modules(ganalytics Core Gui Network) target_include_directories(ganalytics PUBLIC include) + +include (UnitTest) +add_unit_test(sys + SOURCES src/sys_test.cpp + LIBS ganalytics +) diff --git a/libraries/ganalytics/src/sys_test.cpp b/libraries/ganalytics/src/sys_test.cpp new file mode 100644 index 00000000..6221da45 --- /dev/null +++ b/libraries/ganalytics/src/sys_test.cpp @@ -0,0 +1,22 @@ +#include +#include "TestUtil.h" + +#include + +class SysTest : public QObject +{ + Q_OBJECT +private +slots: + + void test_kernelNotNull() + { + auto kinfo = Sys::getKernelInfo(); + QVERIFY(!kinfo.kernelName.isEmpty()); + QVERIFY(kinfo.kernelVersion != "0.0"); + } +}; + +QTEST_GUILESS_MAIN(SysTest) + +#include "sys_test.moc" diff --git a/libraries/ganalytics/src/sys_win32.cpp b/libraries/ganalytics/src/sys_win32.cpp index 4d43169b..502b980d 100644 --- a/libraries/ganalytics/src/sys_win32.cpp +++ b/libraries/ganalytics/src/sys_win32.cpp @@ -8,6 +8,7 @@ Sys::KernelInfo Sys::getKernelInfo() out.kernelName = "Windows"; OSVERSIONINFOW osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFOW)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); GetVersionExW(&osvi); out.kernelVersion = QString("%1.%2").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion); return out; -- cgit v1.2.3