RUNNER_ASSERT wrappers moved to ckm-common.h
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 26 Jan 2015 13:04:46 +0000 (14:04 +0100)
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>
Wed, 18 Feb 2015 09:45:10 +0000 (10:45 +0100)
[Issue#] N/A
[Feature/Bug] N/A
[Problem] N/A
[Cause] Wrappers for RUNNER_ASSERT could be used by other tests.
[Solution] Wrappers moved to ckm-common.h

[Verification] Successfull compilation

Change-Id: Id9766c09d07c142814c3f3acd65a7b581ab5a061

tests/ckm/capi-certificate-chains.cpp
tests/ckm/ckm-common.h

index 8226a37..49a366a 100644 (file)
@@ -229,36 +229,6 @@ enum CertIdx{
     CERT_TEST_LEAF,    // test certificate signed with CERT_TEST_IM_CA
 };
 
-template <typename F, typename... Args>
-void assert_result(int expected, F&& func, Args... args)
-{
-    int ret = func(args...);
-    RUNNER_ASSERT_MSG_BT(ret == expected, "Expected " << expected << " got: " << ret);
-}
-
-template <typename F, typename... Args>
-void assert_positive(F&& func, Args... args)
-{
-    assert_result(CKMC_ERROR_NONE, std::move(func), args...);
-}
-
-template <typename F, typename... Args>
-void assert_invalid_param(F&& func, Args... args)
-{
-    assert_result(CKMC_ERROR_INVALID_PARAMETER, std::move(func), args...);
-}
-
-template <typename T>
-size_t list_size(const T* list)
-{
-    size_t size = 0;
-    while(list) {
-        list = list->next;
-        size++;
-    }
-    return size;
-}
-
 typedef std::unique_ptr<ckmc_cert_s, void (*)(ckmc_cert_s*)> CertPtr;
 typedef std::unique_ptr<ckmc_cert_list_s, void (*)(ckmc_cert_list_s*)> CertListPtr;
 typedef std::unique_ptr<ckmc_alias_list_s, void (*)(ckmc_alias_list_s*)> AliasListPtr;
index 3d0695a..3b0d514 100644 (file)
 #include <unordered_set>
 #include <memory>
 #include <ckm/ckm-type.h>
+#include <ckmc/ckmc-error.h>
+#include <tests_common.h>
 
 void switch_to_storage_user(const char* label);
 void switch_to_storage_ocsp_user(const char* label);
 
 
+// RUNNER_ASSERT wrappers
+template <typename F, typename... Args>
+void assert_result(int expected, F&& func, Args... args)
+{
+    int ret = func(args...);
+    RUNNER_ASSERT_MSG_BT(ret == expected, "Expected " << expected << " got: " << ret);
+}
+
+template <typename F, typename... Args>
+void assert_positive(F&& func, Args... args)
+{
+    assert_result(CKMC_ERROR_NONE, std::move(func), args...);
+}
+
+template <typename F, typename... Args>
+void assert_invalid_param(F&& func, Args... args)
+{
+    assert_result(CKMC_ERROR_INVALID_PARAMETER, std::move(func), args...);
+}
+
+
+// list operations
+template <typename T>
+size_t list_size(const T* list)
+{
+    size_t size = 0;
+    while(list) {
+        list = list->next;
+        size++;
+    }
+    return size;
+}
+
+
 // service lifecycle management
 enum ServiceIdx {
     LISTENER,