Add unit tests for increased coverage 48/316448/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Wed, 21 Aug 2024 10:28:05 +0000 (12:28 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 29 Aug 2024 07:47:14 +0000 (09:47 +0200)
Change-Id: Ifbb5ad446b4aa4c2d350f630ea713cd2d7bbbb9d

test/test_misc.cpp

index d4879ba91b31cb578d34a6a8c96f1fb602c70149..d536b122ce4bdd8cf20d7091bf8822eb6c692486 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2022 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2024 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * This file is licensed under the terms of MIT License or the Apache License
  * Version 2.0 of your choice. See the LICENSE.MIT file for MIT license details.
  */
 
 #include <algorithm>
+#include <check-proper-drop.h>
 #include <credentials.h>
+#include <dpl/errno_string.h>
+#include <dpl/exception.h>
 #include <string>
 #include <stdexcept>
-#include <dpl/exception.h>
 #include <security-manager-types.h>
 #include <sys/types.h>
 #include <utils.h>
@@ -209,4 +211,25 @@ POSITIVE_TEST_CASE(T293_possiblyUnterminatedArrayToString)
     BOOST_REQUIRE_EQUAL("", possiblyUnterminatedArrayToString(a));
 }
 
+POSITIVE_TEST_CASE(T294_checkThreads)
+{
+    pid_t myTid = gettid();
+    auto tids = CheckProperDrop::checkThreads(myTid);
+    BOOST_REQUIRE_MESSAGE(tids.count(myTid) == 0,  "CheckProperDrop::checkThreads includes own tid");
+}
+
+POSITIVE_TEST_CASE(T295_GetErrnoString)
+{
+    std::string str = GetErrnoString(EINVAL);
+    BOOST_REQUIRE_MESSAGE(str != "", "empty string from GetErrnoString");
+}
+
+NEGATIVE_TEST_CASE(T296_GetErrnoString)
+{
+    int err = -1;
+    std::string str = GetErrnoString(err);
+    BOOST_REQUIRE_MESSAGE(str != "", "empty string from GetErrnoString");
+}
+
+
 BOOST_AUTO_TEST_SUITE_END()