summaryrefslogtreecommitdiff
path: root/src/components/utils
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2016-04-26 12:41:54 +0300
committerKozoriz <kozorizandriy@gmail.com>2016-04-26 15:50:21 +0300
commit4ecdb2a83871784f34430ed09d5ef6a2c0855506 (patch)
treedc36b449e5d32ac3e493e16865cf9d88d9991817 /src/components/utils
parentcf58bb97d09c536dce3b492d1517da0b837bc8eb (diff)
downloadsdl_core-4ecdb2a83871784f34430ed09d5ef6a2c0855506.tar.gz
Format all code in project
Formated all code in appMain, components, plugins to correct coding-style Used clang-format-3.6 Used 2 commands : find src/appMain/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file find src/components/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file find src/plugins/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
Diffstat (limited to 'src/components/utils')
-rw-r--r--src/components/utils/include/utils/appenders_loader.h1
-rw-r--r--src/components/utils/include/utils/back_trace.h6
-rw-r--r--src/components/utils/include/utils/bitstream.h35
-rw-r--r--src/components/utils/include/utils/convert_utils.h1
-rw-r--r--src/components/utils/include/utils/file_system.h13
-rw-r--r--src/components/utils/include/utils/helpers.h120
-rw-r--r--src/components/utils/include/utils/log_message_loop_thread.h11
-rw-r--r--src/components/utils/include/utils/qdb_wrapper/sql_database.h1
-rw-r--r--src/components/utils/include/utils/qdb_wrapper/sql_error.h4
-rw-r--r--src/components/utils/include/utils/qdb_wrapper/sql_query.h2
-rw-r--r--src/components/utils/include/utils/resource_usage.h27
-rw-r--r--src/components/utils/include/utils/signals.h2
-rw-r--r--src/components/utils/include/utils/singleton.h98
-rw-r--r--src/components/utils/include/utils/sqlite_wrapper/sql_error.h62
-rw-r--r--src/components/utils/include/utils/stl_utils.h27
-rw-r--r--src/components/utils/include/utils/threads/pulse_thread_delegate.h43
-rw-r--r--src/components/utils/include/utils/threads/thread_manager.h7
-rw-r--r--src/components/utils/include/utils/threads/thread_validator.h7
-rw-r--r--src/components/utils/include/utils/timer.h2
-rw-r--r--src/components/utils/src/auto_trace.cc22
-rw-r--r--src/components/utils/src/back_trace.cc25
-rw-r--r--src/components/utils/src/bitstream.cc17
-rw-r--r--src/components/utils/src/conditional_variable_posix.cc48
-rw-r--r--src/components/utils/src/convert_utils.cc6
-rw-r--r--src/components/utils/src/date_time.cc69
-rw-r--r--src/components/utils/src/lock_posix.cc36
-rw-r--r--src/components/utils/src/log_message_loop_thread.cc9
-rw-r--r--src/components/utils/src/logger.cc8
-rw-r--r--src/components/utils/src/push_log.cc27
-rw-r--r--src/components/utils/src/qdb_wrapper/sql_database.cc12
-rw-r--r--src/components/utils/src/qdb_wrapper/sql_error.cc5
-rw-r--r--src/components/utils/src/qdb_wrapper/sql_query.cc65
-rw-r--r--src/components/utils/src/resource_usage.cc167
-rw-r--r--src/components/utils/src/sqlite_wrapper/sql_database.cc15
-rw-r--r--src/components/utils/src/sqlite_wrapper/sql_error.cc5
-rw-r--r--src/components/utils/src/sqlite_wrapper/sql_query.cc24
-rw-r--r--src/components/utils/src/system.cc26
-rw-r--r--src/components/utils/src/threads/async_runner.cc13
-rw-r--r--src/components/utils/src/threads/pulse_thread_delegate.cc24
-rw-r--r--src/components/utils/src/threads/thread_delegate.cc2
-rw-r--r--src/components/utils/src/threads/thread_manager.cc2
-rw-r--r--src/components/utils/src/threads/thread_validator.cc44
-rw-r--r--src/components/utils/src/timer.cc6
-rw-r--r--src/components/utils/test/async_runner_test.cc16
-rw-r--r--src/components/utils/test/back_trace_test.cc7
-rw-r--r--src/components/utils/test/bitstream_test.cc105
-rw-r--r--src/components/utils/test/conditional_variable_test.cc60
-rw-r--r--src/components/utils/test/data_accessor_test.cc48
-rw-r--r--src/components/utils/test/date_time_test.cc165
-rw-r--r--src/components/utils/test/generated_code_with_sqlite_test.cc93
-rw-r--r--src/components/utils/test/include/generated_code_with_sqlite_test.h40
-rw-r--r--src/components/utils/test/log_message_loop_thread_test.cc8
-rw-r--r--src/components/utils/test/message_queue_test.cc55
-rw-r--r--src/components/utils/test/messagemeter_test.cc164
-rw-r--r--src/components/utils/test/posix_thread_test.cc97
-rw-r--r--src/components/utils/test/prioritized_queue_test.cc43
-rw-r--r--src/components/utils/test/qdb_wrapper/sql_query_test.cc46
-rw-r--r--src/components/utils/test/resource_usage_test.cc16
-rw-r--r--src/components/utils/test/rwlock_posix_test.cc24
-rw-r--r--src/components/utils/test/shared_ptr_test.cc55
-rw-r--r--src/components/utils/test/singleton_test.cc72
-rw-r--r--src/components/utils/test/sqlite_wrapper/sql_database_test.cc90
-rw-r--r--src/components/utils/test/sqlite_wrapper/sql_query_test.cc173
-rw-r--r--src/components/utils/test/stl_utils_test.cc19
-rw-r--r--src/components/utils/test/system_test.cc33
-rw-r--r--src/components/utils/test/thread_validator_test.cc7
66 files changed, 1297 insertions, 1285 deletions
diff --git a/src/components/utils/include/utils/appenders_loader.h b/src/components/utils/include/utils/appenders_loader.h
index 03d3217994..65556e6862 100644
--- a/src/components/utils/include/utils/appenders_loader.h
+++ b/src/components/utils/include/utils/appenders_loader.h
@@ -40,6 +40,7 @@ class AppendersLoader {
AppendersLoader();
~AppendersLoader();
bool Loaded() const;
+
private:
void* handle_;
};
diff --git a/src/components/utils/include/utils/back_trace.h b/src/components/utils/include/utils/back_trace.h
index f2410e36bc..180714e5a6 100644
--- a/src/components/utils/include/utils/back_trace.h
+++ b/src/components/utils/include/utils/back_trace.h
@@ -68,8 +68,8 @@ class Backtrace {
std::vector<void*> backtrace_;
};
-std::ostream& operator<< (std::ostream& os, const Backtrace& bt);
+std::ostream& operator<<(std::ostream& os, const Backtrace& bt);
-} // namespace utils
+} // namespace utils
-#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BACK_TRACE_H_
+#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BACK_TRACE_H_
diff --git a/src/components/utils/include/utils/bitstream.h b/src/components/utils/include/utils/bitstream.h
index 6b9d6337ef..13eacc6cb1 100644
--- a/src/components/utils/include/utils/bitstream.h
+++ b/src/components/utils/include/utils/bitstream.h
@@ -57,12 +57,21 @@ class BitStream {
// Mark stream as badly-formed.
// Should be called by Extract* family of procedures if they decide
// that stream is invalid
- void MarkBad() { bad_ = true; }
+ void MarkBad() {
+ bad_ = true;
+ }
// Predicates to check whether there were errors while parsing
// Stream is good when it is created
- bool IsGood() { return !bad_; }
- bool IsBad() { return bad_; }
- operator bool() { return IsGood(); }
+ bool IsGood() {
+ return !bad_;
+ }
+ bool IsBad() {
+ return bad_;
+ }
+ operator bool() {
+ return IsGood();
+ }
+
private:
// These two functions are used for internal stream checks only
// Stream parser procedures must not define their logic depending on
@@ -78,13 +87,13 @@ class BitStream {
// Extract single value, amount of bits read from stream depends on T size
// If there is not enough data in the stream, stream is marked bad
- template<typename T>
+ template <typename T>
void Extract(T& val);
// Read single value, amount of bits read from stream is signaled by |bits|
// parameter. T must be wide enough to hold this amount of bits.
// If there is not enough data in the stream, stream is marked bad
- template<typename T>
+ template <typename T>
void ExtractBits(T& val, size_t bits);
// Extract |length| bytes from the stream. Stream read position
@@ -94,10 +103,11 @@ class BitStream {
private:
const uint8_t* bytes_;
- const size_t bytes_count_;
+ const size_t bytes_count_;
size_t byte_offset_;
size_t bit_offset_;
bool bad_;
+
private:
friend void Extract(BitStream*, uint8_t*);
friend void Extract(BitStream*, uint8_t*, size_t);
@@ -105,7 +115,6 @@ class BitStream {
friend void Extract(BitStream*, uint32_t*, size_t);
friend void Extract(BitStream*, std::string*, size_t);
friend void Extract(BitStream*, std::vector<uint8_t>*, size_t);
-
};
// Extract single byte from stream
@@ -133,16 +142,15 @@ void Extract(BitStream* bs, std::string* str, size_t length);
// vector |data|. If stream is too short it is marked bad.
void Extract(BitStream* bs, std::vector<uint8_t>* data, size_t length);
-
// Template member definitions
-template<typename T>
+template <typename T>
void BitStream::Extract(T& val) {
// Slow but simple implementation
// It's a space for bit stream reading optimization
ExtractBits(val, sizeof(val) * CHAR_BIT);
}
-template<typename T>
+template <typename T>
void BitStream::ExtractBits(T& val, size_t bits) {
DCHECK(sizeof(val) * CHAR_BIT >= bits);
if (IsGood()) {
@@ -164,7 +172,6 @@ void BitStream::ExtractBits(T& val, size_t bits) {
}
}
-} // namespace utils
-
+} // namespace utils
-#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BITSTREAM_H_
+#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_BITSTREAM_H_
diff --git a/src/components/utils/include/utils/convert_utils.h b/src/components/utils/include/utils/convert_utils.h
index b3e849d6bd..0609164a60 100644
--- a/src/components/utils/include/utils/convert_utils.h
+++ b/src/components/utils/include/utils/convert_utils.h
@@ -60,7 +60,6 @@ unsigned long long int ConvertUInt64ToLongLongUInt(const uint64_t value);
*/
uint64_t ConvertLongLongUIntToUInt64(const unsigned long long int value);
-
/**
* Convert one number value to another type value
*/
diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h
index 0757a17110..5862241c9c 100644
--- a/src/components/utils/include/utils/file_system.h
+++ b/src/components/utils/include/utils/file_system.h
@@ -41,7 +41,6 @@
namespace file_system {
-
/**
* @brief Get available disc space.
*
@@ -165,7 +164,8 @@ bool DeleteFile(const std::string& name);
* @brief Removes directory.
*
* @param name path to directory.
- * @param is_recursively true if you need delete directory recursively, otherwise false.
+ * @param is_recursively true if you need delete directory recursively,
+ *otherwise false.
* @return returns true if the directory is successfully deleted.
*/
bool RemoveDirectory(const std::string& directory_name,
@@ -220,8 +220,7 @@ bool WriteBinaryFile(const std::string& name,
* @param result read data
* @return returns true if the operation is successfully.
*/
-bool ReadBinaryFile(const std::string& name,
- std::vector<uint8_t>& result);
+bool ReadBinaryFile(const std::string& name, std::vector<uint8_t>& result);
bool ReadFile(const std::string& name, std::string& result);
@@ -255,8 +254,7 @@ uint64_t GetFileModificationTime(const std::string& path);
* @param dst Destination file path
* @return if result success return true
*/
-bool CopyFile(const std::string& src,
- const std::string& dst);
+bool CopyFile(const std::string& src, const std::string& dst);
/**
* @brief Move file from source to destination
@@ -265,8 +263,7 @@ bool CopyFile(const std::string& src,
* @param dst Destination file path
* @return if result success return true
*/
-bool MoveFile(const std::string& src,
- const std::string& dst);
+bool MoveFile(const std::string& src, const std::string& dst);
void remove_directory_content(const std::string& directory_name);
diff --git a/src/components/utils/include/utils/helpers.h b/src/components/utils/include/utils/helpers.h
index f16acfc90a..17d4af27a1 100644
--- a/src/components/utils/include/utils/helpers.h
+++ b/src/components/utils/include/utils/helpers.h
@@ -31,12 +31,13 @@
*/
#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H
#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H
-#include<algorithm>
+#include <algorithm>
/**
* These helpers allows to simplify compare strategy between some objects.
* Suppose user has some enum with value E with some numbers of possible values
* enum E {V1, V2, V3, V5};
- * So we want to know if some user-input value is belong to one of the enum's subset.
+ * So we want to know if some user-input value is belong to one of the enum's
+ *subset.
* Usually user has to do next routine
*
* E input_value = V3;
@@ -56,71 +57,72 @@
*/
namespace helpers {
- template<typename T>
- bool EQ (T what, T to) {
- return what == to;
- }
-
- template<typename T>
- bool NEQ (T what, T to) {
- return !EQ<T>(what, to);
- }
+template <typename T>
+bool EQ(T what, T to) {
+ return what == to;
+}
- template<class U = bool>
- bool ALL (U what, U to) {
- return what && to;
- }
+template <typename T>
+bool NEQ(T what, T to) {
+ return !EQ<T>(what, to);
+}
- template<class U = bool>
- bool ONE (U what, U to) {
- return what || to;
- }
+template <class U = bool>
+bool ALL(U what, U to) {
+ return what && to;
+}
- template <typename T,
- bool (*CompareType)(T ,T),
- bool (*CmpStrategy)(bool ,bool)>
- bool Compare (T what, T to) {
- return CompareType(what, to);
- }
+template <class U = bool>
+bool ONE(U what, U to) {
+ return what || to;
+}
- template <typename T,
- bool (*CompareType)(T ,T),
- bool (*CmpStrategy)(bool, bool)>
- bool Compare(T what, T to, T to1) {
- return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to),
- Compare<T, CompareType, CmpStrategy>(what, to1));
- }
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to) {
+ return CompareType(what, to);
+}
- template <typename T,
- bool (*CompareType)(T ,T),
- bool (*CmpStrategy)(bool, bool)>
- bool Compare(T what, T to, T to1, T to2) {
- return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1),
- Compare<T, CompareType, CmpStrategy>(what, to2));
- }
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to, T to1) {
+ return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to),
+ Compare<T, CompareType, CmpStrategy>(what, to1));
+}
- template <typename T,
- bool (*CompareType)(T ,T),
- bool (*CmpStrategy)(bool, bool)>
- bool Compare(T what, T to, T to1, T to2, T to3) {
- return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1, to2),
- Compare<T, CompareType, CmpStrategy>(what, to3));
- }
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to, T to1, T to2) {
+ return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1),
+ Compare<T, CompareType, CmpStrategy>(what, to2));
+}
- template <typename T,
- bool (*CompareType)(T ,T),
- bool (*CmpStrategy)(bool, bool)>
- bool Compare(T what, T to, T to1, T to2, T to3, T to4) {
- return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1, to2, to3),
- Compare<T, CompareType, CmpStrategy>(what, to4));
- }
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to, T to1, T to2, T to3) {
+ return CmpStrategy(Compare<T, CompareType, CmpStrategy>(what, to, to1, to2),
+ Compare<T, CompareType, CmpStrategy>(what, to3));
+}
+template <typename T,
+ bool (*CompareType)(T, T),
+ bool (*CmpStrategy)(bool, bool)>
+bool Compare(T what, T to, T to1, T to2, T to3, T to4) {
+ return CmpStrategy(
+ Compare<T, CompareType, CmpStrategy>(what, to, to1, to2, to3),
+ Compare<T, CompareType, CmpStrategy>(what, to4));
+}
- template<typename Container>
- bool in_range(const Container& container, const typename Container::value_type& value) {
- return
- std::find(container.begin(), container.end(), value) != container.end();
- }
+template <typename Container>
+bool in_range(const Container& container,
+ const typename Container::value_type& value) {
+ return std::find(container.begin(), container.end(), value) !=
+ container.end();
+}
}
-#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H
+#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_HELPERS_H
diff --git a/src/components/utils/include/utils/log_message_loop_thread.h b/src/components/utils/include/utils/log_message_loop_thread.h
index 80816877b6..deea1a07c0 100644
--- a/src/components/utils/include/utils/log_message_loop_thread.h
+++ b/src/components/utils/include/utils/log_message_loop_thread.h
@@ -53,21 +53,20 @@ typedef struct {
typedef std::queue<LogMessage> LogMessageQueue;
-typedef threads::MessageLoopThread<LogMessageQueue> LogMessageLoopThreadTemplate;
+typedef threads::MessageLoopThread<LogMessageQueue>
+ LogMessageLoopThreadTemplate;
class LogMessageHandler : public LogMessageLoopThreadTemplate::Handler {
public:
virtual void Handle(const LogMessage message) OVERRIDE;
};
-class LogMessageLoopThread :
- public LogMessageLoopThreadTemplate {
-
+class LogMessageLoopThread : public LogMessageLoopThreadTemplate {
public:
LogMessageLoopThread();
- ~LogMessageLoopThread();
+ ~LogMessageLoopThread();
-DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread);
+ DISALLOW_COPY_AND_ASSIGN(LogMessageLoopThread);
};
} // namespace logger
diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_database.h b/src/components/utils/include/utils/qdb_wrapper/sql_database.h
index 54c89f678c..ba5c8a722a 100644
--- a/src/components/utils/include/utils/qdb_wrapper/sql_database.h
+++ b/src/components/utils/include/utils/qdb_wrapper/sql_database.h
@@ -90,6 +90,7 @@ class SQLDatabase {
* Call backup for opened DB
*/
bool Backup();
+
protected:
/**
* Gets connection to the SQLite database
diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_error.h b/src/components/utils/include/utils/qdb_wrapper/sql_error.h
index 79706cc0ef..25fd558308 100644
--- a/src/components/utils/include/utils/qdb_wrapper/sql_error.h
+++ b/src/components/utils/include/utils/qdb_wrapper/sql_error.h
@@ -39,8 +39,8 @@ namespace utils {
namespace dbms {
typedef enum Error {
- OK = 0, /* Successful result */
- ERROR /* Error */
+ OK = 0, /* Successful result */
+ ERROR /* Error */
} Error;
/**
diff --git a/src/components/utils/include/utils/qdb_wrapper/sql_query.h b/src/components/utils/include/utils/qdb_wrapper/sql_query.h
index 34fbfc61c7..f1da6ccad9 100644
--- a/src/components/utils/include/utils/qdb_wrapper/sql_query.h
+++ b/src/components/utils/include/utils/qdb_wrapper/sql_query.h
@@ -238,7 +238,7 @@ class SQLQuery {
/**
* The result of query
*/
- qdb_result_t *result_;
+ qdb_result_t* result_;
/**
* The current row in result for select
diff --git a/src/components/utils/include/utils/resource_usage.h b/src/components/utils/include/utils/resource_usage.h
index ff90b2c22f..4dd8a7eafd 100644
--- a/src/components/utils/include/utils/resource_usage.h
+++ b/src/components/utils/include/utils/resource_usage.h
@@ -44,8 +44,8 @@
#include "utils/logger.h"
-#define MAX_COMM_LEN 128
-#define MAX_CMDLINE_LEN 128
+#define MAX_COMM_LEN 128
+#define MAX_CMDLINE_LEN 128
namespace utils {
@@ -56,7 +56,7 @@ struct ResourseUsage {
};
class Resources {
- public:
+ public:
typedef uint32_t MemInfo;
#if defined(__QNXNTO__)
typedef procfs_info PidStats;
@@ -108,19 +108,18 @@ class Resources {
unsigned long long delayacct_blkio_ticks;
unsigned long guest_time;
long int cguest_time;
- };
+ };
#else
#endif
- public:
- /*
- * @brief Returns current resource usage of process
- * @return Raw pointer on ResourseUsage if success, otherwise return NULL
- */
+ public:
+ /*
+ * @brief Returns current resource usage of process
+ * @return Raw pointer on ResourseUsage if success, otherwise return NULL
+ */
static ResourseUsage* getCurrentResourseUsage();
-private:
-
+ private:
#ifdef BUILD_TESTS
friend class ResourceUsagePrivateTest;
FRIEND_TEST(ResourceUsagePrivateTest, ReadStatFileTest);
@@ -134,7 +133,8 @@ private:
/*
* @brief reads /proc/PID/stat file on linux
* do not work on QNX ( return false, output wan't be changed )
- * @param output - storage for result string ( there will be separated content of /proc/PID/stat )
+ * @param output - storage for result string ( there will be separated content
+ * of /proc/PID/stat )
* @return true on succes false onb fail
*/
static bool ReadStatFile(std::string& output);
@@ -171,9 +171,6 @@ private:
*/
static const char* proc;
};
-
}
-
-
#endif /* SRC_COMPONENTS_UTILS_INCLUDE_UTILS_RESOURCE_USAGE_H_ */
diff --git a/src/components/utils/include/utils/signals.h b/src/components/utils/include/utils/signals.h
index b8b71b95e3..48120d53cd 100644
--- a/src/components/utils/include/utils/signals.h
+++ b/src/components/utils/include/utils/signals.h
@@ -34,7 +34,7 @@
#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SIGNALS_H_
#ifdef __QNXNTO__
-typedef void (*sighandler_t) (int);
+typedef void (*sighandler_t)(int);
#else
#include <signal.h>
#endif
diff --git a/src/components/utils/include/utils/singleton.h b/src/components/utils/include/utils/singleton.h
index fff7294d1c..b73780ee1d 100644
--- a/src/components/utils/include/utils/singleton.h
+++ b/src/components/utils/include/utils/singleton.h
@@ -43,15 +43,13 @@ namespace deleters {
class DummyDeleter {
public:
- void grab(void* pointer) {
- }
+ void grab(void* pointer) {}
};
-template<typename T>
+template <typename T>
class Deleter {
public:
- Deleter() : pointer_(0) {
- }
+ Deleter() : pointer_(0) {}
~Deleter() {
if (pointer_) {
delete pointer_;
@@ -60,69 +58,68 @@ class Deleter {
void grab(T* pointer) {
pointer_ = pointer;
}
+
private:
T* pointer_;
};
} // namespace deleters
-template<typename T, class Deleter = deleters::DummyDeleter>
+template <typename T, class Deleter = deleters::DummyDeleter>
class Singleton {
-/**
- * @brief Singleton template
- * Singleton classes must derive from this template specialized with class itself:
- *
- * class MySingleton : public Singleton<MySingleton> {...};
- *
- * All such classes must declare instance() method as friend
- * by adding FRIEND_BASE_SINGLETON_CLASS macro from macro.h to class definition:
- *
- * FRIEND_BASE_SINGLETON_CLASS(MySingleton);
- *
- * Instance of this class (if created) can be deleted by Deleter destructor
- * which is called after main() (or from exit())
- * This requires T destructor to be accessible for Deleter (e.g. public)
- * Deleter template parameter can be specified with any class
- * with public default constructor, destructor and method
- * void grab(T*);
- * However, default Deleter specification does nothing
- *
- * Also instance can be deleted explicitly by calling destroy() method
- *
- * Both instance() and destroy() methods are thread safe
- * but not thread safety between simultaneous calls
- * of instance() and destroy() is cared about
- */
+ /**
+ * @brief Singleton template
+ * Singleton classes must derive from this template specialized with class
+ *itself:
+ *
+ * class MySingleton : public Singleton<MySingleton> {...};
+ *
+ * All such classes must declare instance() method as friend
+ * by adding FRIEND_BASE_SINGLETON_CLASS macro from macro.h to class
+ *definition:
+ *
+ * FRIEND_BASE_SINGLETON_CLASS(MySingleton);
+ *
+ * Instance of this class (if created) can be deleted by Deleter destructor
+ * which is called after main() (or from exit())
+ * This requires T destructor to be accessible for Deleter (e.g. public)
+ * Deleter template parameter can be specified with any class
+ * with public default constructor, destructor and method
+ * void grab(T*);
+ * However, default Deleter specification does nothing
+ *
+ * Also instance can be deleted explicitly by calling destroy() method
+ *
+ * Both instance() and destroy() methods are thread safe
+ * but not thread safety between simultaneous calls
+ * of instance() and destroy() is cared about
+ */
public:
-/**
- * @brief Returns the singleton of class
- */
+ /**
+ * @brief Returns the singleton of class
+ */
static T* instance();
-/**
- * @brief Destroys the singleton (if it had been created)
- */
+ /**
+ * @brief Destroys the singleton (if it had been created)
+ */
static void destroy();
-/**
- * @brief Checks whether the singleton exists
- */
+ /**
+ * @brief Checks whether the singleton exists
+ */
static bool exists();
private:
-
static T** instance_pointer();
static Deleter* deleter();
static sync_primitives::Lock lock_;
};
-
-template<typename T, class Deleter>
+template <typename T, class Deleter>
sync_primitives::Lock Singleton<T, Deleter>::lock_;
-
-template<typename T, class Deleter>
+template <typename T, class Deleter>
T* Singleton<T, Deleter>::instance() {
-
T* local_instance;
atomic_pointer_assign(local_instance, *instance_pointer());
memory_barrier();
@@ -142,9 +139,8 @@ T* Singleton<T, Deleter>::instance() {
return local_instance;
}
-template<typename T, class Deleter>
+template <typename T, class Deleter>
void Singleton<T, Deleter>::destroy() {
-
T* local_instance;
atomic_pointer_assign(local_instance, *instance_pointer());
memory_barrier();
@@ -162,18 +158,18 @@ void Singleton<T, Deleter>::destroy() {
}
}
-template<typename T, class Deleter>
+template <typename T, class Deleter>
bool Singleton<T, Deleter>::exists() {
return *instance_pointer() != 0;
}
-template<typename T, class Deleter>
+template <typename T, class Deleter>
T** Singleton<T, Deleter>::instance_pointer() {
static T* instance = 0;
return &instance;
}
-template<typename T, class Deleter>
+template <typename T, class Deleter>
Deleter* Singleton<T, Deleter>::deleter() {
static Deleter deleter;
return &deleter;
diff --git a/src/components/utils/include/utils/sqlite_wrapper/sql_error.h b/src/components/utils/include/utils/sqlite_wrapper/sql_error.h
index 70e73820f8..8a53e12169 100644
--- a/src/components/utils/include/utils/sqlite_wrapper/sql_error.h
+++ b/src/components/utils/include/utils/sqlite_wrapper/sql_error.h
@@ -39,37 +39,37 @@ namespace utils {
namespace dbms {
typedef enum Error {
- OK = 0, /* Successful result */
- ERROR, /* SQL error or missing database */
- INTERNAL, /* Internal logic error in SQLite */
- PERM, /* Access permission denied */
- ABORT, /* Callback routine requested an abort */
- BUSY, /* The database file is locked */
- LOCKED, /* A table in the database is locked */
- NOMEM, /* A malloc() failed */
- READONLY, /* Attempt to write a readonly database */
- INTERRUPT, /* Operation terminated by sqlite3_interrupt()*/
- IOERR, /* Some kind of disk I/O error occurred */
- CORRUPT, /* The database disk image is malformed */
- NOTFOUND, /* Unknown opcode in sqlite3_file_control() */
- FULL, /* Insertion failed because database is full */
- CANTOPEN, /* Unable to open the database file */
- PROTOCOL, /* Database lock protocol error */
- EMPTY, /* Database is empty */
- SCHEMA, /* The database schema changed */
- TOOBIG, /* String or BLOB exceeds size limit */
- CONSTRAINT, /* Abort due to constraint violation */
- MISMATCH, /* Data type mismatch */
- MISUSE, /* Library used incorrectly */
- NOLFS, /* Uses OS features not supported on host */
- AUTH, /* Authorization denied */
- FORMAT, /* Auxiliary database format error */
- RANGE, /* 2nd parameter to sqlite3_bind out of range */
- NOTADB, /* File opened that is not a database file */
- NOTICE, /* Notifications from sqlite3_log() */
- WARNING, /* Warnings from sqlite3_log() */
- ROW = 100, /* sqlite3_step() has another row ready */
- DONE = 101 /* sqlite3_step() has finished executing */
+ OK = 0, /* Successful result */
+ ERROR, /* SQL error or missing database */
+ INTERNAL, /* Internal logic error in SQLite */
+ PERM, /* Access permission denied */
+ ABORT, /* Callback routine requested an abort */
+ BUSY, /* The database file is locked */
+ LOCKED, /* A table in the database is locked */
+ NOMEM, /* A malloc() failed */
+ READONLY, /* Attempt to write a readonly database */
+ INTERRUPT, /* Operation terminated by sqlite3_interrupt()*/
+ IOERR, /* Some kind of disk I/O error occurred */
+ CORRUPT, /* The database disk image is malformed */
+ NOTFOUND, /* Unknown opcode in sqlite3_file_control() */
+ FULL, /* Insertion failed because database is full */
+ CANTOPEN, /* Unable to open the database file */
+ PROTOCOL, /* Database lock protocol error */
+ EMPTY, /* Database is empty */
+ SCHEMA, /* The database schema changed */
+ TOOBIG, /* String or BLOB exceeds size limit */
+ CONSTRAINT, /* Abort due to constraint violation */
+ MISMATCH, /* Data type mismatch */
+ MISUSE, /* Library used incorrectly */
+ NOLFS, /* Uses OS features not supported on host */
+ AUTH, /* Authorization denied */
+ FORMAT, /* Auxiliary database format error */
+ RANGE, /* 2nd parameter to sqlite3_bind out of range */
+ NOTADB, /* File opened that is not a database file */
+ NOTICE, /* Notifications from sqlite3_log() */
+ WARNING, /* Warnings from sqlite3_log() */
+ ROW = 100, /* sqlite3_step() has another row ready */
+ DONE = 101 /* sqlite3_step() has finished executing */
} Error;
/**
diff --git a/src/components/utils/include/utils/stl_utils.h b/src/components/utils/include/utils/stl_utils.h
index 70fbadbd5e..4a4e3d2fe8 100644
--- a/src/components/utils/include/utils/stl_utils.h
+++ b/src/components/utils/include/utils/stl_utils.h
@@ -40,45 +40,48 @@ namespace utils {
* Utility class that automatically deletes STL collection of
* freestore objects
*/
-template<class T>
+template <class T>
class StlCollectionDeleter {
public:
typedef T Collection;
- StlCollectionDeleter(T* collection)
- : collection_(collection) {
+ StlCollectionDeleter(T* collection) : collection_(collection) {
DCHECK(collection_);
}
~StlCollectionDeleter() {
- for (typename Collection::iterator i = collection_->begin(), end =
- collection_->end(); i != end; ++i) {
+ for (typename Collection::iterator i = collection_->begin(),
+ end = collection_->end();
+ i != end;
+ ++i) {
delete *i;
*i = NULL;
}
}
+
private:
Collection* collection_;
};
-template<class T>
+template <class T>
class StlMapDeleter {
public:
typedef T Collection;
- StlMapDeleter(T* collection)
- : collection_(collection) {
+ StlMapDeleter(T* collection) : collection_(collection) {
DCHECK(collection_);
}
~StlMapDeleter() {
- for (typename Collection::iterator i = collection_->begin(), end =
- collection_->end(); i != end; ++i) {
+ for (typename Collection::iterator i = collection_->begin(),
+ end = collection_->end();
+ i != end;
+ ++i) {
delete i->second;
i->second = NULL;
}
-
}
+
private:
Collection* collection_;
};
} // namespace utils
-#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_STL_UTILS_H_
+#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_STL_UTILS_H_
diff --git a/src/components/utils/include/utils/threads/pulse_thread_delegate.h b/src/components/utils/include/utils/threads/pulse_thread_delegate.h
index 207b64caaf..623e12b261 100644
--- a/src/components/utils/include/utils/threads/pulse_thread_delegate.h
+++ b/src/components/utils/include/utils/threads/pulse_thread_delegate.h
@@ -42,9 +42,11 @@ namespace threads {
/**
* @brief This ThreadDelegate derivative is designed
* to implement threads waiting for QNX Pulse messages
- * When constucted, an instance of this class creates QNX channel and connects to it
+ * When constucted, an instance of this class creates QNX channel and connects
+ * to it
* In exitThreadMain() channel is disconnected and destroyed
- * In threadMain() endless loop event is armed via pure virtual method ArmEvent()
+ * In threadMain() endless loop event is armed via pure virtual method
+ * ArmEvent()
* and thread blocks on MsgReceivePulse() waiting for Pulse
* When Pulse comes, OnPulse() pure virtual method is invoked
* Subclassed must implement ArmEvent() for events of interest
@@ -52,39 +54,42 @@ namespace threads {
*/
class PulseThreadDelegate : public ThreadDelegate {
public:
-/**
- * @brief default constructor
- */
+ /**
+ * @brief default constructor
+ */
PulseThreadDelegate();
virtual void threadMain();
virtual void exitThreadMain();
protected:
-/**
- * @brief This method is to be implemented to arm events of interest
- * @param event pointer to structure sigevent
- * @return If this method returns true, thread is blocked on MsgReceivePulse() waiting for Pulse
- */
+ /**
+ * @brief This method is to be implemented to arm events of interest
+ * @param event pointer to structure sigevent
+ * @return If this method returns true, thread is blocked on
+ * MsgReceivePulse() waiting for Pulse
+ */
virtual bool ArmEvent(struct sigevent* event) = 0;
-/**
- * @brief This method is invoked from threadMain() when Pulse comes
- */
+ /**
+ * @brief This method is invoked from threadMain() when Pulse comes
+ */
virtual void OnPulse() = 0;
/**
* This method is to be initialize child class
* @return If this method returns false, thread will be stopped
*/
- virtual bool Init() { return true; }
+ virtual bool Init() {
+ return true;
+ }
-/**
- * Finalizes thread
- * Can free resources
- */
+ /**
+ * Finalizes thread
+ * Can free resources
+ */
virtual void Finalize() {}
private:
- enum {PULSE_CODE = _PULSE_CODE_MINAVAIL + 1};
+ enum { PULSE_CODE = _PULSE_CODE_MINAVAIL + 1 };
volatile bool run_;
int chid_;
diff --git a/src/components/utils/include/utils/threads/thread_manager.h b/src/components/utils/include/utils/threads/thread_manager.h
index d72abb428f..3f53c902c4 100644
--- a/src/components/utils/include/utils/threads/thread_manager.h
+++ b/src/components/utils/include/utils/threads/thread_manager.h
@@ -51,7 +51,7 @@
#include "utils/threads/thread_delegate.h"
namespace threads {
- class Thread;
+class Thread;
/*
* This class is here currently to remember names associated to threads.
@@ -69,12 +69,13 @@ class ThreadManager : public utils::Singleton<ThreadManager> {
};
ThreadManager() {}
MessageQueue<ThreadDesc> threads_to_terminate;
+
private:
DISALLOW_COPY_AND_ASSIGN(ThreadManager);
FRIEND_BASE_SINGLETON_CLASS(ThreadManager);
};
-} // namespace threads
+} // namespace threads
-#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_THREADS_THREAD_MANAGER_H_
+#endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_THREADS_THREAD_MANAGER_H_
diff --git a/src/components/utils/include/utils/threads/thread_validator.h b/src/components/utils/include/utils/threads/thread_validator.h
index dc2d138e2e..2e7dac02ab 100644
--- a/src/components/utils/include/utils/threads/thread_validator.h
+++ b/src/components/utils/include/utils/threads/thread_validator.h
@@ -68,11 +68,11 @@ class SingleThreadSimpleValidator {
// of classes being checked for absence of concurrent access
void AssertRunningOnCreationThread() const;
PlatformThreadHandle creation_thread_id() const;
+
private:
const PlatformThreadHandle creation_thread_id_;
};
-
/*
* This is bit more sophisticated debug helper which allows
* objects being checked to be transferred between threads.
@@ -97,10 +97,11 @@ class SingleThreadValidator {
// of classes being checked for absence of unintended concurrent
// access
void AssertRunningOnValidThread() const;
+
private:
mutable PlatformThreadHandle owning_thread_id_;
};
-} // namespace threads
+} // namespace threads
-#endif // SRC_COMPONENTS_UTILS_INCLUDE_THREADS_THREAD_VALIDATOR_H_
+#endif // SRC_COMPONENTS_UTILS_INCLUDE_THREADS_THREAD_VALIDATOR_H_
diff --git a/src/components/utils/include/utils/timer.h b/src/components/utils/include/utils/timer.h
index 69b2d08a4d..837e7ed598 100644
--- a/src/components/utils/include/utils/timer.h
+++ b/src/components/utils/include/utils/timer.h
@@ -65,7 +65,7 @@ class Timer {
* Stops timer if it's running
*/
~Timer();
-
+
/**
* @brief Starts timer with specified timeout
* @param timeout Timer timeout
diff --git a/src/components/utils/src/auto_trace.cc b/src/components/utils/src/auto_trace.cc
index 606e8330cb..0379630319 100644
--- a/src/components/utils/src/auto_trace.cc
+++ b/src/components/utils/src/auto_trace.cc
@@ -38,32 +38,28 @@
namespace logger {
-AutoTrace::AutoTrace(
- log4cxx::LoggerPtr logger,
- const log4cxx::spi::LocationInfo& location) :
- logger_(logger), location_(location) {
- if (logger::logs_enabled() &&
- logger_->isTraceEnabled()) {
+AutoTrace::AutoTrace(log4cxx::LoggerPtr logger,
+ const log4cxx::spi::LocationInfo& location)
+ : logger_(logger), location_(location) {
+ if (logger::logs_enabled() && logger_->isTraceEnabled()) {
push_log(logger_,
::log4cxx::Level::getTrace(),
"Enter",
apr_time_now(),
location_,
- ::log4cxx::spi::LoggingEvent::getCurrentThreadName()
- );
+ ::log4cxx::spi::LoggingEvent::getCurrentThreadName());
}
}
AutoTrace::~AutoTrace() {
- if (logger::logs_enabled() &&
- logger_->isTraceEnabled()) {
+ if (logger::logs_enabled() && logger_->isTraceEnabled()) {
push_log(logger_,
::log4cxx::Level::getTrace(),
"Exit",
apr_time_now(),
- location_, // the location corresponds rather to creation of autotrace object than to deletion
- ::log4cxx::spi::LoggingEvent::getCurrentThreadName()
- );
+ location_, // the location corresponds rather to creation of
+ // autotrace object than to deletion
+ ::log4cxx::spi::LoggingEvent::getCurrentThreadName());
}
}
diff --git a/src/components/utils/src/back_trace.cc b/src/components/utils/src/back_trace.cc
index f49c60b467..c587643cc6 100644
--- a/src/components/utils/src/back_trace.cc
+++ b/src/components/utils/src/back_trace.cc
@@ -67,16 +67,16 @@ string demangle(const char* symbol) {
Backtrace::Backtrace(int32_t count, int32_t skip_top)
: thread_id_(threads::Thread::CurrentId()) {
- int32_t skip = skip_top + 1; // Skip this constructor
- vector<void*> full_trace (count + skip);
+ int32_t skip = skip_top + 1; // Skip this constructor
+ vector<void*> full_trace(count + skip);
int32_t captured = backtrace(&full_trace.front(), count + skip);
int32_t first_call = std::min(captured, skip);
int32_t last_call = std::min(first_call + count, captured);
- backtrace_.assign(full_trace.begin() + first_call, full_trace.begin() + last_call);
+ backtrace_.assign(full_trace.begin() + first_call,
+ full_trace.begin() + last_call);
}
-Backtrace::~Backtrace() {
-}
+Backtrace::~Backtrace() {}
vector<string> Backtrace::CallStack() const {
vector<string> callstack;
@@ -93,15 +93,16 @@ threads::PlatformThreadHandle Backtrace::ThreadId() const {
return thread_id_;
}
-ostream& operator<< (ostream& os, const Backtrace& bt) {
+ostream& operator<<(ostream& os, const Backtrace& bt) {
const vector<string> symbols = bt.CallStack();
- os<<"Stack trace ("<<bt.ThreadId()<<")\n";
+ os << "Stack trace (" << bt.ThreadId() << ")\n";
if (symbols.empty()) {
- os<<"Not available"<<std::endl;
- } else for (size_t i = 0; i < symbols.size(); ++i) {
- os<<symbols[i]<<std::endl;
- }
+ os << "Not available" << std::endl;
+ } else
+ for (size_t i = 0; i < symbols.size(); ++i) {
+ os << symbols[i] << std::endl;
+ }
return os;
}
-} // namespace utils
+} // namespace utils
diff --git a/src/components/utils/src/bitstream.cc b/src/components/utils/src/bitstream.cc
index ae353b44c6..e0cc502d54 100644
--- a/src/components/utils/src/bitstream.cc
+++ b/src/components/utils/src/bitstream.cc
@@ -34,15 +34,13 @@
namespace utils {
BitStream::BitStream(uint8_t* bytes, size_t bytes_count)
- : bytes_(bytes),
- bytes_count_(bytes_count),
- byte_offset_(0),
- bit_offset_(0),
- bad_(false) {
-}
+ : bytes_(bytes)
+ , bytes_count_(bytes_count)
+ , byte_offset_(0)
+ , bit_offset_(0)
+ , bad_(false) {}
-BitStream::~BitStream() {
-}
+BitStream::~BitStream() {}
size_t BitStream::FullBytesLeft() {
size_t left = bytes_count_ - byte_offset_;
@@ -104,7 +102,7 @@ void Extract(BitStream* bs, std::string* str, size_t length) {
bs->MarkBad();
return;
}
- str->resize(length+1);
+ str->resize(length + 1);
void* stringdata = &(*str)[0];
bs->ExtractBytes(stringdata, length);
str->resize(length);
@@ -129,4 +127,3 @@ void Extract(BitStream* bs, std::vector<uint8_t>* data, size_t length) {
}
} // namespace utils
-
diff --git a/src/components/utils/src/conditional_variable_posix.cc b/src/components/utils/src/conditional_variable_posix.cc
index 1fde18b1f9..50ebc74556 100644
--- a/src/components/utils/src/conditional_variable_posix.cc
+++ b/src/components/utils/src/conditional_variable_posix.cc
@@ -49,44 +49,43 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
ConditionalVariable::ConditionalVariable() {
pthread_condattr_t attrs;
- int initialized = pthread_condattr_init(&attrs);
+ int initialized = pthread_condattr_init(&attrs);
if (initialized != 0)
- LOG4CXX_ERROR(logger_, "Failed to initialize "
- "conditional variable attributes");
+ LOG4CXX_ERROR(logger_,
+ "Failed to initialize "
+ "conditional variable attributes");
pthread_condattr_setclock(&attrs, CLOCK_MONOTONIC);
initialized = pthread_cond_init(&cond_var_, &attrs);
if (initialized != 0)
- LOG4CXX_ERROR(logger_, "Failed to initialize "
- "conditional variable");
+ LOG4CXX_ERROR(logger_,
+ "Failed to initialize "
+ "conditional variable");
int rv = pthread_condattr_destroy(&attrs);
if (rv != 0)
- LOG4CXX_ERROR(logger_, "Failed to destroy "
- "conditional variable attributes");
+ LOG4CXX_ERROR(logger_,
+ "Failed to destroy "
+ "conditional variable attributes");
}
ConditionalVariable::~ConditionalVariable() {
pthread_cond_destroy(&cond_var_);
-
}
void ConditionalVariable::NotifyOne() {
int signaled = pthread_cond_signal(&cond_var_);
if (signaled != 0)
LOG4CXX_ERROR(logger_, "Failed to signal conditional variable");
-
}
void ConditionalVariable::Broadcast() {
int signaled = pthread_cond_broadcast(&cond_var_);
if (signaled != 0)
LOG4CXX_ERROR(logger_, "Failed to broadcast conditional variable");
-
}
bool ConditionalVariable::Wait(Lock& lock) {
lock.AssertTakenAndMarkFree();
- int wait_status = pthread_cond_wait(&cond_var_,
- &lock.mutex_);
+ int wait_status = pthread_cond_wait(&cond_var_, &lock.mutex_);
lock.AssertFreeAndMarkTaken();
if (wait_status != 0) {
LOG4CXX_ERROR(logger_, "Failed to wait for conditional variable");
@@ -98,8 +97,7 @@ bool ConditionalVariable::Wait(Lock& lock) {
bool ConditionalVariable::Wait(AutoLock& auto_lock) {
Lock& lock = auto_lock.GetLock();
lock.AssertTakenAndMarkFree();
- int wait_status = pthread_cond_wait(&cond_var_,
- &lock.mutex_);
+ int wait_status = pthread_cond_wait(&cond_var_, &lock.mutex_);
lock.AssertFreeAndMarkTaken();
if (wait_status != 0) {
LOG4CXX_ERROR(logger_, "Failed to wait for conditional variable");
@@ -109,24 +107,23 @@ bool ConditionalVariable::Wait(AutoLock& auto_lock) {
}
ConditionalVariable::WaitStatus ConditionalVariable::WaitFor(
- AutoLock& auto_lock, uint32_t milliseconds){
+ AutoLock& auto_lock, uint32_t milliseconds) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
timespec wait_interval;
- wait_interval.tv_sec = now.tv_sec +
- (milliseconds / kMillisecondsPerSecond);
- wait_interval.tv_nsec = now.tv_nsec +
+ wait_interval.tv_sec = now.tv_sec + (milliseconds / kMillisecondsPerSecond);
+ wait_interval.tv_nsec =
+ now.tv_nsec +
(milliseconds % kMillisecondsPerSecond) * kNanosecondsPerMillisecond;
wait_interval.tv_sec += wait_interval.tv_nsec / kNanosecondsPerSecond;
wait_interval.tv_nsec %= kNanosecondsPerSecond;
Lock& lock = auto_lock.GetLock();
lock.AssertTakenAndMarkFree();
- int timedwait_status = pthread_cond_timedwait(&cond_var_,
- &lock.mutex_,
- &wait_interval);
+ int timedwait_status =
+ pthread_cond_timedwait(&cond_var_, &lock.mutex_, &wait_interval);
lock.AssertFreeAndMarkTaken();
WaitStatus wait_status = kNoTimeout;
- switch(timedwait_status) {
+ switch (timedwait_status) {
case 0: {
wait_status = kNoTimeout;
break;
@@ -140,10 +137,13 @@ ConditionalVariable::WaitStatus ConditionalVariable::WaitFor(
break;
}
default: {
- LOG4CXX_ERROR(logger_, "Failed to timewait for conditional variable timedwait_status: " << timedwait_status);
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to timewait for conditional variable timedwait_status: "
+ << timedwait_status);
}
}
return wait_status;
}
-} // namespace sync_primitives
+} // namespace sync_primitives
diff --git a/src/components/utils/src/convert_utils.cc b/src/components/utils/src/convert_utils.cc
index 50a32f3da0..319b231a96 100644
--- a/src/components/utils/src/convert_utils.cc
+++ b/src/components/utils/src/convert_utils.cc
@@ -52,13 +52,15 @@ int64_t utils::ConvertLongLongIntToInt64(const long long int value) {
return static_cast<int64_t>(value);
}
-unsigned long long int utils::ConvertUInt64ToLongLongUInt(const uint64_t value) {
+unsigned long long int utils::ConvertUInt64ToLongLongUInt(
+ const uint64_t value) {
DCHECK(value >= std::numeric_limits<unsigned long long int>::min());
DCHECK(value <= std::numeric_limits<unsigned long long int>::max());
return static_cast<unsigned long long int>(value);
}
-uint64_t utils::ConvertLongLongUIntToUInt64(const unsigned long long int value) {
+uint64_t utils::ConvertLongLongUIntToUInt64(
+ const unsigned long long int value) {
DCHECK_OR_RETURN(
value >= std::numeric_limits<uint64_t>::min(),
std::min<uint64_t>(value, std::numeric_limits<uint64_t>::min()));
diff --git a/src/components/utils/src/date_time.cc b/src/components/utils/src/date_time.cc
index 9313874f48..fdf0926eb2 100644
--- a/src/components/utils/src/date_time.cc
+++ b/src/components/utils/src/date_time.cc
@@ -34,41 +34,41 @@
#include <stdint.h>
#include "utils/date_time.h"
-
namespace date_time {
- TimevalStruct DateTime::getCurrentTime() {
- TimevalStruct currentTime;
- timezone timeZone;
+TimevalStruct DateTime::getCurrentTime() {
+ TimevalStruct currentTime;
+ timezone timeZone;
- gettimeofday(&currentTime, &timeZone);
+ gettimeofday(&currentTime, &timeZone);
- return currentTime;
- }
+ return currentTime;
+}
-int64_t date_time::DateTime::getSecs(const TimevalStruct &time) {
- const TimevalStruct times = ConvertionUsecs(time);
- return static_cast<int64_t>(times.tv_sec);
+int64_t date_time::DateTime::getSecs(const TimevalStruct& time) {
+ const TimevalStruct times = ConvertionUsecs(time);
+ return static_cast<int64_t>(times.tv_sec);
}
-int64_t DateTime::getmSecs(const TimevalStruct &time) {
+int64_t DateTime::getmSecs(const TimevalStruct& time) {
const TimevalStruct times = ConvertionUsecs(time);
- return static_cast<int64_t>(times.tv_sec) * MILLISECONDS_IN_SECOND
- + times.tv_usec / MICROSECONDS_IN_MILLISECOND;
+ return static_cast<int64_t>(times.tv_sec) * MILLISECONDS_IN_SECOND +
+ times.tv_usec / MICROSECONDS_IN_MILLISECOND;
}
-int64_t DateTime::getuSecs(const TimevalStruct &time) {
+int64_t DateTime::getuSecs(const TimevalStruct& time) {
const TimevalStruct times = ConvertionUsecs(time);
- return static_cast<int64_t>(times.tv_sec) * MILLISECONDS_IN_SECOND
- * MICROSECONDS_IN_MILLISECOND + times.tv_usec;
+ return static_cast<int64_t>(times.tv_sec) * MILLISECONDS_IN_SECOND *
+ MICROSECONDS_IN_MILLISECOND +
+ times.tv_usec;
}
int64_t DateTime::calculateTimeSpan(const TimevalStruct& sinceTime) {
return calculateTimeDiff(getCurrentTime(), sinceTime);
}
-int64_t DateTime::calculateTimeDiff(const TimevalStruct &time1,
- const TimevalStruct &time2){
+int64_t DateTime::calculateTimeDiff(const TimevalStruct& time1,
+ const TimevalStruct& time2) {
const TimevalStruct times1 = ConvertionUsecs(time1);
const TimevalStruct times2 = ConvertionUsecs(time2);
TimevalStruct ret;
@@ -80,10 +80,10 @@ int64_t DateTime::calculateTimeDiff(const TimevalStruct &time1,
return getmSecs(ret);
}
-void DateTime::AddMilliseconds(TimevalStruct& time,
- uint32_t milliseconds) {
- const uint32_t sec = milliseconds/MILLISECONDS_IN_SECOND;
- const uint32_t usec = (milliseconds%MILLISECONDS_IN_SECOND)*MICROSECONDS_IN_MILLISECOND;
+void DateTime::AddMilliseconds(TimevalStruct& time, uint32_t milliseconds) {
+ const uint32_t sec = milliseconds / MILLISECONDS_IN_SECOND;
+ const uint32_t usec =
+ (milliseconds % MILLISECONDS_IN_SECOND) * MICROSECONDS_IN_MILLISECOND;
time.tv_sec += sec;
time.tv_usec += usec;
time = ConvertionUsecs(time);
@@ -101,31 +101,35 @@ TimevalStruct DateTime::Sub(const TimevalStruct& time1,
bool DateTime::Greater(const TimevalStruct& time1, const TimevalStruct& time2) {
const TimevalStruct times1 = ConvertionUsecs(time1);
const TimevalStruct times2 = ConvertionUsecs(time2);
- return timercmp(&times1, &times2, >);
+ return timercmp(&times1, &times2, > );
}
bool DateTime::Less(const TimevalStruct& time1, const TimevalStruct& time2) {
const TimevalStruct times1 = ConvertionUsecs(time1);
const TimevalStruct times2 = ConvertionUsecs(time2);
- return timercmp(&times1, &times2, <);
+ return timercmp(&times1, &times2, < );
}
bool DateTime::Equal(const TimevalStruct& time1, const TimevalStruct& time2) {
const TimevalStruct times1 = ConvertionUsecs(time1);
const TimevalStruct times2 = ConvertionUsecs(time2);
- return !timercmp(&times1, &times2, !=);
+ return !timercmp(&times1, &times2, != );
}
-TimeCompare date_time::DateTime::compareTime(const TimevalStruct &time1, const TimevalStruct &time2) {
- if (Greater(time1, time2)) return GREATER;
- if (Less(time1, time2)) return LESS;
+TimeCompare date_time::DateTime::compareTime(const TimevalStruct& time1,
+ const TimevalStruct& time2) {
+ if (Greater(time1, time2))
+ return GREATER;
+ if (Less(time1, time2))
+ return LESS;
return EQUAL;
}
-TimevalStruct date_time::DateTime::ConvertionUsecs(const TimevalStruct &time){
+TimevalStruct date_time::DateTime::ConvertionUsecs(const TimevalStruct& time) {
if (time.tv_usec >= MICROSECONDS_IN_SECOND) {
TimevalStruct time1;
- time1.tv_sec = static_cast<int64_t>(time.tv_sec) + (time.tv_usec/MICROSECONDS_IN_SECOND);
+ time1.tv_sec = static_cast<int64_t>(time.tv_sec) +
+ (time.tv_usec / MICROSECONDS_IN_SECOND);
time1.tv_usec = static_cast<int64_t>(time.tv_usec) % MICROSECONDS_IN_SECOND;
return time1;
}
@@ -142,6 +146,7 @@ bool operator==(const TimevalStruct& time1, const TimevalStruct& time2) {
return date_time::DateTime::Equal(time1, time2);
}
-const TimevalStruct operator-(const TimevalStruct& time1, const TimevalStruct& time2) {
- return date_time::DateTime::Sub(time1, time2);
+const TimevalStruct operator-(const TimevalStruct& time1,
+ const TimevalStruct& time2) {
+ return date_time::DateTime::Sub(time1, time2);
}
diff --git a/src/components/utils/src/lock_posix.cc b/src/components/utils/src/lock_posix.cc
index 8c943124b4..0a678123f0 100644
--- a/src/components/utils/src/lock_posix.cc
+++ b/src/components/utils/src/lock_posix.cc
@@ -44,18 +44,18 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
Lock::Lock()
#ifndef NDEBUG
- : lock_taken_(0),
- is_mutex_recursive_(false)
-#endif // NDEBUG
+ : lock_taken_(0)
+ , is_mutex_recursive_(false)
+#endif // NDEBUG
{
Init(false);
}
Lock::Lock(bool is_recursive)
#ifndef NDEBUG
- : lock_taken_(0),
- is_mutex_recursive_(is_recursive)
-#endif // NDEBUG
+ : lock_taken_(0)
+ , is_mutex_recursive_(is_recursive)
+#endif // NDEBUG
{
Init(is_recursive);
}
@@ -68,16 +68,18 @@ Lock::~Lock() {
#endif
int32_t status = pthread_mutex_destroy(&mutex_);
if (status != 0) {
- LOG4CXX_ERROR(logger_, "Failed to destroy mutex " << &mutex_ << ": "
- << strerror(status));
+ LOG4CXX_ERROR(logger_,
+ "Failed to destroy mutex " << &mutex_ << ": "
+ << strerror(status));
}
}
void Lock::Acquire() {
const int32_t status = pthread_mutex_lock(&mutex_);
if (status != 0) {
- LOG4CXX_FATAL(logger_, "Failed to acquire mutex " << &mutex_ << ": "
- << strerror(status));
+ LOG4CXX_FATAL(logger_,
+ "Failed to acquire mutex " << &mutex_ << ": "
+ << strerror(status));
DCHECK(status != 0);
} else {
AssertFreeAndMarkTaken();
@@ -88,8 +90,9 @@ void Lock::Release() {
AssertTakenAndMarkFree();
const int32_t status = pthread_mutex_unlock(&mutex_);
if (status != 0) {
- LOG4CXX_ERROR(logger_, "Failed to unlock mutex" << &mutex_ << ": "
- << strerror(status));
+ LOG4CXX_ERROR(logger_,
+ "Failed to unlock mutex" << &mutex_ << ": "
+ << strerror(status));
}
}
@@ -125,9 +128,8 @@ void Lock::Init(bool is_recursive) {
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
- const int32_t mutex_type = is_recursive
- ? PTHREAD_MUTEX_RECURSIVE
- : PTHREAD_MUTEX_ERRORCHECK;
+ const int32_t mutex_type =
+ is_recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_ERRORCHECK;
pthread_mutexattr_settype(&attr, mutex_type);
const int32_t status = pthread_mutex_init(&mutex_, &attr);
@@ -135,8 +137,8 @@ void Lock::Init(bool is_recursive) {
pthread_mutexattr_destroy(&attr);
if (status != 0) {
- LOG4CXX_FATAL(logger_, "Failed to initialize mutex. "
- << std::strerror(status));
+ LOG4CXX_FATAL(logger_,
+ "Failed to initialize mutex. " << std::strerror(status));
DCHECK(status != 0);
}
}
diff --git a/src/components/utils/src/log_message_loop_thread.cc b/src/components/utils/src/log_message_loop_thread.cc
index 1403a5f712..77bc8107eb 100644
--- a/src/components/utils/src/log_message_loop_thread.cc
+++ b/src/components/utils/src/log_message_loop_thread.cc
@@ -43,13 +43,12 @@ void LogMessageHandler::Handle(const LogMessage message) {
message.threadName);
}
-LogMessageLoopThread::LogMessageLoopThread() :
- LogMessageLoopThreadTemplate("Logger", new LogMessageHandler()) {
-}
+LogMessageLoopThread::LogMessageLoopThread()
+ : LogMessageLoopThreadTemplate("Logger", new LogMessageHandler()) {}
LogMessageLoopThread::~LogMessageLoopThread() {
-// we'll have to drop messages
-// while deleting logger thread
+ // we'll have to drop messages
+ // while deleting logger thread
logger_status = DeletingLoggerThread;
}
diff --git a/src/components/utils/src/logger.cc b/src/components/utils/src/logger.cc
index 7d6eb6386a..4e93ca3d14 100644
--- a/src/components/utils/src/logger.cc
+++ b/src/components/utils/src/logger.cc
@@ -35,15 +35,17 @@
#include "utils/logger_status.h"
#include <apr_time.h>
-void deinit_logger () {
+void deinit_logger() {
CREATE_LOGGERPTR_LOCAL(logger_, "Utils")
LOG4CXX_DEBUG(logger_, "Logger deinitialization");
logger::set_logs_enabled(false);
logger::delete_log_message_loop_thread();
log4cxx::LoggerPtr rootLogger = log4cxx::Logger::getRootLogger();
- log4cxx::spi::LoggerRepositoryPtr repository = rootLogger->getLoggerRepository();
+ log4cxx::spi::LoggerRepositoryPtr repository =
+ rootLogger->getLoggerRepository();
log4cxx::LoggerList loggers = repository->getCurrentLoggers();
- for (log4cxx::LoggerList::iterator i = loggers.begin(); i != loggers.end(); ++i) {
+ for (log4cxx::LoggerList::iterator i = loggers.begin(); i != loggers.end();
+ ++i) {
log4cxx::LoggerPtr logger = *i;
logger->removeAllAppenders();
}
diff --git a/src/components/utils/src/push_log.cc b/src/components/utils/src/push_log.cc
index 9825ad9df4..6e16c99181 100644
--- a/src/components/utils/src/push_log.cc
+++ b/src/components/utils/src/push_log.cc
@@ -44,10 +44,10 @@ bool push_log(log4cxx::LoggerPtr logger,
const std::string& entry,
log4cxx_time_t timeStamp,
const log4cxx::spi::LocationInfo& location,
- const log4cxx::LogString& threadName
- ) {
+ const log4cxx::LogString& threadName) {
if (LoggerThreadCreated == logger_status) {
- LogMessage message = {logger, level, entry, timeStamp, location, threadName};
+ LogMessage message = {
+ logger, level, entry, timeStamp, location, threadName};
if (log_message_loop_thread) {
log_message_loop_thread->PostMessage(message);
return true;
@@ -56,17 +56,18 @@ bool push_log(log4cxx::LoggerPtr logger,
if (LoggerThreadNotCreated == logger_status) {
logger_status = CreatingLoggerThread;
-// we'll have to drop messages
-// while creating logger thread
+ // we'll have to drop messages
+ // while creating logger thread
create_log_message_loop_thread();
- LogMessage message = {logger, level, entry, timeStamp, location, threadName};
+ LogMessage message = {
+ logger, level, entry, timeStamp, location, threadName};
log_message_loop_thread->PostMessage(message);
logger_status = LoggerThreadCreated;
return true;
}
-// also we drop messages
-// while deleting logger thread
+ // also we drop messages
+ // while deleting logger thread
return false;
}
@@ -91,11 +92,11 @@ void delete_log_message_loop_thread() {
}
void flush_logger() {
- logger::LoggerStatus old_status = logger::logger_status;
- // Stop pushing new messages to the log queue
- logger::logger_status = logger::DeletingLoggerThread;
- log_message_loop_thread->WaitDumpQueue();
- logger::logger_status = old_status;
+ logger::LoggerStatus old_status = logger::logger_status;
+ // Stop pushing new messages to the log queue
+ logger::logger_status = logger::DeletingLoggerThread;
+ log_message_loop_thread->WaitDumpQueue();
+ logger::logger_status = old_status;
}
} // namespace logger
diff --git a/src/components/utils/src/qdb_wrapper/sql_database.cc b/src/components/utils/src/qdb_wrapper/sql_database.cc
index aabef97f3f..b95fe17845 100644
--- a/src/components/utils/src/qdb_wrapper/sql_database.cc
+++ b/src/components/utils/src/qdb_wrapper/sql_database.cc
@@ -40,10 +40,7 @@ namespace dbms {
CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
SQLDatabase::SQLDatabase(const std::string& db_name)
- : conn_(NULL),
- db_name_(db_name),
- error_(Error::OK) {
-}
+ : conn_(NULL), db_name_(db_name), error_(Error::OK) {}
SQLDatabase::~SQLDatabase() {
Close();
@@ -51,7 +48,8 @@ SQLDatabase::~SQLDatabase() {
bool SQLDatabase::Open() {
sync_primitives::AutoLock auto_lock(conn_lock_);
- if (conn_) return true;
+ if (conn_)
+ return true;
conn_ = qdb_connect(db_name_.c_str(), 0);
if (conn_ == NULL) {
error_ = Error::ERROR;
@@ -102,9 +100,9 @@ qdb_hdl_t* SQLDatabase::conn() const {
bool SQLDatabase::Backup() {
if (qdb_backup(conn_, QDB_ATTACH_DEFAULT) == -1) {
- error_ = Error::ERROR;
+ error_ = Error::ERROR;
LOG4CXX_ERROR(logger_, "Backup returned error: " << std::strerror(errno));
- return false;
+ return false;
}
LOG4CXX_INFO(logger_, "Backup was successful.");
return true;
diff --git a/src/components/utils/src/qdb_wrapper/sql_error.cc b/src/components/utils/src/qdb_wrapper/sql_error.cc
index 22b02a3452..c99a4d2ae3 100644
--- a/src/components/utils/src/qdb_wrapper/sql_error.cc
+++ b/src/components/utils/src/qdb_wrapper/sql_error.cc
@@ -36,9 +36,7 @@ namespace utils {
namespace dbms {
SQLError::SQLError(Error number, const std::string& text)
- : number_(number),
- text_(text) {
-}
+ : number_(number), text_(text) {}
Error SQLError::number() const {
return number_;
@@ -63,4 +61,3 @@ std::string SQLError::text() const {
} // namespace dbms
} // namespace utils
-
diff --git a/src/components/utils/src/qdb_wrapper/sql_query.cc b/src/components/utils/src/qdb_wrapper/sql_query.cc
index 755a595515..e5facb5853 100644
--- a/src/components/utils/src/qdb_wrapper/sql_query.cc
+++ b/src/components/utils/src/qdb_wrapper/sql_query.cc
@@ -41,70 +41,65 @@
namespace utils {
namespace dbms {
- CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
+CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
class SetBindInteger {
public:
- explicit SetBindInteger(qdb_binding_t* array)
- : array_(array) {
- }
+ explicit SetBindInteger(qdb_binding_t* array) : array_(array) {}
void operator()(const std::pair<int, int64_t>& x) {
// In QDB the number of position for binding starts since 1.
QDB_SETARRAYBIND_INT(array_, x.first + 1, x.second);
}
+
private:
qdb_binding_t* array_;
};
class SetBindReal {
public:
- explicit SetBindReal(qdb_binding_t* array)
- : array_(array) {
- }
+ explicit SetBindReal(qdb_binding_t* array) : array_(array) {}
void operator()(const std::pair<int, double>& x) {
// In QDB the number of position for binding starts since 1.
QDB_SETARRAYBIND_REAL(array_, x.first + 1, x.second);
}
+
private:
qdb_binding_t* array_;
};
class SetBindText {
public:
- explicit SetBindText(qdb_binding_t* array)
- : array_(array) {
- }
+ explicit SetBindText(qdb_binding_t* array) : array_(array) {}
void operator()(const std::pair<int, std::string>& x) {
// In QDB the number of position for binding starts since 1.
QDB_SETARRAYBIND_TEXT(array_, x.first + 1, x.second.c_str());
}
+
private:
qdb_binding_t* array_;
};
class SetBindNull {
public:
- explicit SetBindNull(qdb_binding_t* array)
- : array_(array) {
- }
+ explicit SetBindNull(qdb_binding_t* array) : array_(array) {}
void operator()(int x) {
// In QDB the number of position for binding starts since 1.
QDB_SETARRAYBIND_NULL(array_, x + 1);
}
+
private:
qdb_binding_t* array_;
};
SQLQuery::SQLQuery(SQLDatabase* db)
- : db_(db),
- query_(""),
- statement_(-1),
- bindings_(NULL),
- result_(NULL),
- current_row_(0),
- rows_(0),
- error_(Error::OK) {
-}
+ : db_(db)
+ , query_("")
+ , statement_(-1)
+ , bindings_(NULL)
+ , result_(NULL)
+ , current_row_(0)
+ , rows_(0)
+ , error_(Error::OK) {}
SQLQuery::~SQLQuery() {
Finalize();
@@ -124,17 +119,17 @@ bool SQLQuery::Prepare(const std::string& query) {
}
uint8_t SQLQuery::SetBinds() {
- uint8_t binding_count = int_binds_.size() + double_binds_.size()
- + string_binds_.size() + null_binds_.size();
+ uint8_t binding_count = int_binds_.size() + double_binds_.size() +
+ string_binds_.size() + null_binds_.size();
bindings_ = new qdb_binding_t[binding_count];
- std::for_each(int_binds_.begin(), int_binds_.end(),
- SetBindInteger(bindings_));
- std::for_each(double_binds_.begin(), double_binds_.end(),
- SetBindReal(bindings_));
- std::for_each(string_binds_.begin(), string_binds_.end(),
- SetBindText(bindings_));
+ std::for_each(
+ int_binds_.begin(), int_binds_.end(), SetBindInteger(bindings_));
+ std::for_each(
+ double_binds_.begin(), double_binds_.end(), SetBindReal(bindings_));
+ std::for_each(
+ string_binds_.begin(), string_binds_.end(), SetBindText(bindings_));
std::for_each(null_binds_.begin(), null_binds_.end(), SetBindNull(bindings_));
return binding_count;
@@ -239,7 +234,7 @@ bool SQLQuery::GetBoolean(int pos) const {
int SQLQuery::GetInteger(int pos) const {
void* ret = qdb_cell(result_, current_row_, pos);
- if (rows_ !=0 && ret) {
+ if (rows_ != 0 && ret) {
return *static_cast<int*>(ret);
}
return 0;
@@ -247,7 +242,7 @@ int SQLQuery::GetInteger(int pos) const {
uint32_t SQLQuery::GetUInteger(int pos) const {
void* ret = qdb_cell(result_, current_row_, pos);
- if (rows_ !=0 && ret) {
+ if (rows_ != 0 && ret) {
return *static_cast<uint32_t*>(ret);
}
return 0;
@@ -255,16 +250,15 @@ uint32_t SQLQuery::GetUInteger(int pos) const {
int64_t SQLQuery::GetLongInt(int pos) const {
void* ret = qdb_cell(result_, current_row_, pos);
- if (rows_ !=0 && ret) {
+ if (rows_ != 0 && ret) {
return *static_cast<int64_t*>(ret);
}
return 0;
}
-
double SQLQuery::GetDouble(int pos) const {
void* ret = qdb_cell(result_, current_row_, pos);
- if (rows_ !=0 && ret) {
+ if (rows_ != 0 && ret) {
return *static_cast<double*>(ret);
}
return 0;
@@ -297,4 +291,3 @@ int64_t SQLQuery::LastInsertId() const {
} // namespace dbms
} // namespace utils
-
diff --git a/src/components/utils/src/resource_usage.cc b/src/components/utils/src/resource_usage.cc
index 62c8d25b82..385c2bfa2e 100644
--- a/src/components/utils/src/resource_usage.cc
+++ b/src/components/utils/src/resource_usage.cc
@@ -47,7 +47,7 @@ bool Resources::ReadStatFile(std::string& output) {
if (false == file_system::FileExists(filename)) {
return false;
}
- if (false == file_system::ReadFile(filename,output)) {
+ if (false == file_system::ReadFile(filename, output)) {
return false;
}
return true;
@@ -60,61 +60,95 @@ bool Resources::GetProcInfo(Resources::PidStats& output) {
return false;
}
uint32_t num_succes = sscanf(proc_buf.c_str(),
- "%d" //pid
- " %*s"//com
- " %c" //state
- " %d" //ppid
- " %d" //pgrp
- " %d" //session
- " %d" //tty_nr
- " %d" //tpgid
- " %u" //flags
- " %lu" //minflt
- " %lu" //cminflt
- " %lu" //majflt
- " %lu" //cmajflt
- " %lu" //utime
- " %lu" //stime
- " %ld" //cutime
- " %ld" //cstime
- " %ld" //priority
- " %ld" //nice
- " %ld" //num_threads
- " %ld" //itrealvalue
- " %llu" //starttime
- " %lu" //vsize
- " %ld" //rss
- " %lu" //rsslim
- " %lu" //startcode
- " %lu" //endcode
- " %lu" //startstack
- " %lu" //kstkesp
- " %lu" //kstkip
- " %lu" //signal
- " %lu" //blocked
- " %lu" //sigignore
- " %lu" //sigcatch
- " %lu" //wchan
- " %lu" //nswap
- " %lu" //cnswap
- " %d" //exit_signal
- " %d" //processor
- " %u" //rt_priority
- " %u" //policy
- " %llu" //delayacct_blkio_ticks
- " %lu" //guest_time
- " %ld" //cguest_time
- ,&(output.pid), &(output.state), &(output.ppid), &(output.pgrp), &(output.session),
- &(output.tty_nr), &(output.tpgid), &(output.flags), &(output.minflt), &(output.cminflt),
- &(output.majflt), &(output.cmajflt), &(output.utime), &(output.stime), &(output.cutime),
- &(output.cstime), &(output.priority), &( output.nice), &(output.num_threads), &(output.itrealvalue),
- &(output.starttime), &(output.vsize), &(output.rss), &(output.rsslim), &(output.startcode),
- &(output.endcode), &(output.startstack), &(output.kstkesp), &(output.kstkeip), &(output.signal),
- &(output.blocked), &(output.sigignore), &(output.sigcatch), &(output.wchan), &(output.nswap),
- &(output.cnswap), &(output.exit_signal), &(output.processor), &(output.rt_priority), &(output.policy),
- &(output.delayacct_blkio_ticks), &(output.guest_time), &(output.cguest_time)
- );
- if(num_succes != 43) { // 43 is number of iteams in Resources::PidStats
+ "%d" // pid
+ " %*s" // com
+ " %c" // state
+ " %d" // ppid
+ " %d" // pgrp
+ " %d" // session
+ " %d" // tty_nr
+ " %d" // tpgid
+ " %u" // flags
+ " %lu" // minflt
+ " %lu" // cminflt
+ " %lu" // majflt
+ " %lu" // cmajflt
+ " %lu" // utime
+ " %lu" // stime
+ " %ld" // cutime
+ " %ld" // cstime
+ " %ld" // priority
+ " %ld" // nice
+ " %ld" // num_threads
+ " %ld" // itrealvalue
+ " %llu" // starttime
+ " %lu" // vsize
+ " %ld" // rss
+ " %lu" // rsslim
+ " %lu" // startcode
+ " %lu" // endcode
+ " %lu" // startstack
+ " %lu" // kstkesp
+ " %lu" // kstkip
+ " %lu" // signal
+ " %lu" // blocked
+ " %lu" // sigignore
+ " %lu" // sigcatch
+ " %lu" // wchan
+ " %lu" // nswap
+ " %lu" // cnswap
+ " %d" // exit_signal
+ " %d" // processor
+ " %u" // rt_priority
+ " %u" // policy
+ " %llu" // delayacct_blkio_ticks
+ " %lu" // guest_time
+ " %ld" // cguest_time
+ ,
+ &(output.pid),
+ &(output.state),
+ &(output.ppid),
+ &(output.pgrp),
+ &(output.session),
+ &(output.tty_nr),
+ &(output.tpgid),
+ &(output.flags),
+ &(output.minflt),
+ &(output.cminflt),
+ &(output.majflt),
+ &(output.cmajflt),
+ &(output.utime),
+ &(output.stime),
+ &(output.cutime),
+ &(output.cstime),
+ &(output.priority),
+ &(output.nice),
+ &(output.num_threads),
+ &(output.itrealvalue),
+ &(output.starttime),
+ &(output.vsize),
+ &(output.rss),
+ &(output.rsslim),
+ &(output.startcode),
+ &(output.endcode),
+ &(output.startstack),
+ &(output.kstkesp),
+ &(output.kstkeip),
+ &(output.signal),
+ &(output.blocked),
+ &(output.sigignore),
+ &(output.sigcatch),
+ &(output.wchan),
+ &(output.nswap),
+ &(output.cnswap),
+ &(output.exit_signal),
+ &(output.processor),
+ &(output.rt_priority),
+ &(output.policy),
+ &(output.delayacct_blkio_ticks),
+ &(output.guest_time),
+ &(output.cguest_time));
+ if (num_succes != 43) { // 43 is number of iteams in Resources::PidStats
LOG4CXX_ERROR(logger_, "Couldn't parse all iteams in /proc/PID/stat file");
return false;
}
@@ -122,8 +156,9 @@ bool Resources::GetProcInfo(Resources::PidStats& output) {
#elif defined(__QNXNTO__)
int fd = open(GetProcPath().c_str(), O_RDONLY);
if (0 >= fd) {
- LOG4CXX_ERROR(logger_, "Failed open process proc file : " << GetProcPath() <<
- "; error no : " << strerror( errno ) );
+ LOG4CXX_ERROR(logger_,
+ "Failed open process proc file : "
+ << GetProcPath() << "; error no : " << strerror(errno));
close(fd);
return false;
@@ -134,9 +169,9 @@ bool Resources::GetProcInfo(Resources::PidStats& output) {
#endif
}
-bool Resources::GetMemInfo(Resources::MemInfo &output) {
+bool Resources::GetMemInfo(Resources::MemInfo& output) {
bool result = false;
- #if defined(OS_LINUX)
+#if defined(OS_LINUX)
Resources::PidStats pid_stat;
if (false == GetProcInfo(pid_stat)) {
LOG4CXX_ERROR(logger_, "Failed to get proc info");
@@ -154,7 +189,7 @@ bool Resources::GetMemInfo(Resources::MemInfo &output) {
LOG4CXX_ERROR(logger_, "Unable to access to " << proc);
result = false;
return result;
- }
+ }
if (0 == readdir(proc_dir)) {
LOG4CXX_ERROR(logger_, "Unable to read : " << proc_dir);
closedir(proc_dir);
@@ -163,9 +198,9 @@ bool Resources::GetMemInfo(Resources::MemInfo &output) {
}
closedir(proc_dir);
if (-1 == stat(as_path.c_str(), &st) || 0 == st.st_size) {
- LOG4CXX_ERROR(logger_, "Unable to stat : " << as_path.c_str());
- result = false;
- return result;
+ LOG4CXX_ERROR(logger_, "Unable to stat : " << as_path.c_str());
+ result = false;
+ return result;
}
output = st.st_size;
result = true;
@@ -186,9 +221,9 @@ std::string Resources::GetStatPath() {
std::string Resources::GetProcPath() {
char buffer[1024];
pid_t my_pid = getpid();
- snprintf(buffer, sizeof(buffer), "%s%d/", proc , my_pid);
+ snprintf(buffer, sizeof(buffer), "%s%d/", proc, my_pid);
std::string filename(buffer);
return filename;
}
-} // namespace utils
+} // namespace utils
diff --git a/src/components/utils/src/sqlite_wrapper/sql_database.cc b/src/components/utils/src/sqlite_wrapper/sql_database.cc
index 88e43c3675..bf19275bac 100644
--- a/src/components/utils/src/sqlite_wrapper/sql_database.cc
+++ b/src/components/utils/src/sqlite_wrapper/sql_database.cc
@@ -40,14 +40,10 @@ const std::string SQLDatabase::kInMemory = ":memory:";
const std::string SQLDatabase::kExtension = ".sqlite";
SQLDatabase::SQLDatabase()
- : conn_(NULL),
- databasename_(kInMemory),
- error_(SQLITE_OK) {}
+ : conn_(NULL), databasename_(kInMemory), error_(SQLITE_OK) {}
SQLDatabase::SQLDatabase(const std::string& db_name)
- : conn_(NULL),
- databasename_(db_name + kExtension),
- error_(SQLITE_OK) {}
+ : conn_(NULL), databasename_(db_name + kExtension), error_(SQLITE_OK) {}
SQLDatabase::~SQLDatabase() {
Close();
@@ -55,7 +51,8 @@ SQLDatabase::~SQLDatabase() {
bool SQLDatabase::Open() {
sync_primitives::AutoLock auto_lock(conn_lock_);
- if (conn_) return true;
+ if (conn_)
+ return true;
error_ = sqlite3_open(databasename_.c_str(), &conn_);
return error_ == SQLITE_OK;
}
@@ -104,7 +101,7 @@ sqlite3* SQLDatabase::conn() const {
}
void SQLDatabase::set_path(const std::string& path) {
- databasename_ = path + databasename_;
+ databasename_ = path + databasename_;
}
std::string SQLDatabase::get_path() const {
@@ -112,7 +109,7 @@ std::string SQLDatabase::get_path() const {
}
bool SQLDatabase::Backup() {
- return true;
+ return true;
}
} // namespace dbms
} // namespace utils
diff --git a/src/components/utils/src/sqlite_wrapper/sql_error.cc b/src/components/utils/src/sqlite_wrapper/sql_error.cc
index 791d3455f1..9062731a81 100644
--- a/src/components/utils/src/sqlite_wrapper/sql_error.cc
+++ b/src/components/utils/src/sqlite_wrapper/sql_error.cc
@@ -36,9 +36,7 @@ namespace utils {
namespace dbms {
SQLError::SQLError(Error number, const std::string& text)
- : number_(number),
- text_(text) {
-}
+ : number_(number), text_(text) {}
Error SQLError::number() const {
return number_;
@@ -150,4 +148,3 @@ std::string SQLError::text() const {
} // namespace dbms
} // namespace utils
-
diff --git a/src/components/utils/src/sqlite_wrapper/sql_query.cc b/src/components/utils/src/sqlite_wrapper/sql_query.cc
index ba2af76663..5a62ec360d 100644
--- a/src/components/utils/src/sqlite_wrapper/sql_query.cc
+++ b/src/components/utils/src/sqlite_wrapper/sql_query.cc
@@ -39,11 +39,7 @@ namespace utils {
namespace dbms {
SQLQuery::SQLQuery(SQLDatabase* db)
- : db_(*db),
- query_(""),
- statement_(NULL),
- error_(SQLITE_OK) {
-}
+ : db_(*db), query_(""), statement_(NULL), error_(SQLITE_OK) {}
SQLQuery::~SQLQuery() {
Finalize();
@@ -52,9 +48,10 @@ SQLQuery::~SQLQuery() {
bool SQLQuery::Prepare(const std::string& query) {
Finalize();
sync_primitives::AutoLock auto_lock(statement_lock_);
- if (statement_) return false;
- error_ = sqlite3_prepare(db_.conn(), query.c_str(), query.length(),
- &statement_, NULL);
+ if (statement_)
+ return false;
+ error_ = sqlite3_prepare(
+ db_.conn(), query.c_str(), query.length(), &statement_, NULL);
query_ = query;
return error_ == SQLITE_OK;
}
@@ -109,8 +106,8 @@ void SQLQuery::Bind(int pos, bool value) {
void SQLQuery::Bind(int pos, const std::string& value) {
// In SQLite the number of position for binding starts since 1.
- error_ = sqlite3_bind_text(statement_, pos + 1, value.c_str(), value.length(),
- SQLITE_TRANSIENT);
+ error_ = sqlite3_bind_text(
+ statement_, pos + 1, value.c_str(), value.length(), SQLITE_TRANSIENT);
}
bool SQLQuery::GetBoolean(int pos) const {
@@ -122,13 +119,11 @@ int SQLQuery::GetInteger(int pos) const {
}
uint32_t SQLQuery::GetUInteger(int pos) const {
- return static_cast<uint32_t>(
- sqlite3_column_int64(statement_, pos));
+ return static_cast<uint32_t>(sqlite3_column_int64(statement_, pos));
}
int64_t SQLQuery::GetLongInt(int pos) const {
- return static_cast<int64_t>(
- sqlite3_column_int64(statement_, pos));
+ return static_cast<int64_t>(sqlite3_column_int64(statement_, pos));
}
double SQLQuery::GetDouble(int pos) const {
@@ -164,4 +159,3 @@ int64_t SQLQuery::LastInsertId() const {
} // namespace dbms
} // namespace utils
-
diff --git a/src/components/utils/src/system.cc b/src/components/utils/src/system.cc
index 70659419a7..6c3cf56133 100644
--- a/src/components/utils/src/system.cc
+++ b/src/components/utils/src/system.cc
@@ -30,13 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __QNX__
-# include <process.h>
+#include <process.h>
#else // __QNX__
-# include <sys/types.h>
-# include <sys/wait.h>
-# include <sys/stat.h>
-# include <fcntl.h>
-# include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
#endif // __QNX__
#include <algorithm>
@@ -52,13 +52,12 @@ namespace utils {
CREATE_LOGGERPTR_LOCAL(logger_, "Utils")
struct GetCString {
- char * operator ()(const std::string& string) {
+ char* operator()(const std::string& string) {
return const_cast<char*>(string.c_str());
}
};
-System::System(const std::string& command)
- : command_(command) {
+System::System(const std::string& command) : command_(command) {
argv_.push_back(command);
}
@@ -88,7 +87,7 @@ bool System::Execute() {
bool System::Execute(bool wait) {
size_t size = argv_.size();
- char * *argv = new char*[size + 1];
+ char** argv = new char* [size + 1];
std::transform(argv_.begin(), argv_.end(), argv, GetCString());
argv[size] = NULL;
@@ -97,8 +96,9 @@ bool System::Execute(bool wait) {
delete[] argv;
if (ret == -1) {
- LOG4CXX_ERROR(logger_, "Can't execute command: " << command_
- << " Errno is: " << std::strerror(errno));
+ LOG4CXX_ERROR(logger_,
+ "Can't execute command: " << command_ << " Errno is: "
+ << std::strerror(errno));
return false;
}
@@ -137,7 +137,7 @@ bool System::Execute(bool wait) {
dup2(fd_dev0, STDERR_FILENO);
size_t size = argv_.size();
- char * *argv = new char*[size + 1];
+ char** argv = new char* [size + 1];
std::transform(argv_.begin(), argv_.end(), argv, GetCString());
argv[size] = NULL;
diff --git a/src/components/utils/src/threads/async_runner.cc b/src/components/utils/src/threads/async_runner.cc
index f580eebaf0..131aaa3f78 100644
--- a/src/components/utils/src/threads/async_runner.cc
+++ b/src/components/utils/src/threads/async_runner.cc
@@ -40,11 +40,10 @@ namespace threads {
CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
-AsyncRunner::AsyncRunner(const std::string &thread_name)
- : executor_(new AsyncRunnerDelegate) {
+AsyncRunner::AsyncRunner(const std::string& thread_name)
+ : executor_(new AsyncRunnerDelegate) {
LOG4CXX_AUTO_TRACE(logger_);
- thread_ = threads::CreateThread(thread_name.c_str(),
- executor_);
+ thread_ = threads::CreateThread(thread_name.c_str(), executor_);
thread_->start();
}
@@ -65,9 +64,7 @@ AsyncRunner::~AsyncRunner() {
threads::DeleteThread(thread_);
}
-AsyncRunner::AsyncRunnerDelegate::AsyncRunnerDelegate()
- : stop_flag_(false) {
-}
+AsyncRunner::AsyncRunnerDelegate::AsyncRunnerDelegate() : stop_flag_(false) {}
void AsyncRunner::AsyncRunnerDelegate::processDelegate() {
if (!delegates_queue_.empty()) {
@@ -113,4 +110,4 @@ void AsyncRunner::AsyncRunnerDelegate::runDelegate(ThreadDelegate* delegate) {
delegate_notifier_.NotifyOne();
}
-} // namespace policy.
+} // namespace policy.
diff --git a/src/components/utils/src/threads/pulse_thread_delegate.cc b/src/components/utils/src/threads/pulse_thread_delegate.cc
index 68db5dcbea..37e6c670d1 100644
--- a/src/components/utils/src/threads/pulse_thread_delegate.cc
+++ b/src/components/utils/src/threads/pulse_thread_delegate.cc
@@ -61,7 +61,8 @@ PulseThreadDelegate::PulseThreadDelegate() : run_(false) {
void PulseThreadDelegate::threadMain() {
if (!Init()) {
- LOG4CXX_ERROR(logger_, "Failed to initialize thread for QNX channel " << chid_);
+ LOG4CXX_ERROR(logger_,
+ "Failed to initialize thread for QNX channel " << chid_);
return;
}
while (run_) {
@@ -77,13 +78,14 @@ void PulseThreadDelegate::threadMain() {
OnPulse();
break;
}
- }
- else {
+ } else {
if (run_) {
- LOG4CXX_WARN(logger_, "Error occurred while waiting for pulse on QNX channel " << chid_);
- }
- else {
- LOG4CXX_INFO(logger_, "QNX channel " << chid_ << " is apparently destroyed");
+ LOG4CXX_WARN(logger_,
+ "Error occurred while waiting for pulse on QNX channel "
+ << chid_);
+ } else {
+ LOG4CXX_INFO(logger_,
+ "QNX channel " << chid_ << " is apparently destroyed");
}
}
}
@@ -97,16 +99,14 @@ void PulseThreadDelegate::exitThreadMain() {
LOG4CXX_TRACE(logger_, "Disconnecting from QNX channel " << chid_);
if (ConnectDetach(coid_) != -1) {
LOG4CXX_DEBUG(logger_, "Disconnected from QNX channel " << chid_);
- }
- else {
+ } else {
LOG4CXX_WARN(logger_, "Failed to disconnect from QNX channel " << chid_);
}
LOG4CXX_TRACE(logger_, "Destroying QNX channel " << chid_);
- if (ChannelDestroy(chid_) != -1) { // unblocks MsgReceivePulse()
+ if (ChannelDestroy(chid_) != -1) { // unblocks MsgReceivePulse()
LOG4CXX_DEBUG(logger_, "QNX channel " << chid_ << " destroyed");
- }
- else {
+ } else {
LOG4CXX_WARN(logger_, "Failed to destroy QNX channel " << chid_);
}
}
diff --git a/src/components/utils/src/threads/thread_delegate.cc b/src/components/utils/src/threads/thread_delegate.cc
index 417bae5753..7bdce000da 100644
--- a/src/components/utils/src/threads/thread_delegate.cc
+++ b/src/components/utils/src/threads/thread_delegate.cc
@@ -55,7 +55,7 @@ void ThreadDelegate::exitThreadMain() {
}
}
-void ThreadDelegate::set_thread(Thread *thread) {
+void ThreadDelegate::set_thread(Thread* thread) {
DCHECK(thread);
thread_ = thread;
}
diff --git a/src/components/utils/src/threads/thread_manager.cc b/src/components/utils/src/threads/thread_manager.cc
index 528dc8c4de..2959a86cb7 100644
--- a/src/components/utils/src/threads/thread_manager.cc
+++ b/src/components/utils/src/threads/thread_manager.cc
@@ -51,4 +51,4 @@ namespace threads {
CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
-} // namespace threads
+} // namespace threads
diff --git a/src/components/utils/src/threads/thread_validator.cc b/src/components/utils/src/threads/thread_validator.cc
index 99b812c456..4024522ae4 100644
--- a/src/components/utils/src/threads/thread_validator.cc
+++ b/src/components/utils/src/threads/thread_validator.cc
@@ -39,39 +39,32 @@ namespace threads {
CREATE_LOGGERPTR_GLOBAL(logger_, "Utils")
SingleThreadSimpleValidator::SingleThreadSimpleValidator()
- : creation_thread_id_(Thread::CurrentId()) {
-}
+ : creation_thread_id_(Thread::CurrentId()) {}
-SingleThreadSimpleValidator::~SingleThreadSimpleValidator() {
-}
+SingleThreadSimpleValidator::~SingleThreadSimpleValidator() {}
void SingleThreadSimpleValidator::AssertRunningOnCreationThread() const {
PlatformThreadHandle current_id = Thread::CurrentId();
if (creation_thread_id_ != current_id) {
- LOG4CXX_ERROR(logger_, "Single-threaded object created at thread "
- << creation_thread_id_
- <<" is accessed from thread "
- << current_id
+ LOG4CXX_ERROR(logger_,
+ "Single-threaded object created at thread "
+ << creation_thread_id_ << " is accessed from thread "
+ << current_id
#ifdef BACKTRACE_SUPPORT
- << "\n"
- << utils::Backtrace()
+ << "\n" << utils::Backtrace()
#endif
- );
+ );
}
}
-PlatformThreadHandle SingleThreadSimpleValidator::creation_thread_id() const
-{
+PlatformThreadHandle SingleThreadSimpleValidator::creation_thread_id() const {
return creation_thread_id_;
}
-
SingleThreadValidator::SingleThreadValidator()
- : owning_thread_id_(Thread::CurrentId()){
-}
+ : owning_thread_id_(Thread::CurrentId()) {}
-SingleThreadValidator::~SingleThreadValidator() {
-}
+SingleThreadValidator::~SingleThreadValidator() {}
void SingleThreadValidator::PassToThread(PlatformThreadHandle thread_id) const {
owning_thread_id_ = thread_id;
@@ -80,18 +73,17 @@ void SingleThreadValidator::PassToThread(PlatformThreadHandle thread_id) const {
void SingleThreadValidator::AssertRunningOnValidThread() const {
PlatformThreadHandle current_id = Thread::CurrentId();
if (owning_thread_id_ != current_id) {
- LOG4CXX_ERROR(logger_, "Single-threaded object owned by thread "
- << owning_thread_id_
- << " is accessed from thread "
- << current_id << "\n"
+ LOG4CXX_ERROR(logger_,
+ "Single-threaded object owned by thread "
+ << owning_thread_id_ << " is accessed from thread "
+ << current_id << "\n"
#ifdef BACKTRACE_SUPPORT
- << utils::Backtrace()
+ << utils::Backtrace()
#endif
- );
+ );
}
}
-
-} // namespace threads
+} // namespace threads
// vim: set ts=2 sw=2 et:
diff --git a/src/components/utils/src/timer.cc b/src/components/utils/src/timer.cc
index 99141d61b7..d1d1ec5f3b 100644
--- a/src/components/utils/src/timer.cc
+++ b/src/components/utils/src/timer.cc
@@ -150,9 +150,9 @@ void timer::Timer::TimerDelegate::threadMain() {
LOG4CXX_DEBUG(logger_, "Milliseconds left to wait: " << curr_timeout);
if (sync_primitives::ConditionalVariable::kTimeout ==
termination_condition_.WaitFor(auto_lock, curr_timeout)) {
- LOG4CXX_DEBUG(logger_,
- "Timer has finished counting. Timeout (ms): "
- << curr_timeout);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Timer has finished counting. Timeout (ms): " << curr_timeout);
if (timer_) {
timer_->OnTimeout();
}
diff --git a/src/components/utils/test/async_runner_test.cc b/src/components/utils/test/async_runner_test.cc
index e0db33bb96..9b71d8732f 100644
--- a/src/components/utils/test/async_runner_test.cc
+++ b/src/components/utils/test/async_runner_test.cc
@@ -59,9 +59,7 @@ class TestThreadDelegate : public ThreadDelegate {
class AsyncRunnerTest : public ::testing::Test {
public:
- AsyncRunnerTest()
- : kDelegatesNum_(1),
- asr_pt_(NULL) {
+ AsyncRunnerTest() : kDelegatesNum_(1), asr_pt_(NULL) {
CreateAsyncRunner();
CreateThreadsArray();
}
@@ -75,13 +73,13 @@ class AsyncRunnerTest : public ::testing::Test {
Lock test_lock_;
uint32_t kDelegatesNum_;
ConditionalVariable cond_var_;
- TestThreadDelegate **delegates_;
- AsyncRunner *asr_pt_;
+ TestThreadDelegate** delegates_;
+ AsyncRunner* asr_pt_;
void CreateThreadsArray() {
srand(std::time(NULL));
kDelegatesNum_ = (rand() % 20 + 1);
- delegates_ = new TestThreadDelegate*[kDelegatesNum_];
+ delegates_ = new TestThreadDelegate* [kDelegatesNum_];
}
void DeleteThreadsArray() {
@@ -111,8 +109,9 @@ TEST_F(AsyncRunnerTest, ASyncRunManyDelegates_ExpectSuccessfulAllDelegatesRun) {
EXPECT_EQ(kDelegatesNum_, check_value);
}
-//TODO(VVeremjova) APPLINK-12834 Sometimes delegates do not run
-TEST_F(AsyncRunnerTest, DISABLED_RunManyDelegatesAndStop_ExpectSuccessfulDelegatesStop) {
+// TODO(VVeremjova) APPLINK-12834 Sometimes delegates do not run
+TEST_F(AsyncRunnerTest,
+ DISABLED_RunManyDelegatesAndStop_ExpectSuccessfulDelegatesStop) {
AutoLock lock(test_lock_);
// Clear global value before test
check_value = 0;
@@ -138,4 +137,3 @@ TEST_F(AsyncRunnerTest, DISABLED_RunManyDelegatesAndStop_ExpectSuccessfulDelegat
} // namespace utils
} // namespace components
} // namespace test
-
diff --git a/src/components/utils/test/back_trace_test.cc b/src/components/utils/test/back_trace_test.cc
index 12d5df81fc..071c4d3342 100644
--- a/src/components/utils/test/back_trace_test.cc
+++ b/src/components/utils/test/back_trace_test.cc
@@ -40,11 +40,10 @@ namespace utils {
using namespace ::utils;
TEST(BackTraceTest, CallStackShouldNotBeEmpty) {
-
- //arrange
+ // arrange
Backtrace newtrace = Backtrace();
- std::vector < std::string > symbols = newtrace.CallStack();
- //assert
+ std::vector<std::string> symbols = newtrace.CallStack();
+ // assert
ASSERT_FALSE(symbols.empty());
}
diff --git a/src/components/utils/test/bitstream_test.cc b/src/components/utils/test/bitstream_test.cc
index 07a80bde07..df27aaa835 100644
--- a/src/components/utils/test/bitstream_test.cc
+++ b/src/components/utils/test/bitstream_test.cc
@@ -42,19 +42,19 @@ namespace utils {
using ::utils::BitStream;
TEST(BitstreamTest, CreateBitstream_WithDataWithDatasize_BitStreamIsGood) {
-
- //arrange
+ // arrange
uint8_t data = 10;
size_t bits = 2;
BitStream bs(&data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
-TEST(BitstreamTest, ExtractBitstreamInUint8_ExtractAllData_BitStreamIsGoodDataExtractedCorrectly) {
-
- //arrange
+TEST(
+ BitstreamTest,
+ ExtractBitstreamInUint8_ExtractAllData_BitStreamIsGoodDataExtractedCorrectly) {
+ // arrange
uint8_t data = 10;
size_t bits = 2;
BitStream bs(&data, bits);
@@ -62,15 +62,15 @@ TEST(BitstreamTest, ExtractBitstreamInUint8_ExtractAllData_BitStreamIsGoodDataEx
uint8_t extract_data = 0;
Extract(&bs, &extract_data);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
EXPECT_EQ(data, extract_data);
}
-TEST(BitstreamTest, ExtractBitstreamInUint8_WithDataWithZeroSize_BitStreamIsBad) {
-
- //arrange
+TEST(BitstreamTest,
+ ExtractBitstreamInUint8_WithDataWithZeroSize_BitStreamIsBad) {
+ // arrange
uint8_t data = 10;
size_t bits = 0;
BitStream bs(&data, bits);
@@ -78,13 +78,14 @@ TEST(BitstreamTest, ExtractBitstreamInUint8_WithDataWithZeroSize_BitStreamIsBad)
uint8_t extract_data = 0;
Extract(&bs, &extract_data);
- //assert
+ // assert
EXPECT_TRUE(bs.IsBad());
}
-TEST(BitstreamTest, ExtractBitstreamInUint32_WithDatasizeEq4_BitStreamIsGoodDataExtractedCorrectly) {
-
- //arrange
+TEST(
+ BitstreamTest,
+ ExtractBitstreamInUint32_WithDatasizeEq4_BitStreamIsGoodDataExtractedCorrectly) {
+ // arrange
uint8_t data = 10;
size_t bits = 4;
BitStream bs(&data, bits);
@@ -92,14 +93,12 @@ TEST(BitstreamTest, ExtractBitstreamInUint32_WithDatasizeEq4_BitStreamIsGoodData
uint32_t extract_data = 0;
Extract(&bs, &extract_data);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
-
}
TEST(BitstreamTest, ExtractBitstreamInUint32_DatasizeLess4_BitStreamIsBad) {
-
- //arrange
+ // arrange
uint8_t data = 10;
size_t bits = 3;
BitStream bs(&data, bits);
@@ -107,14 +106,12 @@ TEST(BitstreamTest, ExtractBitstreamInUint32_DatasizeLess4_BitStreamIsBad) {
uint32_t extract_data = 0;
Extract(&bs, &extract_data);
- //assert
+ // assert
EXPECT_TRUE(bs.IsBad());
-
}
TEST(BitstreamTest, ExtractFullBitstream_WithDataWithDatasize_BitStreamIsGood) {
-
- //arrange
+ // arrange
uint8_t data = 10;
size_t bits = 8;
BitStream bs(&data, bits);
@@ -123,15 +120,15 @@ TEST(BitstreamTest, ExtractFullBitstream_WithDataWithDatasize_BitStreamIsGood) {
Extract(&bs, &extract_data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
EXPECT_EQ(data, extract_data);
}
-TEST(BitstreamTest, ExtractBitstreamInString_WithDataWithDatasize_BitStreamIsGood) {
-
- //arrange
+TEST(BitstreamTest,
+ ExtractBitstreamInString_WithDataWithDatasize_BitStreamIsGood) {
+ // arrange
uint8_t data = 10;
size_t bits = 2;
BitStream bs(&data, bits);
@@ -141,46 +138,45 @@ TEST(BitstreamTest, ExtractBitstreamInString_WithDataWithDatasize_BitStreamIsGoo
Extract(&bs, &strdata, length);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
TEST(BitstreamTest, CreateBitstream_NoDataZeroDatasize_BitStreamIsGood) {
-
- //arrange
- uint8_t *data = NULL;
+ // arrange
+ uint8_t* data = NULL;
size_t bits = 0;
BitStream bs(data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
-TEST(BitstreamTest, CreateBitstream_NoDataWithUpperboundDataSize_BitStreamIsGood) {
-
- //arrange
- uint8_t *data = NULL;
+TEST(BitstreamTest,
+ CreateBitstream_NoDataWithUpperboundDataSize_BitStreamIsGood) {
+ // arrange
+ uint8_t* data = NULL;
size_t bits = 65535;
BitStream bs(data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
-TEST(BitstreamTest, CreateBitstream_WithUpperboundDataWithLessDataSize_BitStreamIsGood) {
-
- //arrange
+TEST(BitstreamTest,
+ CreateBitstream_WithUpperboundDataWithLessDataSize_BitStreamIsGood) {
+ // arrange
uint8_t data = 255;
size_t bits = sizeof(char);
BitStream bs(&data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
-TEST(BitstreamTest, ExtractBitstream_WithUpperboundDataWithLessDataSize_BitStreamIsGood) {
-
- //arrange
+TEST(BitstreamTest,
+ ExtractBitstream_WithUpperboundDataWithLessDataSize_BitStreamIsGood) {
+ // arrange
uint8_t data = 255;
size_t bits = sizeof(char);
BitStream bs(&data, bits);
@@ -188,13 +184,13 @@ TEST(BitstreamTest, ExtractBitstream_WithUpperboundDataWithLessDataSize_BitStrea
uint8_t extract_data = 0;
Extract(&bs, &extract_data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
-TEST(BitstreamTest, ExtractBitstream_WithUpperboundDataWithZeroDataSize_BitStreamIsGood) {
-
- //arrange
+TEST(BitstreamTest,
+ ExtractBitstream_WithUpperboundDataWithZeroDataSize_BitStreamIsGood) {
+ // arrange
uint8_t data = 255;
size_t bits = 0;
BitStream bs(&data, bits);
@@ -202,26 +198,25 @@ TEST(BitstreamTest, ExtractBitstream_WithUpperboundDataWithZeroDataSize_BitStrea
uint8_t extract_data = 0;
Extract(&bs, &extract_data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
}
TEST(BitstreamTest, ExtractBitstream_WithDataMarkedBad_ExpectIsBad) {
-
- //arrange
+ // arrange
uint8_t data = 255;
size_t bits = sizeof(int);
BitStream bs(&data, bits);
- //assert
+ // assert
EXPECT_TRUE(bs.IsGood());
- //act
+ // act
bs.MarkBad();
- //assert
+ // assert
EXPECT_TRUE(bs.IsBad());
- //act
+ // act
Extract(&bs, &data, bits);
- //arrange
+ // arrange
EXPECT_TRUE(bs.IsBad());
}
diff --git a/src/components/utils/test/conditional_variable_test.cc b/src/components/utils/test/conditional_variable_test.cc
index a898732ffc..fe93e17617 100644
--- a/src/components/utils/test/conditional_variable_test.cc
+++ b/src/components/utils/test/conditional_variable_test.cc
@@ -45,22 +45,20 @@ namespace utils {
class ConditionalVariableTest : public ::testing::Test {
public:
- ConditionalVariableTest()
- : test_value_("initialized"),
- counter_(0) {
- }
+ ConditionalVariableTest() : test_value_("initialized"), counter_(0) {}
void check_counter();
void task_one();
- static void* check_counter_helper(void *context) {
- (reinterpret_cast<ConditionalVariableTest *>(context))->check_counter();
+ static void* check_counter_helper(void* context) {
+ (reinterpret_cast<ConditionalVariableTest*>(context))->check_counter();
return NULL;
}
- static void* task_one_helper(void *context) {
- (reinterpret_cast<ConditionalVariableTest *>(context))->task_one();
+ static void* task_one_helper(void* context) {
+ (reinterpret_cast<ConditionalVariableTest*>(context))->task_one();
return NULL;
}
+
protected:
std::string test_value_;
sync_primitives::ConditionalVariable cond_var_;
@@ -73,10 +71,13 @@ void ConditionalVariableTest::check_counter() {
sync_primitives::AutoLock test_lock(test_mutex_);
if (counter_ <= 1) {
counter_++;
- cond_var_.Wait(test_mutex_); // Mutex unlock & Thread sleeps until Notification
- }
- else if(counter_ == 2) { // Checking for equal 2 in this specific case. Because we were waiting for 2 threads to be finished
- cond_var_.Broadcast(); // Notify All threads waiting on conditional variable
+ cond_var_.Wait(
+ test_mutex_); // Mutex unlock & Thread sleeps until Notification
+ } else if (counter_ == 2) { // Checking for equal 2 in this specific case.
+ // Because we were waiting for 2 threads to be
+ // finished
+ cond_var_
+ .Broadcast(); // Notify All threads waiting on conditional variable
}
}
@@ -84,18 +85,18 @@ void ConditionalVariableTest::check_counter() {
void ConditionalVariableTest::task_one() {
sync_primitives::AutoLock test_lock(test_mutex_);
test_value_ = "changed by thread 1";
- cond_var_.NotifyOne(); // Notify At least one thread waiting on conditional variable
+ cond_var_.NotifyOne(); // Notify At least one thread waiting on conditional
+ // variable
test_value_ = "changed again by thread 1";
}
-TEST_F(ConditionalVariableTest, CheckNotifyOne_OneThreadNotified_ExpectSuccessful) {
+TEST_F(ConditionalVariableTest,
+ CheckNotifyOne_OneThreadNotified_ExpectSuccessful) {
pthread_t thread1;
sync_primitives::AutoLock test_lock(test_mutex_);
test_value_ = "changed by main thread";
- const bool thread_created = pthread_create(&thread1,
- NULL,
- &ConditionalVariableTest::task_one_helper,
- this);
+ const bool thread_created = pthread_create(
+ &thread1, NULL, &ConditionalVariableTest::task_one_helper, this);
ASSERT_FALSE(thread_created) << "thread1 is not created!";
test_value_ = "changed twice by main thread";
cond_var_.WaitFor(test_lock, 2000);
@@ -103,30 +104,29 @@ TEST_F(ConditionalVariableTest, CheckNotifyOne_OneThreadNotified_ExpectSuccessfu
EXPECT_EQ(last_value, test_value_);
}
-TEST_F(ConditionalVariableTest, CheckBroadcast_AllThreadsNotified_ExpectSuccessful) {
+TEST_F(ConditionalVariableTest,
+ CheckBroadcast_AllThreadsNotified_ExpectSuccessful) {
pthread_t thread1;
pthread_t thread2;
- bool thread_created = pthread_create(&thread1,
- NULL,
- &ConditionalVariableTest::check_counter_helper,
- this);
+ bool thread_created = pthread_create(
+ &thread1, NULL, &ConditionalVariableTest::check_counter_helper, this);
ASSERT_FALSE(thread_created) << "thread1 is not created!";
- thread_created = pthread_create(&thread2,
- NULL,
- &ConditionalVariableTest::check_counter_helper,
- this);
+ thread_created = pthread_create(
+ &thread2, NULL, &ConditionalVariableTest::check_counter_helper, this);
ASSERT_FALSE(thread_created) << "thread2 is not created!";
check_counter();
EXPECT_EQ(2u, counter_);
}
-TEST_F(ConditionalVariableTest, CheckWaitForWithTimeout1sec_ThreadBlockedForTimeout_ExpectSuccessfulWakeUp) {
+TEST_F(
+ ConditionalVariableTest,
+ CheckWaitForWithTimeout1sec_ThreadBlockedForTimeout_ExpectSuccessfulWakeUp) {
sync_primitives::AutoLock test_lock(test_mutex_);
- sync_primitives::ConditionalVariable::WaitStatus wait_st = cond_var_.WaitFor(test_lock, 1000);
+ sync_primitives::ConditionalVariable::WaitStatus wait_st =
+ cond_var_.WaitFor(test_lock, 1000);
EXPECT_EQ(sync_primitives::ConditionalVariable::kTimeout, wait_st);
}
} // namespace utils
} // namespace components
} // namespace test
-
diff --git a/src/components/utils/test/data_accessor_test.cc b/src/components/utils/test/data_accessor_test.cc
index 105ec8517f..b15310ff3f 100644
--- a/src/components/utils/test/data_accessor_test.cc
+++ b/src/components/utils/test/data_accessor_test.cc
@@ -39,31 +39,28 @@ namespace components {
namespace utils {
TEST(DataAccessorTest, CreateDataAccessor) {
-
- //arrange
+ // arrange
int test_value = 10;
sync_primitives::Lock testSet_lock_;
DataAccessor<int> testdata(test_value, testSet_lock_);
int data_from_testdata = testdata.GetData();
- //assert
+ // assert
EXPECT_EQ(test_value, data_from_testdata);
}
TEST(DataAccessorTest, CreateDataAccessor_MutexIsLocked_CannotLockItAgain) {
-
- //arrange
+ // arrange
int test_value = 10;
sync_primitives::Lock testSet_lock_;
DataAccessor<int> testdata(test_value, testSet_lock_);
- //assert
+ // assert
EXPECT_FALSE(testSet_lock_.Try());
}
TEST(DataAccessorTest, CopyDataAccessor_GetDataFromDataAccessors) {
-
- //arrange
+ // arrange
int test_value = 10;
sync_primitives::Lock testSet_lock_;
DataAccessor<int> testdata(test_value, testSet_lock_);
@@ -72,15 +69,15 @@ TEST(DataAccessorTest, CopyDataAccessor_GetDataFromDataAccessors) {
int data_from_testdata = testdata.GetData();
int data_from_testdata_copy = testdata_copy.GetData();
- //assert
+ // assert
EXPECT_EQ(data_from_testdata, data_from_testdata_copy);
EXPECT_FALSE(testSet_lock_.Try());
}
-TEST(DataAccessorTest,ChangedDataInDataAccessor_ChangeData_DataInDataAccessorIsChanged) {
-
- //arrange
+TEST(DataAccessorTest,
+ ChangedDataInDataAccessor_ChangeData_DataInDataAccessorIsChanged) {
+ // arrange
int test_value = 10;
sync_primitives::Lock testSet_lock_;
DataAccessor<int> testdata(test_value, testSet_lock_);
@@ -88,32 +85,31 @@ TEST(DataAccessorTest,ChangedDataInDataAccessor_ChangeData_DataInDataAccessorIsC
int data_from_testdata_after_change = testdata.GetData();
- //assert
+ // assert
EXPECT_EQ(test_value, data_from_testdata_after_change);
}
-TEST(DataAccessorTest, DeleteDataAccessor_CreatedOneDeleteOneThread_MutexIsUnlocked) {
-
- //arrange
+TEST(DataAccessorTest,
+ DeleteDataAccessor_CreatedOneDeleteOneThread_MutexIsUnlocked) {
+ // arrange
int test_value = 10;
sync_primitives::Lock testSet_lock_;
{
DataAccessor<int> testdata(test_value, testSet_lock_);
- //assert
+ // assert
EXPECT_FALSE(testSet_lock_.Try());
}
- //assert
+ // assert
EXPECT_TRUE(testSet_lock_.Try());
testSet_lock_.Release();
-
}
-TEST(DataAccessorTest, DeleteDataAccessor_CreatedThreadAndCopyDeleteBothThreads_MutexIsUnlocked) {
-
- //arrange
+TEST(DataAccessorTest,
+ DeleteDataAccessor_CreatedThreadAndCopyDeleteBothThreads_MutexIsUnlocked) {
+ // arrange
int test_value = 10;
sync_primitives::Lock testSet_lock_;
{
@@ -121,18 +117,16 @@ TEST(DataAccessorTest, DeleteDataAccessor_CreatedThreadAndCopyDeleteBothThreads_
{
DataAccessor<int> testdata_copy(testdata);
- //assert
+ // assert
EXPECT_FALSE(testSet_lock_.Try());
}
- //assert
+ // assert
EXPECT_FALSE(testSet_lock_.Try());
-
}
- //assert
+ // assert
EXPECT_TRUE(testSet_lock_.Try());
testSet_lock_.Release();
-
}
} // namespace utils
diff --git a/src/components/utils/test/date_time_test.cc b/src/components/utils/test/date_time_test.cc
index c5deba8f5c..fc34b7a998 100644
--- a/src/components/utils/test/date_time_test.cc
+++ b/src/components/utils/test/date_time_test.cc
@@ -39,86 +39,85 @@ namespace utils {
using namespace date_time;
TEST(DateTimeTest, GetCurrentTime) {
-
- //arrange
+ // arrange
const TimevalStruct time1 = date_time::DateTime::getCurrentTime();
- //assert
+ // assert
ASSERT_NE(0, time1.tv_sec);
ASSERT_GE(time1.tv_usec, 0);
- //act
+ // act
const TimevalStruct time2 = date_time::DateTime::getCurrentTime();
- //assert
+ // assert
ASSERT_NE(0, time2.tv_sec);
ASSERT_GE(time2.tv_usec, 0);
ASSERT_GE(time2.tv_sec, time1.tv_sec);
}
TEST(DateTimeTest, GetSecs) {
- //arrange
+ // arrange
TimevalStruct time;
time.tv_sec = 1;
time.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
- //assert
+ // assert
ASSERT_EQ(1, date_time::DateTime::getSecs(time));
}
TEST(DateTimeTest, GetmSecs) {
- //arrange
+ // arrange
TimevalStruct time;
time.tv_sec = 1;
time.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
- int64_t expect_value = time.tv_sec
- * date_time::DateTime::MILLISECONDS_IN_SECOND
- + time.tv_usec / date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
- //assert
+ int64_t expect_value =
+ time.tv_sec * date_time::DateTime::MILLISECONDS_IN_SECOND +
+ time.tv_usec / date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
+ // assert
ASSERT_EQ(expect_value, date_time::DateTime::getmSecs(time));
}
TEST(DateTimeTest, GetuSecs) {
- //arrange
+ // arrange
TimevalStruct time;
time.tv_sec = 3;
time.tv_usec = 4;
- int64_t expect_value = time.tv_sec
- * date_time::DateTime::MILLISECONDS_IN_SECOND
- * date_time::DateTime::MICROSECONDS_IN_MILLISECOND + time.tv_usec;
- //assert
+ int64_t expect_value = time.tv_sec *
+ date_time::DateTime::MILLISECONDS_IN_SECOND *
+ date_time::DateTime::MICROSECONDS_IN_MILLISECOND +
+ time.tv_usec;
+ // assert
ASSERT_EQ(expect_value, date_time::DateTime::getuSecs(time));
}
TEST(DateTimeTest, GetuSecsmSecs) {
- //arrange
+ // arrange
TimevalStruct time;
time.tv_sec = 5;
time.tv_usec = 6;
- int64_t expect_value = date_time::DateTime::getuSecs(time)
- / date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
+ int64_t expect_value = date_time::DateTime::getuSecs(time) /
+ date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
- //assert
+ // assert
ASSERT_EQ(expect_value, date_time::DateTime::getmSecs(time));
}
TEST(DateTimeTest, CalculateTimeSpan) {
- //arrange
+ // arrange
const TimevalStruct time = date_time::DateTime::getCurrentTime();
const uint32_t sleep_time_mSec = 10;
usleep(sleep_time_mSec * date_time::DateTime::MICROSECONDS_IN_MILLISECOND);
- //assert
+ // assert
ASSERT_GE(date_time::DateTime::calculateTimeSpan(time), sleep_time_mSec);
}
TEST(DateTimeTest, CalculateTimeDiff) {
-
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
@@ -127,26 +126,26 @@ TEST(DateTimeTest, CalculateTimeDiff) {
time2.tv_sec = 3;
time2.tv_usec = 4 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
- //time2 to time1
+ // time2 to time1
TimevalStruct diff1;
diff1.tv_sec = time2.tv_sec - time1.tv_sec;
diff1.tv_usec = time2.tv_usec - time1.tv_usec;
- const int64_t mSecDiff = static_cast<int64_t>(diff1.tv_sec) * 1000
- + diff1.tv_usec / 1000;
+ const int64_t mSecDiff =
+ static_cast<int64_t>(diff1.tv_sec) * 1000 + diff1.tv_usec / 1000;
- //assert
+ // assert
ASSERT_EQ(mSecDiff, date_time::DateTime::calculateTimeDiff(time2, time1));
- //time1 to time2
+ // time1 to time2
TimevalStruct diff2;
diff2.tv_sec = time1.tv_sec - time2.tv_sec;
diff2.tv_usec = time1.tv_usec - time2.tv_usec;
- const int64_t mSecDiff2 = -(static_cast<int64_t>(diff2.tv_sec) * 1000
- + diff2.tv_usec / 1000);
+ const int64_t mSecDiff2 =
+ -(static_cast<int64_t>(diff2.tv_sec) * 1000 + diff2.tv_usec / 1000);
- //assert
+ // assert
ASSERT_EQ(mSecDiff2, date_time::DateTime::calculateTimeDiff(time1, time2));
}
@@ -164,8 +163,7 @@ TEST(DateTimeTest, CalculateEqualTimeDiff) {
}
TEST(DateTimeTest, compareTime) {
-
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
@@ -174,30 +172,30 @@ TEST(DateTimeTest, compareTime) {
time2.tv_sec = 2;
time2.tv_usec = 4 * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
- //assert
+ // assert
ASSERT_EQ(LESS, date_time::DateTime::compareTime(time1, time2));
ASSERT_EQ(GREATER, date_time::DateTime::compareTime(time2, time1));
ASSERT_NE(EQUAL, date_time::DateTime::compareTime(time2, time1));
- //act
+ // act
TimevalStruct time3 = date_time::DateTime::Sub(time2, time1);
- //assert
+ // assert
ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time1, time3));
}
TEST(DateTimeTest, GetSecs_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 0;
time1.tv_usec = date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_EQ(1, date_time::DateTime::getSecs(time1));
}
TEST(DateTimeTest, compareTime_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 0;
@@ -206,14 +204,14 @@ TEST(DateTimeTest, compareTime_UsecConvertedInSec) {
time2.tv_sec = 0;
time2.tv_usec = date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_EQ(1, date_time::DateTime::getSecs(time1));
ASSERT_EQ(1, date_time::DateTime::getSecs(time2));
ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time1, time2));
}
TEST(DateTimeTest, compareEqualTime_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 0;
@@ -222,12 +220,12 @@ TEST(DateTimeTest, compareEqualTime_UsecConvertedInSec) {
time2.tv_sec = 0;
time2.tv_usec = date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_TRUE(date_time::DateTime::Equal(time1, time2));
}
TEST(DateTimeTest, compareLessTime_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 0;
@@ -236,12 +234,12 @@ TEST(DateTimeTest, compareLessTime_UsecConvertedInSec) {
time2.tv_sec = 0;
time2.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_TRUE(date_time::DateTime::Less(time1, time2));
}
TEST(DateTimeTest, compareGreaterTime_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 0;
@@ -250,12 +248,12 @@ TEST(DateTimeTest, compareGreaterTime_UsecConvertedInSec) {
time2.tv_sec = 0;
time2.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_TRUE(date_time::DateTime::Greater(time2, time1));
}
TEST(DateTimeTest, CalculateTimeSub_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 1;
time1.tv_usec = 0;
@@ -266,12 +264,12 @@ TEST(DateTimeTest, CalculateTimeSub_UsecConvertedInSec) {
TimevalStruct time3 = date_time::DateTime::Sub(time2, time1);
- //assert
+ // assert
ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time1, time3));
}
TEST(DateTimeTest, CalculateTimeDiff_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 2;
time1.tv_usec = 5 * date_time::DateTime::MICROSECONDS_IN_SECOND;
@@ -280,13 +278,13 @@ TEST(DateTimeTest, CalculateTimeDiff_UsecConvertedInSec) {
time2.tv_sec = 3;
time2.tv_usec = 1 * date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_EQ(3000, date_time::DateTime::calculateTimeDiff(time2, time1));
ASSERT_EQ(3000, date_time::DateTime::calculateTimeDiff(time1, time2));
}
TEST(DateTimeTest, CalculateEqualTimeDiff_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 2;
time1.tv_usec = 2 * date_time::DateTime::MICROSECONDS_IN_SECOND;
@@ -295,13 +293,13 @@ TEST(DateTimeTest, CalculateEqualTimeDiff_UsecConvertedInSec) {
time2.tv_sec = 3;
time2.tv_usec = 1 * date_time::DateTime::MICROSECONDS_IN_SECOND;
- //assert
+ // assert
ASSERT_EQ(0, date_time::DateTime::calculateTimeDiff(time2, time1));
ASSERT_EQ(0, date_time::DateTime::calculateTimeDiff(time1, time2));
}
TEST(DateTimeTest, CalculateEqualTimeSub_UsecConvertedInSec) {
- //arrange
+ // arrange
TimevalStruct time1;
time1.tv_sec = 3;
time1.tv_usec = 0;
@@ -316,12 +314,13 @@ TEST(DateTimeTest, CalculateEqualTimeSub_UsecConvertedInSec) {
TimevalStruct time_expected;
time_expected.tv_sec = 0;
time_expected.tv_usec = 0;
- //assert
+ // assert
ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time_expected, time3));
ASSERT_EQ(EQUAL, date_time::DateTime::compareTime(time_expected, time4));
}
-TEST(DateTimeTest, AddMilliseconds_SetMillisecondMultiplesSecond_ExpectChangeTime) {
+TEST(DateTimeTest,
+ AddMilliseconds_SetMillisecondMultiplesSecond_ExpectChangeTime) {
TimevalStruct time1;
time1.tv_sec = 3;
time1.tv_usec = 0;
@@ -331,7 +330,8 @@ TEST(DateTimeTest, AddMilliseconds_SetMillisecondMultiplesSecond_ExpectChangeTim
ASSERT_EQ(0, time1.tv_usec);
}
-TEST(DateTimeTest, AddMilliseconds_SetMillisecondNotMultiplesSecond_ExpectChangeTime) {
+TEST(DateTimeTest,
+ AddMilliseconds_SetMillisecondNotMultiplesSecond_ExpectChangeTime) {
TimevalStruct time1;
uint32_t milliseconds = 7500;
time1.tv_sec = 3;
@@ -341,7 +341,8 @@ TEST(DateTimeTest, AddMilliseconds_SetMillisecondNotMultiplesSecond_ExpectChange
ASSERT_EQ(500000, time1.tv_usec);
}
-TEST(DateTimeTest, AddMilliseconds_SetMilliSecondLessThenSeconds_ExpectChangeTime) {
+TEST(DateTimeTest,
+ AddMilliseconds_SetMilliSecondLessThenSeconds_ExpectChangeTime) {
TimevalStruct time1;
uint32_t milliseconds = 500;
time1.tv_sec = 3;
@@ -351,7 +352,8 @@ TEST(DateTimeTest, AddMilliseconds_SetMilliSecondLessThenSeconds_ExpectChangeTim
ASSERT_EQ(500000, time1.tv_usec);
}
-TEST(DateTimeTest, AddMilliseconds_SetMillisecondEqualNull_ExpectNotChangeTime) {
+TEST(DateTimeTest,
+ AddMilliseconds_SetMillisecondEqualNull_ExpectNotChangeTime) {
TimevalStruct time1;
uint32_t milliseconds = 0;
time1.tv_sec = 3;
@@ -371,32 +373,31 @@ TEST(DateTimeTest, AddMilliseconds_SetOverlowMicrosecond_ExpectChangeTime) {
ASSERT_EQ(100000, time1.tv_usec);
}
-TEST(DateTimeTest, Operator_minus_TimevalStruct_positive){
- TimevalStruct time1;
- TimevalStruct time2;
- TimevalStruct time3;
- time1.tv_sec = 3;
- time1.tv_usec = 0;
- time2.tv_sec = 3;
- time2.tv_usec = 0;
- time3.tv_sec = 2;
- time3.tv_usec = 9000000;
- ASSERT_EQ(0, date_time::DateTime::getSecs(time1 - time2));
- ASSERT_EQ(8000000, date_time::DateTime::getuSecs(time3 - time1));
+TEST(DateTimeTest, Operator_minus_TimevalStruct_positive) {
+ TimevalStruct time1;
+ TimevalStruct time2;
+ TimevalStruct time3;
+ time1.tv_sec = 3;
+ time1.tv_usec = 0;
+ time2.tv_sec = 3;
+ time2.tv_usec = 0;
+ time3.tv_sec = 2;
+ time3.tv_usec = 9000000;
+ ASSERT_EQ(0, date_time::DateTime::getSecs(time1 - time2));
+ ASSERT_EQ(8000000, date_time::DateTime::getuSecs(time3 - time1));
}
-TEST(DateTimeTest, Operator_minus_TimevalStruct_negative){
- TimevalStruct time1;
- TimevalStruct time2;
- time1.tv_sec = 3;
- time1.tv_usec = 0;
- time2.tv_sec = 2;
- time2.tv_usec = 9000000;
- ASSERT_NE(1, date_time::DateTime::getSecs(time1 - time2));
- ASSERT_NE(-8000000, date_time::DateTime::getSecs(time2 - time1));
+TEST(DateTimeTest, Operator_minus_TimevalStruct_negative) {
+ TimevalStruct time1;
+ TimevalStruct time2;
+ time1.tv_sec = 3;
+ time1.tv_usec = 0;
+ time2.tv_sec = 2;
+ time2.tv_usec = 9000000;
+ ASSERT_NE(1, date_time::DateTime::getSecs(time1 - time2));
+ ASSERT_NE(-8000000, date_time::DateTime::getSecs(time2 - time1));
}
-
} // namespace utils
} // namespace components
} // namespace test
diff --git a/src/components/utils/test/generated_code_with_sqlite_test.cc b/src/components/utils/test/generated_code_with_sqlite_test.cc
index d75d924321..cb319fa0ac 100644
--- a/src/components/utils/test/generated_code_with_sqlite_test.cc
+++ b/src/components/utils/test/generated_code_with_sqlite_test.cc
@@ -62,81 +62,83 @@ const std::string GeneratedCodeTest::kDatabaseName = "test_db";
const std::string GeneratedCodeTest::kEndpointsCreation =
"CREATE TABLE Endpoints ("
- "endpoint_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
- "service_id VARCHAR(45) NOT NULL,"
- "application_id VARCHAR(45),"
- "url VARCHAR(45) NOT NULL,"
- "is_default INTEGER NOT NULL CHECK(is_default>=0))";
+ "endpoint_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "service_id VARCHAR(45) NOT NULL,"
+ "application_id VARCHAR(45),"
+ "url VARCHAR(45) NOT NULL,"
+ "is_default INTEGER NOT NULL CHECK(is_default>=0))";
const std::string GeneratedCodeTest::kEndpointsContent =
"INSERT INTO Endpoints "
- "VALUES (1, '0x07', null, 'http://url.example.com', 1)";
+ "VALUES (1, '0x07', null, 'http://url.example.com', 1)";
const std::string GeneratedCodeTest::kAppPoliciesCreation =
"CREATE TABLE AppPolicies ("
- "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
- "application_id VARCHAR(45),"
- "priority VARCHAR(45),"
- "is_default INTEGER NOT NULL CHECK(is_default>=0))";
+ "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "application_id VARCHAR(45),"
+ "priority VARCHAR(45),"
+ "is_default INTEGER NOT NULL CHECK(is_default>=0))";
-const std::string GeneratedCodeTest::kGroupsCreation = "CREATE TABLE Groups ("
+const std::string GeneratedCodeTest::kGroupsCreation =
+ "CREATE TABLE Groups ("
"id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
"application_id VARCHAR(45) NOT NULL,"
"group_name VARCHAR(45) NOT NULL )";
-TEST_F(GeneratedCodeTest, FindSectionEndpoints_OpenDBSetDefaultUrl_ExpectDefaultUrl) {
-
- //arrange
+TEST_F(GeneratedCodeTest,
+ FindSectionEndpoints_OpenDBSetDefaultUrl_ExpectDefaultUrl) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
policy_table::ServiceEndpoints ep;
- //assert
+ // assert
EXPECT_TRUE(policy_table::FindSection(&db, ep));
EXPECT_EQ(1u, ep.size());
- //act
+ // act
std::string url = ep["0x07"]["default"].front();
- //assert
+ // assert
EXPECT_EQ("http://url.example.com", url);
}
-TEST_F(GeneratedCodeTest, RemoveSectionEndpoints_RemoveSectionEndpoints_Expect0EndPoints) {
- //arrange
+TEST_F(GeneratedCodeTest,
+ RemoveSectionEndpoints_RemoveSectionEndpoints_Expect0EndPoints) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
- //act
+ // act
policy_table::ServiceEndpoints ep;
- //assert
+ // assert
EXPECT_TRUE(policy_table::RemoveSection(&db, ep));
dbms::SQLQuery sqlquery(&db);
- //act
+ // act
std::string check_query = "select count (*) from endpoints";
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare(check_query));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(0, sqlquery.GetInteger(0));
}
-TEST_F(GeneratedCodeTest, UpdateSectionEndpoints_SetUrlPoint_ExpectPointEqualsUrl) {
-
- //arrange
+TEST_F(GeneratedCodeTest,
+ UpdateSectionEndpoints_SetUrlPoint_ExpectPointEqualsUrl) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
- //act
+ // act
std::string test_url = "http://url.example.com";
policy_table::URL urls;
@@ -148,52 +150,50 @@ TEST_F(GeneratedCodeTest, UpdateSectionEndpoints_SetUrlPoint_ExpectPointEqualsUr
policy_table::ServiceEndpoints ep;
ep["0x07"] = urllist;
- //assert
+ // assert
EXPECT_TRUE(policy_table::UpdateSection(&db, ep));
dbms::SQLQuery sqlquery(&db);
std::string num_of_records_check = "select count (*) from endpoints";
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare(num_of_records_check));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(1, sqlquery.GetInteger(0));
EXPECT_TRUE(sqlquery.Reset());
-
- //act
+ // act
std::string url_check_query = "select * from endpoints";
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare(url_check_query));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(test_url, sqlquery.GetString(3));
}
-TEST_F(GeneratedCodeTest, UpdateSectionAppPolicies_SetAppParams_ExpectDBHasThem) {
-
- //arrange
+TEST_F(GeneratedCodeTest,
+ UpdateSectionAppPolicies_SetAppParams_ExpectDBHasThem) {
+ // arrange
dbms::SQLDatabase db(GeneratedCodeTest::kDatabaseName);
- //assert
+ // assert
EXPECT_TRUE(db.Open());
- //act
+ // act
policy_table::ApplicationPolicies ap;
const std::string application_id = "12345678";
ap[application_id].groups.push_back("Base-4");
ap[application_id].priority = policy_table::P_NORMAL;
- //assert
+ // assert
EXPECT_TRUE(policy_table::UpdateSection(&db, ap));
- //act
+ // act
dbms::SQLQuery sqlquery(&db);
-
- //assert
+ // assert
EXPECT_TRUE(sqlquery.Prepare("select count (*) from AppPolicies"));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
@@ -206,9 +206,8 @@ TEST_F(GeneratedCodeTest, UpdateSectionAppPolicies_SetAppParams_ExpectDBHasThem)
EXPECT_EQ(1, sqlquery.GetInteger(0));
EXPECT_TRUE(sqlquery.Reset());
- EXPECT_TRUE(
- sqlquery.Prepare(
- "select application_id from Groups where group_name='Base-4'"));
+ EXPECT_TRUE(sqlquery.Prepare(
+ "select application_id from Groups where group_name='Base-4'"));
EXPECT_TRUE(sqlquery.Exec());
// Index for binding starts from 1, index for results starts from 0
EXPECT_EQ(application_id, sqlquery.GetString(0));
diff --git a/src/components/utils/test/include/generated_code_with_sqlite_test.h b/src/components/utils/test/include/generated_code_with_sqlite_test.h
index 4ce14be649..1abeb5f6b6 100644
--- a/src/components/utils/test/include/generated_code_with_sqlite_test.h
+++ b/src/components/utils/test/include/generated_code_with_sqlite_test.h
@@ -51,7 +51,8 @@ bool FindSection(dbms::SQLDatabase* db, policy_table::ServiceEndpoints& ep) {
* table Endpoints
* index, service_type, application_id, url, is_default
*
- * If url belongs to default section, application_id should be null and is_defaut = true
+ * If url belongs to default section, application_id should be null and
+ *is_defaut = true
* Otherwise application_id should be set and is_default = false
*/
@@ -101,7 +102,7 @@ bool RemoveSection(dbms::SQLDatabase* db,
// bool is_nicknames_removed = sqlquery.Exec("delete from Nicknames");
bool is_groups_removed = sqlquery.Exec("delete from Groups");
- return is_policies_removed /*&& is_nicknames_removed*/&& is_groups_removed;
+ return is_policies_removed /*&& is_nicknames_removed*/ && is_groups_removed;
}
bool RemoveSection(dbms::SQLDatabase* db,
@@ -135,7 +136,8 @@ bool UpdateSection(dbms::SQLDatabase* db,
* table Endpoints
* index, service_type, application_id, url, is_default
*
- * If url belongs to default section, application_id should be null and is_defaut = true
+ * If url belongs to default section, application_id should be null and
+ *is_defaut = true
* Otherwise application_id should be set and is_default = false
*/
@@ -225,7 +227,8 @@ bool UpdateSection(dbms::SQLDatabase* db,
return false;
}
- std::string query = "insert into FunctionalGroups values("
+ std::string query =
+ "insert into FunctionalGroups values("
"?,"
"(select index from Groups where group_name=?),"
"(select index from Rpcs where rpc=?),"
@@ -245,10 +248,10 @@ bool UpdateSection(dbms::SQLDatabase* db,
for (; it_rpcs != it_rpcs_end; ++it_rpcs) {
policy_table::RpcParameters rpc_params = (*it_rpcs).second;
- policy_table::HmiLevels::const_iterator it_hmi_levels = rpc_params
- .hmi_levels.begin();
- policy_table::HmiLevels::const_iterator it_hmi_levels_end = rpc_params
- .hmi_levels.end();
+ policy_table::HmiLevels::const_iterator it_hmi_levels =
+ rpc_params.hmi_levels.begin();
+ policy_table::HmiLevels::const_iterator it_hmi_levels_end =
+ rpc_params.hmi_levels.end();
for (; it_hmi_levels != it_hmi_levels_end; ++it_hmi_levels) {
// Index binding
@@ -302,7 +305,8 @@ bool UpdateSection(dbms::SQLDatabase* db,
return false;
}
- std::string groups_query = "insert into Groups values ("
+ std::string groups_query =
+ "insert into Groups values ("
"?,"
"?,"
"?)";
@@ -334,7 +338,8 @@ bool UpdateSection(dbms::SQLDatabase* db,
app_policies_sqlquery.Bind(3, false);
}
- // Struct contains groups, nicknames, priority for application/default section
+ // Struct contains groups, nicknames, priority for application/default
+ // section
policy_table::ApplicationParams app_params = (*it_ap).second;
// Priority binding
@@ -354,10 +359,13 @@ bool UpdateSection(dbms::SQLDatabase* db,
// begin/end methods in its interface
// To be discussed with I.Kozyrenko
- // policy_table::StringArray::const_iterator it_nicknames = app_params.nicknames.begin();
- // policy_table::StringArray::const_iterator it_nicknames_end = app_params.nicknames.end();
+ // policy_table::StringArray::const_iterator it_nicknames =
+ // app_params.nicknames.begin();
+ // policy_table::StringArray::const_iterator it_nicknames_end =
+ // app_params.nicknames.end();
//
- // for (int nick_index = 0;it_nicknames != it_nicknames_end; ++ it_nicknames, ++nick_index) {
+ // for (int nick_index = 0;it_nicknames != it_nicknames_end; ++
+ // it_nicknames, ++nick_index) {
// nicknames_sqlquery.Bind(0, nick_index);
// nicknames_sqlquery.Bind(1, app_policy_name);
//
@@ -372,11 +380,11 @@ bool UpdateSection(dbms::SQLDatabase* db,
policy_table::Strings::const_iterator it_groups =
app_params.groups.begin();
- policy_table::Strings::const_iterator it_groups_end = app_params.groups
- .end();
+ policy_table::Strings::const_iterator it_groups_end =
+ app_params.groups.end();
for (int group_index = 0; it_groups != it_groups_end;
- ++it_groups, ++group_index) {
+ ++it_groups, ++group_index) {
groups_sqlquery.Bind(0, group_index);
groups_sqlquery.Bind(1, app_policy_name);
groups_sqlquery.Bind(2, (*it_groups));
diff --git a/src/components/utils/test/log_message_loop_thread_test.cc b/src/components/utils/test/log_message_loop_thread_test.cc
index d457325d4d..14515961bb 100644
--- a/src/components/utils/test/log_message_loop_thread_test.cc
+++ b/src/components/utils/test/log_message_loop_thread_test.cc
@@ -45,13 +45,13 @@ using ::testing::_;
TEST(LogMessageLoopThread, DestroyLogMessage_loggerStatusDeletingLogger) {
logger::logger_status = CreatingLoggerThread;
LogMessageLoopThread* loop_thread = new LogMessageLoopThread();
- //assert
+ // assert
EXPECT_EQ(CreatingLoggerThread, logger::logger_status);
- //act
+ // act
delete loop_thread;
- //assert
+ // assert
EXPECT_EQ(DeletingLoggerThread, logger::logger_status);
logger::logger_status = LoggerThreadNotCreated;
@@ -66,7 +66,7 @@ TEST(LogMessageLoopThread, HandleNeverCalled) {
logger::logger_status = CreatingLoggerThread;
MockLogMessageTest mmock;
- EXPECT_CALL(mmock,Handle(_)).Times(0);
+ EXPECT_CALL(mmock, Handle(_)).Times(0);
LogMessageLoopThread* loop_thread = new LogMessageLoopThread();
delete loop_thread;
diff --git a/src/components/utils/test/message_queue_test.cc b/src/components/utils/test/message_queue_test.cc
index 8ce7196b07..d80016c6a8 100644
--- a/src/components/utils/test/message_queue_test.cc
+++ b/src/components/utils/test/message_queue_test.cc
@@ -43,21 +43,20 @@ using ::utils::MessageQueue;
class MessageQueueTest : public testing::Test {
public:
MessageQueueTest()
- : test_val_1("Hello,"),
- test_val_2("Beautiful "),
- test_val_3("World!"),
- test_line(""),
- check_value(false) {
- }
+ : test_val_1("Hello,")
+ , test_val_2("Beautiful ")
+ , test_val_3("World!")
+ , test_line("")
+ , check_value(false) {}
void add_one_element_to_queue();
void extract_from_queue();
void add_three_elements_to_queue();
void ShutDownQueue();
- static void* add_one_element_to_queue_helper(void *context);
- static void* extract_from_queue_helper(void *context);
- static void* add_three_elements_to_queue_helper(void *context);
- static void* ShutDownQueue_helper(void *context);
+ static void* add_one_element_to_queue_helper(void* context);
+ static void* extract_from_queue_helper(void* context);
+ static void* add_three_elements_to_queue_helper(void* context);
+ static void* ShutDownQueue_helper(void* context);
protected:
MessageQueue<std::string> test_queue;
@@ -96,20 +95,20 @@ void MessageQueueTest::ShutDownQueue() {
pthread_exit(NULL);
}
-void* MessageQueueTest::add_one_element_to_queue_helper(void *context) {
- (reinterpret_cast<MessageQueueTest *>(context))->add_one_element_to_queue();
+void* MessageQueueTest::add_one_element_to_queue_helper(void* context) {
+ (reinterpret_cast<MessageQueueTest*>(context))->add_one_element_to_queue();
return NULL;
}
-void* MessageQueueTest::extract_from_queue_helper(void *context) {
- (reinterpret_cast<MessageQueueTest *>(context))->extract_from_queue();
+void* MessageQueueTest::extract_from_queue_helper(void* context) {
+ (reinterpret_cast<MessageQueueTest*>(context))->extract_from_queue();
return NULL;
}
-void* MessageQueueTest::add_three_elements_to_queue_helper(void *context) {
- (reinterpret_cast<MessageQueueTest *>(context))->add_three_elements_to_queue();
+void* MessageQueueTest::add_three_elements_to_queue_helper(void* context) {
+ (reinterpret_cast<MessageQueueTest*>(context))->add_three_elements_to_queue();
return NULL;
}
-void* MessageQueueTest::ShutDownQueue_helper(void *context) {
- (reinterpret_cast<MessageQueueTest *>(context))->ShutDownQueue();
+void* MessageQueueTest::ShutDownQueue_helper(void* context) {
+ (reinterpret_cast<MessageQueueTest*>(context))->ShutDownQueue();
return NULL;
}
@@ -119,9 +118,13 @@ TEST_F(MessageQueueTest, DefaultCtorTest_ExpectEmptyQueueCreated) {
ASSERT_EQ(test_value, test_queue.empty());
}
-TEST_F(MessageQueueTest, MessageQueuePushThreeElementsTest_ExpectThreeElementsAdded) {
+TEST_F(MessageQueueTest,
+ MessageQueuePushThreeElementsTest_ExpectThreeElementsAdded) {
pthread_t thread1;
- pthread_create(&thread1, NULL, &MessageQueueTest::add_three_elements_to_queue_helper, this);
+ pthread_create(&thread1,
+ NULL,
+ &MessageQueueTest::add_three_elements_to_queue_helper,
+ this);
pthread_join(thread1, NULL);
// check if 3 elements were added successfully
ASSERT_EQ(3u, test_queue.size());
@@ -140,12 +143,15 @@ TEST_F(MessageQueueTest, NotEmptyMessageQueueResetTest_ExpectEmptyQueue) {
ASSERT_EQ(0u, test_queue.size());
}
-TEST_F(MessageQueueTest, MessageQueuePopOneElementTest_ExpectOneElementRemovedFromQueue) {
+TEST_F(MessageQueueTest,
+ MessageQueuePopOneElementTest_ExpectOneElementRemovedFromQueue) {
pthread_t thread1;
pthread_t thread2;
// Creating threads with thread function mentioned above
- pthread_create(&thread1, NULL, &MessageQueueTest::add_one_element_to_queue_helper, this);
- pthread_create(&thread2, NULL, &MessageQueueTest::extract_from_queue_helper, this);
+ pthread_create(
+ &thread1, NULL, &MessageQueueTest::add_one_element_to_queue_helper, this);
+ pthread_create(
+ &thread2, NULL, &MessageQueueTest::extract_from_queue_helper, this);
// Primary thread waits until thread 2 to be finished
pthread_join(thread2, NULL);
// Check if first element was removed successfully
@@ -154,7 +160,8 @@ TEST_F(MessageQueueTest, MessageQueuePopOneElementTest_ExpectOneElementRemovedFr
ASSERT_EQ(0u, test_queue.size());
}
-TEST_F(MessageQueueTest, MessageQueueShutdownTest_ExpectMessageQueueWillBeShutDown) {
+TEST_F(MessageQueueTest,
+ MessageQueueShutdownTest_ExpectMessageQueueWillBeShutDown) {
pthread_t thread1;
// Creating thread with thread function mentioned above
pthread_create(&thread1, NULL, &MessageQueueTest::ShutDownQueue_helper, this);
diff --git a/src/components/utils/test/messagemeter_test.cc b/src/components/utils/test/messagemeter_test.cc
index 0db947e564..69db658542 100644
--- a/src/components/utils/test/messagemeter_test.cc
+++ b/src/components/utils/test/messagemeter_test.cc
@@ -40,21 +40,21 @@
#include "utils/messagemeter.h"
#include "utils/date_time.h"
-namespace test {
-namespace components {
-namespace utils {
+namespace test {
+namespace components {
+namespace utils {
// Pair of values <second, msecond>
typedef std::pair<int, int> TimePair;
-const TimePair testing_time_pairs[] = { TimePair(0, 50),
- TimePair(0, 100),
- TimePair(0, 200),
- TimePair(0, 500),
- TimePair(0, 900),
- TimePair(1, 0),
- TimePair(1, 500) };
-
-class MessageMeterTest: public ::testing::TestWithParam<TimePair> {
+const TimePair testing_time_pairs[] = {TimePair(0, 50),
+ TimePair(0, 100),
+ TimePair(0, 200),
+ TimePair(0, 500),
+ TimePair(0, 900),
+ TimePair(1, 0),
+ TimePair(1, 500)};
+
+class MessageMeterTest : public ::testing::TestWithParam<TimePair> {
protected:
void SetUp() OVERRIDE {
usecs = date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
@@ -63,20 +63,17 @@ class MessageMeterTest: public ::testing::TestWithParam<TimePair> {
id3 = 0xFEBCDA;
const TimePair time_pair = GetParam();
- EXPECT_GT(usecs,
- time_pair.second) << "Wrong time (msecs) value";
+ EXPECT_GT(usecs, time_pair.second) << "Wrong time (msecs) value";
time_range.tv_sec = time_pair.first;
time_range.tv_usec = time_pair.second * usecs;
- EXPECT_LT(0,
- date_time::DateTime::getuSecs(time_range))
+ EXPECT_LT(0, date_time::DateTime::getuSecs(time_range))
<< "Wrong test case with null range value";
meter.set_time_range(time_range);
time_range_msecs = date_time::DateTime::getmSecs(time_range);
}
- void TearDown() OVERRIDE {
- }
+ void TearDown() OVERRIDE {}
::utils::MessageMeter<int> meter;
TimevalStruct time_range = {0, 0};
int64_t time_range_msecs;
@@ -86,29 +83,28 @@ class MessageMeterTest: public ::testing::TestWithParam<TimePair> {
TEST(MessageMeterTest, DefaultTimeRange) {
const ::utils::MessageMeter<int> default_meter;
- const TimevalStruct time_second {1, 0};
+ const TimevalStruct time_second{1, 0};
EXPECT_EQ(time_second, default_meter.time_range());
}
TEST(MessageMeterTest, TimeRangeSetter) {
::utils::MessageMeter<int> meter;
- TimevalStruct time_range {0, 0};
+ TimevalStruct time_range{0, 0};
const int test_count_secs = 1000;
// Skip 1000th msec value as wrong for TimevalStruct
const int test_count_msecs = 999;
for (int sec = test_count_secs; sec >= 0; --sec) {
for (int msec = test_count_msecs; msec >= 0; --msec) {
time_range.tv_sec = sec;
- time_range.tv_usec = msec * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
+ time_range.tv_usec =
+ msec * date_time::DateTime::MICROSECONDS_IN_MILLISECOND;
// Setter TimevalStruct
meter.set_time_range(time_range);
- EXPECT_EQ(time_range,
- meter.time_range()) << sec << "." << msec << " sec";
+ EXPECT_EQ(time_range, meter.time_range()) << sec << "." << msec << " sec";
// Setter mSecs
meter.set_time_range(sec * date_time::DateTime::MILLISECONDS_IN_SECOND +
msec);
- EXPECT_EQ(time_range,
- meter.time_range()) << sec << "." << msec << " sec";
+ EXPECT_EQ(time_range, meter.time_range()) << sec << "." << msec << " sec";
}
}
}
@@ -117,20 +113,16 @@ TEST(MessageMeterTest, AddingWithNullTimeRange) {
::utils::MessageMeter<int> meter;
const int id1 = 1;
const int id2 = 2;
- const TimevalStruct null_time_range {0, 0};
+ const TimevalStruct null_time_range{0, 0};
meter.set_time_range(null_time_range);
for (int i = 0; i < 10000; ++i) {
// 1st Connection
- EXPECT_EQ(0u,
- meter.TrackMessage(id1));
- EXPECT_EQ(0u,
- meter.Frequency(id1));
+ EXPECT_EQ(0u, meter.TrackMessage(id1));
+ EXPECT_EQ(0u, meter.Frequency(id1));
// 2d Connection
- EXPECT_EQ(0u,
- meter.TrackMessage(id2));
- EXPECT_EQ(0u,
- meter.Frequency(id2));
+ EXPECT_EQ(0u, meter.TrackMessage(id2));
+ EXPECT_EQ(0u, meter.Frequency(id2));
}
}
@@ -139,8 +131,8 @@ TEST_P(MessageMeterTest, TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
// Add messages for less range period
int64_t time_span;
- while ((time_span = date_time::DateTime::calculateTimeSpan(start_time))
- < time_range_msecs) {
+ while ((time_span = date_time::DateTime::calculateTimeSpan(start_time)) <
+ time_range_msecs) {
++messages;
size_t tracked_frequency = meter.TrackMessage(id1);
@@ -158,13 +150,13 @@ TEST_P(MessageMeterTest, TrackMessage_AddingOverPeriod_CorrectCountOfMessages) {
}
TEST_P(MessageMeterTest,
- TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) {
+ TrackMessage_AddingOverPeriodMultiIds_CorrectCountOfMessages) {
size_t messages = 0;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
// Add messages for less range period
int64_t time_span;
- while ((time_span = date_time::DateTime::calculateTimeSpan(start_time))
- < time_range_msecs) {
+ while ((time_span = date_time::DateTime::calculateTimeSpan(start_time)) <
+ time_range_msecs) {
++messages;
size_t tracked_frequency_id1 = meter.TrackMessage(id1);
@@ -181,9 +173,8 @@ TEST_P(MessageMeterTest,
EXPECT_GE(messages, tracked_frequency_id3)
<< "Tracked messages can`t be over cycles.";
- if (messages > frequency_id1 ||
- messages > frequency_id2 ||
- messages > frequency_id3) {
+ if (messages > frequency_id1 || messages > frequency_id2 ||
+ messages > frequency_id3) {
EXPECT_GE(time_range_msecs, time_span);
break;
}
@@ -196,22 +187,19 @@ TEST_P(MessageMeterTest,
TEST_P(MessageMeterTest, Frequency_CountingOverPeriod_CorrectCountOfMessages) {
const size_t one_message = 1;
const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
- EXPECT_EQ(one_message,
- meter.TrackMessage(id1));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id2));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id3));
+ EXPECT_EQ(one_message, meter.TrackMessage(id1));
+ EXPECT_EQ(one_message, meter.TrackMessage(id2));
+ EXPECT_EQ(one_message, meter.TrackMessage(id3));
// Check messages count over period
int64_t time_span;
- while ((time_span = date_time::DateTime::calculateTimeSpan(start_time))
- < time_range_msecs) {
+ while ((time_span = date_time::DateTime::calculateTimeSpan(start_time)) <
+ time_range_msecs) {
usleep(time_range_msecs);
if (one_message != meter.Frequency(id1) ||
- one_message != meter.Frequency(id2) ||
- one_message != meter.Frequency(id3)) {
+ one_message != meter.Frequency(id2) ||
+ one_message != meter.Frequency(id3)) {
EXPECT_GE(time_range_msecs, time_span);
break;
}
@@ -220,77 +208,53 @@ TEST_P(MessageMeterTest, Frequency_CountingOverPeriod_CorrectCountOfMessages) {
TEST_P(MessageMeterTest, CountingOutOfPeriod) {
const size_t one_message = 1;
- EXPECT_EQ(one_message,
- meter.TrackMessage(id1));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id2));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id3));
+ EXPECT_EQ(one_message, meter.TrackMessage(id1));
+ EXPECT_EQ(one_message, meter.TrackMessage(id2));
+ EXPECT_EQ(one_message, meter.TrackMessage(id3));
// sleep more than time range
usleep(time_range_msecs * usecs * 1.1);
- EXPECT_EQ(0u,
- meter.Frequency(id1));
- EXPECT_EQ(0u,
- meter.Frequency(id2));
- EXPECT_EQ(0u,
- meter.Frequency(id3));
+ EXPECT_EQ(0u, meter.Frequency(id1));
+ EXPECT_EQ(0u, meter.Frequency(id2));
+ EXPECT_EQ(0u, meter.Frequency(id3));
}
TEST_P(MessageMeterTest, ClearId) {
const size_t one_message = 1;
- EXPECT_EQ(one_message,
- meter.TrackMessage(id1));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id2));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id3));
+ EXPECT_EQ(one_message, meter.TrackMessage(id1));
+ EXPECT_EQ(one_message, meter.TrackMessage(id2));
+ EXPECT_EQ(one_message, meter.TrackMessage(id3));
meter.RemoveIdentifier(id1);
- EXPECT_EQ(0u,
- meter.Frequency(id1));
- EXPECT_EQ(one_message,
- meter.Frequency(id2));
- EXPECT_EQ(one_message,
- meter.Frequency(id3));
+ EXPECT_EQ(0u, meter.Frequency(id1));
+ EXPECT_EQ(one_message, meter.Frequency(id2));
+ EXPECT_EQ(one_message, meter.Frequency(id3));
meter.RemoveIdentifier(id2);
- EXPECT_EQ(0u,
- meter.Frequency(id1));
- EXPECT_EQ(0u,
- meter.Frequency(id2));
- EXPECT_EQ(one_message,
- meter.Frequency(id3));
+ EXPECT_EQ(0u, meter.Frequency(id1));
+ EXPECT_EQ(0u, meter.Frequency(id2));
+ EXPECT_EQ(one_message, meter.Frequency(id3));
meter.RemoveIdentifier(id3);
- EXPECT_EQ(0u,
- meter.Frequency(id1));
- EXPECT_EQ(0u,
- meter.Frequency(id2));
- EXPECT_EQ(0u,
- meter.Frequency(id3));
+ EXPECT_EQ(0u, meter.Frequency(id1));
+ EXPECT_EQ(0u, meter.Frequency(id2));
+ EXPECT_EQ(0u, meter.Frequency(id3));
}
TEST_P(MessageMeterTest, ClearIds) {
const size_t one_message = 1;
- EXPECT_EQ(one_message,
- meter.TrackMessage(id1));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id2));
- EXPECT_EQ(one_message,
- meter.TrackMessage(id3));
+ EXPECT_EQ(one_message, meter.TrackMessage(id1));
+ EXPECT_EQ(one_message, meter.TrackMessage(id2));
+ EXPECT_EQ(one_message, meter.TrackMessage(id3));
meter.ClearIdentifiers();
- EXPECT_EQ(0u,
- meter.Frequency(id2));
- EXPECT_EQ(0u,
- meter.Frequency(id2));
- EXPECT_EQ(0u,
- meter.Frequency(id3));
+ EXPECT_EQ(0u, meter.Frequency(id2));
+ EXPECT_EQ(0u, meter.Frequency(id2));
+ EXPECT_EQ(0u, meter.Frequency(id3));
}
INSTANTIATE_TEST_CASE_P(MessageMeterTestCase,
diff --git a/src/components/utils/test/posix_thread_test.cc b/src/components/utils/test/posix_thread_test.cc
index d597f036d0..f98794d08a 100644
--- a/src/components/utils/test/posix_thread_test.cc
+++ b/src/components/utils/test/posix_thread_test.cc
@@ -41,13 +41,14 @@ namespace utils {
using namespace sync_primitives;
using namespace threads;
-// TODO(AByzhynar): Change this to use Gtest class to create all variables for every TEST_F
+// TODO(AByzhynar): Change this to use Gtest class to create all variables for
+// every TEST_F
// TODO(AByzhynar): Add multithreading tests
namespace {
const uint32_t MAX_SIZE = 20;
const size_t MyStackSize = 32768;
-const char *threadName("test thread");
+const char* threadName("test thread");
const std::string test_thread_name("THREAD");
sync_primitives::ConditionalVariable cond_var_;
sync_primitives::Lock test_mutex_;
@@ -56,9 +57,7 @@ sync_primitives::Lock test_mutex_;
// ThreadDelegate successor
class TestThreadDelegate : public threads::ThreadDelegate {
public:
- TestThreadDelegate()
- : check_value_(false) {
- }
+ TestThreadDelegate() : check_value_(false) {}
void threadMain() {
AutoLock test_lock(test_mutex_);
check_value_ = true;
@@ -68,14 +67,15 @@ class TestThreadDelegate : public threads::ThreadDelegate {
bool check_value() const {
return check_value_;
}
+
private:
bool check_value_;
};
TEST(PosixThreadTest, CreateThread_ExpectThreadCreated) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
EXPECT_TRUE(thread != NULL);
@@ -89,8 +89,8 @@ TEST(PosixThreadTest, CreateThread_ExpectThreadCreated) {
TEST(PosixThreadTest, CheckCreatedThreadName_ExpectCorrectName) {
// Arrange
- threads::Thread *thread = NULL;
- threads::ThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ threads::ThreadDelegate* threadDelegate = new TestThreadDelegate();
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
// Check thread was created with correct name
@@ -100,10 +100,11 @@ TEST(PosixThreadTest, CheckCreatedThreadName_ExpectCorrectName) {
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, CheckCreatedThreadNameChangeToLongName_ExpectThreadNameReduced) {
+TEST(PosixThreadTest,
+ CheckCreatedThreadNameChangeToLongName_ExpectThreadNameReduced) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
@@ -124,14 +125,17 @@ TEST(PosixThreadTest, CheckCreatedThreadNameChangeToLongName_ExpectThreadNameRed
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, StartCreatedThreadWithOptionsJoinableAndMyStackSize_ExpectMyStackSizeStackAndJoinableThreadStarted) {
+TEST(
+ PosixThreadTest,
+ StartCreatedThreadWithOptionsJoinableAndMyStackSize_ExpectMyStackSizeStackAndJoinableThreadStarted) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
- // Start thread with following options (Stack size = 32768 & thread is joinable)
+ // Start thread with following options (Stack size = 32768 & thread is
+ // joinable)
thread->start(threads::ThreadOptions(MyStackSize));
// Check thread is joinable
EXPECT_TRUE(thread->is_joinable());
@@ -144,10 +148,12 @@ TEST(PosixThreadTest, StartCreatedThreadWithOptionsJoinableAndMyStackSize_Expect
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, StartCreatedThreadWithDefaultOptions_ExpectZeroStackAndJoinableThreadStarted) {
+TEST(
+ PosixThreadTest,
+ StartCreatedThreadWithDefaultOptions_ExpectZeroStackAndJoinableThreadStarted) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
@@ -164,10 +170,12 @@ TEST(PosixThreadTest, StartCreatedThreadWithDefaultOptions_ExpectZeroStackAndJoi
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, StartThreadWithZeroStackAndDetached_ExpectMinimumStackAndDetachedThreadStarted) {
+TEST(
+ PosixThreadTest,
+ StartThreadWithZeroStackAndDetached_ExpectMinimumStackAndDetachedThreadStarted) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
@@ -184,10 +192,12 @@ TEST(PosixThreadTest, StartThreadWithZeroStackAndDetached_ExpectMinimumStackAndD
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, DISABLED_CheckCreatedThreadNameChangeToEmpty_ExpectThreadNameChangedToEmpty) {
+TEST(
+ PosixThreadTest,
+ DISABLED_CheckCreatedThreadNameChangeToEmpty_ExpectThreadNameChangedToEmpty) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
@@ -208,10 +218,11 @@ TEST(PosixThreadTest, DISABLED_CheckCreatedThreadNameChangeToEmpty_ExpectThreadN
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, CheckCreatedThreadNameChangeToShortName_ExpectThreadNameChangedToShort) {
+TEST(PosixThreadTest,
+ CheckCreatedThreadNameChangeToShortName_ExpectThreadNameChangedToShort) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
@@ -235,13 +246,14 @@ TEST(PosixThreadTest, CheckCreatedThreadNameChangeToShortName_ExpectThreadNameCh
TEST(PosixThreadTest, StartThread_ExpectThreadStarted) {
// Arrange
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
// Start created thread
- EXPECT_TRUE(thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
+ EXPECT_TRUE(
+ thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
cond_var_.WaitFor(test_lock, 10000);
EXPECT_TRUE(threadDelegate->check_value());
DeleteThread(thread);
@@ -253,17 +265,19 @@ TEST(PosixThreadTest, StartOneThreadTwice_ExpectTheSameThreadStartedTwice) {
// Arrange
PlatformThreadHandle thread1_id;
PlatformThreadHandle thread2_id;
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
// Start created thread
- EXPECT_TRUE(thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
+ EXPECT_TRUE(
+ thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
thread1_id = thread->CurrentId();
thread->stop();
// Try to start thread again
- EXPECT_TRUE(thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
+ EXPECT_TRUE(
+ thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
thread2_id = thread->CurrentId();
EXPECT_EQ(thread1_id, thread2_id);
cond_var_.WaitFor(test_lock, 10000);
@@ -273,17 +287,19 @@ TEST(PosixThreadTest, StartOneThreadTwice_ExpectTheSameThreadStartedTwice) {
EXPECT_EQ(NULL, thread->delegate());
}
-TEST(PosixThreadTest, StartOneThreadAgainAfterRename_ExpectRenamedThreadStarted) {
+TEST(PosixThreadTest,
+ StartOneThreadAgainAfterRename_ExpectRenamedThreadStarted) {
// Arrange
PlatformThreadHandle thread1_id;
PlatformThreadHandle thread2_id;
- threads::Thread *thread = NULL;
- TestThreadDelegate *threadDelegate = new TestThreadDelegate();
+ threads::Thread* thread = NULL;
+ TestThreadDelegate* threadDelegate = new TestThreadDelegate();
AutoLock test_lock(test_mutex_);
// Create thread
ASSERT_NO_THROW(thread = CreateThread(threadName, threadDelegate));
// Start created thread
- EXPECT_TRUE(thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
+ EXPECT_TRUE(
+ thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
thread1_id = thread->CurrentId();
// Rename started thread. Name will be cut to 15 symbols + '\0'
// This is the limit in current POSIX thread implementation
@@ -295,7 +311,8 @@ TEST(PosixThreadTest, StartOneThreadAgainAfterRename_ExpectRenamedThreadStarted)
EXPECT_EQ(test_thread_name, std::string(name));
// Stop thread
thread->stop();
- EXPECT_TRUE(thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
+ EXPECT_TRUE(
+ thread->start(threads::ThreadOptions(threads::Thread::kMinStackSize)));
thread2_id = thread->CurrentId();
// Expect the same thread started with the the same name
EXPECT_EQ(test_thread_name, std::string(name));
diff --git a/src/components/utils/test/prioritized_queue_test.cc b/src/components/utils/test/prioritized_queue_test.cc
index 19e168cdce..ef105f6c4e 100644
--- a/src/components/utils/test/prioritized_queue_test.cc
+++ b/src/components/utils/test/prioritized_queue_test.cc
@@ -41,16 +41,13 @@ using ::utils::PrioritizedQueue;
class TestMessage {
public:
- TestMessage()
- : priority(0) {
- }
+ TestMessage() : priority(0) {}
TestMessage(std::string message, size_t msg_priority)
- : msg_(message),
- priority(msg_priority) {
- }
+ : msg_(message), priority(msg_priority) {}
size_t PriorityOrder() const;
std::string msg() const;
- friend bool operator==(const TestMessage &msg1, const TestMessage &msg2);
+ friend bool operator==(const TestMessage& msg1, const TestMessage& msg2);
+
private:
std::string msg_;
size_t priority;
@@ -64,9 +61,9 @@ std::string TestMessage::msg() const {
return msg_;
}
-bool operator==(const TestMessage &msg1, const TestMessage &msg2) {
- return (msg1.msg() == msg2.msg()
- && msg1.PriorityOrder() == msg2.PriorityOrder());
+bool operator==(const TestMessage& msg1, const TestMessage& msg2) {
+ return (msg1.msg() == msg2.msg() &&
+ msg1.PriorityOrder() == msg2.PriorityOrder());
}
class PrioritizedQueueTest : public testing::Test {
@@ -108,13 +105,15 @@ TEST_F(PrioritizedQueueTest, AddFourElementsTest_ExpectQueueNotEmpty) {
EXPECT_FALSE(test_queue.empty());
}
-TEST_F(PrioritizedQueueTest, CheckMessageOrder_ExpectMessageWithHighestPriorityAddedFirst) {
+TEST_F(PrioritizedQueueTest,
+ CheckMessageOrder_ExpectMessageWithHighestPriorityAddedFirst) {
// Creating 4 messages with different priorities
TestMessage message1("Ford", 111);
TestMessage message2("Hello", 21);
TestMessage message3("Luxoft", 14);
TestMessage message4("from", 4);
- // Adding created messages to Prioritized queue. Expect queue ordered according priority
+ // Adding created messages to Prioritized queue. Expect queue ordered
+ // according priority
test_queue.push(message4);
test_queue.push(message3);
test_queue.push(message1);
@@ -123,7 +122,8 @@ TEST_F(PrioritizedQueueTest, CheckMessageOrder_ExpectMessageWithHighestPriorityA
EXPECT_EQ(message1, test_queue.front());
}
-TEST_F(PrioritizedQueueTest, Push_AddMessagesWithEqualPriority_ExpectMessagesWithEqualPriorityAdded) {
+TEST_F(PrioritizedQueueTest,
+ Push_AddMessagesWithEqualPriority_ExpectMessagesWithEqualPriorityAdded) {
// Creating 2 messages with the same priorities
TestMessage message1("Hello", 111);
TestMessage message2("Luxoft", 111);
@@ -134,14 +134,17 @@ TEST_F(PrioritizedQueueTest, Push_AddMessagesWithEqualPriority_ExpectMessagesWit
EXPECT_EQ(2u, test_queue.size());
}
-TEST_F(PrioritizedQueueTest, Pop_OneElementInPriorityQueue_ExpectQueueStillAliveWithRestMessagesWithEqualPriority) {
+TEST_F(
+ PrioritizedQueueTest,
+ Pop_OneElementInPriorityQueue_ExpectQueueStillAliveWithRestMessagesWithEqualPriority) {
// Creating 4 messages with same priorities
TestMessage message1("Ford's", 111);
TestMessage message2("Partner", 111);
// Adding created messages to Prioritized queue.
test_queue.push(message1);
test_queue.push(message2);
- // Expect 2 messages were added successfully to One element of prioritized queue
+ // Expect 2 messages were added successfully to One element of prioritized
+ // queue
EXPECT_EQ(2u, test_queue.size());
// Extracting first element from the queue
EXPECT_EQ(message1, test_queue.front());
@@ -153,7 +156,9 @@ TEST_F(PrioritizedQueueTest, Pop_OneElementInPriorityQueue_ExpectQueueStillAlive
EXPECT_EQ(0u, test_queue.size());
}
-TEST_F(PrioritizedQueueTest, Pop_TwoElementsInPriorityQueue_ExpectElementErasedIfOnlyOneWithConcretePriorityExist) {
+TEST_F(
+ PrioritizedQueueTest,
+ Pop_TwoElementsInPriorityQueue_ExpectElementErasedIfOnlyOneWithConcretePriorityExist) {
// Creating 2 messages with same priority and 1 with different
TestMessage message1("Hello", 111);
TestMessage message2("Luxoft", 111);
@@ -162,7 +167,8 @@ TEST_F(PrioritizedQueueTest, Pop_TwoElementsInPriorityQueue_ExpectElementErasedI
test_queue.push(message1);
test_queue.push(message2);
test_queue.push(message3);
- // Expect 3 messages were added successfully to Two elements of prioritized queue
+ // Expect 3 messages were added successfully to Two elements of prioritized
+ // queue
EXPECT_EQ(3u, test_queue.size());
// Extracting first element from the queue
EXPECT_EQ(message1, test_queue.front());
@@ -177,7 +183,8 @@ TEST_F(PrioritizedQueueTest, Pop_TwoElementsInPriorityQueue_ExpectElementErasedI
EXPECT_EQ(0u, test_queue.size());
}
-TEST_F(PrioritizedQueueTest, NotEmptyPrioritizedQueuePopElement_ExpectQueueDecreasedOneElement) {
+TEST_F(PrioritizedQueueTest,
+ NotEmptyPrioritizedQueuePopElement_ExpectQueueDecreasedOneElement) {
// Creating 4 prioritized messages
TestMessage message1("Alice", 111);
TestMessage message2("in", 14);
diff --git a/src/components/utils/test/qdb_wrapper/sql_query_test.cc b/src/components/utils/test/qdb_wrapper/sql_query_test.cc
index 4d880a4cda..6c866ffb9d 100644
--- a/src/components/utils/test/qdb_wrapper/sql_query_test.cc
+++ b/src/components/utils/test/qdb_wrapper/sql_query_test.cc
@@ -55,8 +55,9 @@ class SQLQueryTest : public ::testing::Test {
static void SetUpTestCase() {
conn = qdb_connect(kDatabaseName.c_str(), 0);
ASSERT_TRUE(conn);
- int ret = qdb_statement(conn, "CREATE TABLE testTable (integerValue INTEGER,"
- " doubleValue REAL, stringValue TEXT)");
+ int ret = qdb_statement(conn,
+ "CREATE TABLE testTable (integerValue INTEGER,"
+ " doubleValue REAL, stringValue TEXT)");
ASSERT_NE(-1, ret);
}
@@ -93,9 +94,10 @@ TEST_F(SQLQueryTest, Query) {
}
TEST_F(SQLQueryTest, ExecString) {
- const std::string kInsert("INSERT INTO testTable"
- " (integerValue, doubleValue, stringValue)"
- " VALUES(1, 1.1, 'one-один')");
+ const std::string kInsert(
+ "INSERT INTO testTable"
+ " (integerValue, doubleValue, stringValue)"
+ " VALUES(1, 1.1, 'one-один')");
SQLDatabase* db = new SQLDatabase(kDatabaseName);
ASSERT_TRUE(db->Open());
@@ -153,8 +155,9 @@ TEST_F(SQLQueryTest, BindString) {
}
TEST_F(SQLQueryTest, BindAllTypes) {
- const std::string kInsert("INSERT INTO testTable (integerValue, doubleValue,"
- " stringValue) VALUES (?, ?, ?)");
+ const std::string kInsert(
+ "INSERT INTO testTable (integerValue, doubleValue,"
+ " stringValue) VALUES (?, ?, ?)");
const int kIntegerValue = 5;
const double kDoubleValue = 5.5;
const std::string kStringValue = "five-пять";
@@ -176,13 +179,15 @@ TEST_F(SQLQueryTest, BindAllTypes) {
}
TEST_F(SQLQueryTest, Value) {
- const char* insert = "INSERT INTO testTable "
+ const char* insert =
+ "INSERT INTO testTable "
"(integerValue, doubleValue, stringValue) "
"VALUES (6, 6.6, 'six-шесть');";
ASSERT_NE(-1, qdb_statement(conn, insert));
- const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
- " FROM testTable WHERE integerValue = 6");
+ const std::string kSelect(
+ "SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE integerValue = 6");
const int kIntegerValue = 6;
const double kDoubleValue = 6.6;
const std::string kStringValue = "six-шесть";
@@ -203,8 +208,9 @@ TEST_F(SQLQueryTest, Value) {
}
TEST_F(SQLQueryTest, EmptySelect) {
- const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
- " FROM testTable WHERE 0");
+ const std::string kSelect(
+ "SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE 0");
SQLDatabase* db = new SQLDatabase(kDatabaseName);
ASSERT_TRUE(db->Open());
@@ -216,13 +222,15 @@ TEST_F(SQLQueryTest, EmptySelect) {
}
TEST_F(SQLQueryTest, NextAndBind) {
- const char* insert = "INSERT INTO testTable "
+ const char* insert =
+ "INSERT INTO testTable "
"(integerValue, doubleValue, stringValue) "
"VALUES (7, 7.7, 'seven-семь');";
ASSERT_NE(-1, qdb_statement(conn, insert));
- const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
- " FROM testTable WHERE integerValue = ?");
+ const std::string kSelect(
+ "SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE integerValue = ?");
const int kIntegerValue = 7;
const double kDoubleValue = 7.7;
const std::string kStringValue = "seven-семь";
@@ -245,7 +253,8 @@ TEST_F(SQLQueryTest, NextAndBind) {
}
TEST_F(SQLQueryTest, LastInsertId) {
- const char* create = "CREATE TABLE idTable ( "
+ const char* create =
+ "CREATE TABLE idTable ( "
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"value TEXT)";
ASSERT_NE(-1, qdb_statement(conn, create));
@@ -270,8 +279,9 @@ TEST_F(SQLQueryTest, LastInsertId) {
}
TEST_F(SQLQueryTest, BindNull) {
- const std::string kInsert("INSERT INTO testTable (`integerValue`)"
- " VALUES (?)");
+ const std::string kInsert(
+ "INSERT INTO testTable (`integerValue`)"
+ " VALUES (?)");
SQLDatabase* db = new SQLDatabase(kDatabaseName);
ASSERT_TRUE(db->Open());
diff --git a/src/components/utils/test/resource_usage_test.cc b/src/components/utils/test/resource_usage_test.cc
index cac5dc2e31..96b4fe4b49 100644
--- a/src/components/utils/test/resource_usage_test.cc
+++ b/src/components/utils/test/resource_usage_test.cc
@@ -60,25 +60,24 @@ TEST_F(ResourceUsagePrivateTest, GetMemInfoTest) {
}
TEST_F(ResourceUsagePrivateTest, GetStatPathTest_FileExists) {
- //arrange
+ // arrange
std::string filename = res.GetStatPath();
- //assert
+ // assert
EXPECT_TRUE(file_system::FileExists(filename));
}
TEST_F(ResourceUsagePrivateTest, GetStatPathTest_ReadFile) {
- //arrange
+ // arrange
std::string filename = res.GetStatPath();
std::string output;
- //assert
+ // assert
EXPECT_TRUE(file_system::ReadFile(filename, output));
-
}
TEST_F(ResourceUsagePrivateTest, GetProcPathTest) {
- ///arrange
+ /// arrange
std::string fd = res.GetProcPath();
std::string filename = res.GetStatPath();
- //assert
+ // assert
EXPECT_EQ(filename, fd + "/stat");
}
}
@@ -88,7 +87,8 @@ namespace components {
namespace utils_test {
TEST(ResourceUsageTest, SuccesfulGrabResources) {
- ::utils::ResourseUsage* resources = ::utils::Resources::getCurrentResourseUsage();
+ ::utils::ResourseUsage* resources =
+ ::utils::Resources::getCurrentResourseUsage();
EXPECT_TRUE(resources != NULL);
delete resources;
}
diff --git a/src/components/utils/test/rwlock_posix_test.cc b/src/components/utils/test/rwlock_posix_test.cc
index 779b57ff32..6cb140f4c5 100644
--- a/src/components/utils/test/rwlock_posix_test.cc
+++ b/src/components/utils/test/rwlock_posix_test.cc
@@ -72,20 +72,20 @@ class RWlockTest : public ::testing::Test {
}
}
- static void* ReadLock_helper(void *context) {
- RWlockTest *temp = reinterpret_cast<RWlockTest *>(context);
+ static void* ReadLock_helper(void* context) {
+ RWlockTest* temp = reinterpret_cast<RWlockTest*>(context);
temp->ReadLock();
return NULL;
}
- static void* TryReadLock_helper(void *context) {
- RWlockTest *temp = reinterpret_cast<RWlockTest *>(context);
+ static void* TryReadLock_helper(void* context) {
+ RWlockTest* temp = reinterpret_cast<RWlockTest*>(context);
temp->ExpectReadLockFail();
return NULL;
}
- static void* TryWriteLock_helper(void *context) {
- RWlockTest *temp = reinterpret_cast<RWlockTest *>(context);
+ static void* TryWriteLock_helper(void* context) {
+ RWlockTest* temp = reinterpret_cast<RWlockTest*>(context);
temp->ExpectWriteLockFail();
return NULL;
}
@@ -101,7 +101,8 @@ TEST_F(RWlockTest, AcquireForReading_ExpectAccessForReading) {
EXPECT_TRUE(test_rwlock.AcquireForReading());
// Try to lock rw lock for reading again
EXPECT_TRUE(test_rwlock.AcquireForReading());
- // Creating kNumThreads threads, starting them with callback function, waits until all of them finished
+ // Creating kNumThreads threads, starting them with callback function, waits
+ // until all of them finished
ThreadsDispatcher(&RWlockTest::ReadLock_helper);
// Releasing RW locks
EXPECT_TRUE(test_rwlock.Release());
@@ -113,7 +114,8 @@ TEST_F(RWlockTest, AcquireForReading_ExpectNoAccessForWriting) {
EXPECT_TRUE(test_rwlock.AcquireForReading());
// Try to lock rw lock for writing
EXPECT_FALSE(test_rwlock.TryAcquireForWriting());
- // Creating kNumThreads threads, starting them with callback function, waits until all of them finished
+ // Creating kNumThreads threads, starting them with callback function, waits
+ // until all of them finished
ThreadsDispatcher(&RWlockTest::TryWriteLock_helper);
EXPECT_TRUE(test_rwlock.Release());
}
@@ -123,7 +125,8 @@ TEST_F(RWlockTest, AcquireForWriting_ExpectNoAccessForReading) {
EXPECT_TRUE(test_rwlock.AcquireForWriting());
// Try to lock rw lock for reading
EXPECT_FALSE(test_rwlock.TryAcquireForReading());
- // Creating kNumThreads threads, starting them with callback function, waits until all of them finished
+ // Creating kNumThreads threads, starting them with callback function, waits
+ // until all of them finished
ThreadsDispatcher(&RWlockTest::TryReadLock_helper);
EXPECT_TRUE(test_rwlock.Release());
}
@@ -133,7 +136,8 @@ TEST_F(RWlockTest, AcquireForWriting_ExpectNoMoreAccessForWriting) {
EXPECT_TRUE(test_rwlock.AcquireForWriting());
// Try to lock rw lock for reading
EXPECT_FALSE(test_rwlock.TryAcquireForWriting());
- // Creating kNumThreads threads, starting them with callback function, waits until all of them finished
+ // Creating kNumThreads threads, starting them with callback function, waits
+ // until all of them finished
ThreadsDispatcher(&RWlockTest::TryWriteLock_helper);
EXPECT_TRUE(test_rwlock.Release());
}
diff --git a/src/components/utils/test/shared_ptr_test.cc b/src/components/utils/test/shared_ptr_test.cc
index 92d867fe76..85682073aa 100644
--- a/src/components/utils/test/shared_ptr_test.cc
+++ b/src/components/utils/test/shared_ptr_test.cc
@@ -42,20 +42,20 @@ namespace utils {
namespace SharedPtrTest {
class CMockObject {
- public:
- CMockObject(int id);
- virtual ~CMockObject();
- virtual int getId() const;
+ public:
+ CMockObject(int id);
+ virtual ~CMockObject();
+ virtual int getId() const;
- MOCK_METHOD0(destructor, void ());
+ MOCK_METHOD0(destructor, void());
- private:
- int mId_;
+ private:
+ int mId_;
};
class CExtendedMockObject : public CMockObject {
- public:
- CExtendedMockObject(int id);
+ public:
+ CExtendedMockObject(int id);
};
} // namespace CMockObject
@@ -66,9 +66,7 @@ class CExtendedMockObject : public CMockObject {
using namespace test::components::utils::SharedPtrTest;
using ::testing::NiceMock;
-CMockObject::CMockObject(int id)
- : mId_(id) {
-}
+CMockObject::CMockObject(int id) : mId_(id) {}
CMockObject::~CMockObject() {
destructor();
@@ -78,9 +76,7 @@ int CMockObject::getId() const {
return mId_;
}
-CExtendedMockObject::CExtendedMockObject(int id)
- : CMockObject(id) {
-}
+CExtendedMockObject::CExtendedMockObject(int id) : CMockObject(id) {}
typedef utils::SharedPtr<CMockObject> tMockObjectPtr;
typedef utils::SharedPtr<CExtendedMockObject> tExtendedMockObjectPtr;
@@ -120,9 +116,9 @@ TEST(SharedPtrTest, CopyConstructorTest) {
ASSERT_EQ(1, p3->getId());
ASSERT_EQ(3u, *(p3.get_ReferenceCounter()));
{
- tMockObjectPtr p4 = p3;
- ASSERT_EQ(1, p4->getId());
- ASSERT_EQ(4u, *(p3.get_ReferenceCounter()));
+ tMockObjectPtr p4 = p3;
+ ASSERT_EQ(1, p4->getId());
+ ASSERT_EQ(4u, *(p3.get_ReferenceCounter()));
}
// Check reference counter decreased
ASSERT_EQ(3u, *(p3.get_ReferenceCounter()));
@@ -283,10 +279,9 @@ TEST(SharedPtrTest, LessThanOperatorTest) {
// Checks
if (object1 < object2) {
- ASSERT_TRUE(p1 < p2);
- }
- else {
- ASSERT_FALSE(p1 < p2);
+ ASSERT_TRUE(p1 < p2);
+ } else {
+ ASSERT_FALSE(p1 < p2);
}
EXPECT_CALL(*object1, destructor());
@@ -309,7 +304,8 @@ TEST(SharedPtrTest, StaticPointerCastTest_DerivedToBase_ExpectCastOk) {
ASSERT_EQ(2, ep1->getId());
ASSERT_EQ(1u, *(ep1.get_ReferenceCounter()));
// Cast from SharedPtr to Derived class to SharedPtr to Base class
- p1 = utils::SharedPtr<CExtendedMockObject>::static_pointer_cast< CMockObject >(ep1);
+ p1 = utils::SharedPtr<CExtendedMockObject>::static_pointer_cast<CMockObject>(
+ ep1);
// Checks
ASSERT_EQ(2, p1->getId());
ASSERT_EQ(2u, *(p1.get_ReferenceCounter()));
@@ -334,7 +330,8 @@ TEST(SharedPtrTest, StaticPointerCastTest_BaseToDerived_ExpectCastOk) {
ASSERT_EQ(2, ep1->getId());
ASSERT_EQ(1u, *(ep1.get_ReferenceCounter()));
// Cast from SharedPtr to Base class to SharedPtr to Derived class
- ep1 = utils::SharedPtr<CMockObject>::static_pointer_cast<CExtendedMockObject>(p1);
+ ep1 = utils::SharedPtr<CMockObject>::static_pointer_cast<CExtendedMockObject>(
+ p1);
// Checks
ASSERT_EQ(1, ep1->getId());
ASSERT_EQ(2u, *(ep1.get_ReferenceCounter()));
@@ -359,7 +356,8 @@ TEST(SharedPtrTest, DynamicPointerCastTest_DerivedToBase_ExpectCastOk) {
ASSERT_EQ(2, ep1->getId());
ASSERT_EQ(1u, *(ep1.get_ReferenceCounter()));
// Cast from SharedPtr to Derived class to SharedPtr to Base class
- p1 = utils::SharedPtr<CExtendedMockObject>::dynamic_pointer_cast< CMockObject >(ep1);
+ p1 = utils::SharedPtr<CExtendedMockObject>::dynamic_pointer_cast<CMockObject>(
+ ep1);
// Checks
ASSERT_EQ(2, p1->getId());
ASSERT_EQ(2u, *(p1.get_ReferenceCounter()));
@@ -384,7 +382,9 @@ TEST(SharedPtrTest, DynamicPointerCastTest_BaseToDerived_ExpectNullPtr) {
ASSERT_EQ(2, ep1->getId());
ASSERT_EQ(1u, *(ep1.get_ReferenceCounter()));
// Cast from SharedPtr to Base class to SharedPtr to Derived class
- ep1 = utils::SharedPtr<CMockObject>::dynamic_pointer_cast<CExtendedMockObject>(p1);
+ ep1 =
+ utils::SharedPtr<CMockObject>::dynamic_pointer_cast<CExtendedMockObject>(
+ p1);
// Checks
ASSERT_EQ(NULL, ep1);
@@ -539,6 +539,7 @@ TEST(SharedPtrTest, StressTest) {
}
}
}
- printf("%zu objects created, %zu pointers copied\n", objectCreated,
+ printf("%zu objects created, %zu pointers copied\n",
+ objectCreated,
pointersCopied);
}
diff --git a/src/components/utils/test/singleton_test.cc b/src/components/utils/test/singleton_test.cc
index 8a9e6b31e1..3bad45a7d7 100644
--- a/src/components/utils/test/singleton_test.cc
+++ b/src/components/utils/test/singleton_test.cc
@@ -42,7 +42,6 @@ using ::utils::Singleton;
class SingletonTest : public ::utils::Singleton<SingletonTest> {
public:
-
void SetValue(int value) {
test_value = value;
}
@@ -50,128 +49,129 @@ class SingletonTest : public ::utils::Singleton<SingletonTest> {
return test_value;
}
- FRIEND_BASE_SINGLETON_CLASS (SingletonTest);
+ FRIEND_BASE_SINGLETON_CLASS(SingletonTest);
+
private:
int test_value;
};
TEST(SingletonTest, CreateAndDestroySingleton) {
- //assert
+ // assert
ASSERT_EQ(SingletonTest::instance(), SingletonTest::instance());
ASSERT_EQ(0, SingletonTest::instance()->GetValue());
ASSERT_TRUE(SingletonTest::exists());
SingletonTest::instance()->SetValue(5);
ASSERT_EQ(5, SingletonTest::instance()->GetValue());
- //act
+ // act
SingletonTest::destroy();
- //assert
+ // assert
ASSERT_FALSE(SingletonTest::exists());
}
TEST(SingletonTest, DestroySingletonTwice) {
- //assert
+ // assert
ASSERT_EQ(0, SingletonTest::instance()->GetValue());
ASSERT_TRUE(SingletonTest::exists());
- //act
+ // act
SingletonTest::destroy();
- //assert
+ // assert
ASSERT_FALSE(SingletonTest::exists());
- //act
+ // act
SingletonTest::destroy();
- //assert
+ // assert
ASSERT_FALSE(SingletonTest::exists());
}
TEST(SingletonTest, DeleteSingletonCreateAnother) {
- //arrange
+ // arrange
SingletonTest::instance()->SetValue(10);
- //assert
+ // assert
ASSERT_TRUE(SingletonTest::exists());
ASSERT_EQ(10, SingletonTest::instance()->GetValue());
- //act
+ // act
SingletonTest::destroy();
- //assert
+ // assert
ASSERT_FALSE(SingletonTest::exists());
- //act
+ // act
SingletonTest::instance();
- //assert
+ // assert
ASSERT_EQ(0, SingletonTest::instance()->GetValue());
ASSERT_TRUE(SingletonTest::exists());
SingletonTest::destroy();
}
void* func_pthread1(void*) {
- SingletonTest* singleton_in_other_thread = SingletonTest::instance();
+ SingletonTest* singleton_in_other_thread = SingletonTest::instance();
pthread_exit(singleton_in_other_thread);
return NULL;
}
-void* func_pthread2(void * value) {
- SingletonTest * instance = reinterpret_cast<SingletonTest *>(value);
+void* func_pthread2(void* value) {
+ SingletonTest* instance = reinterpret_cast<SingletonTest*>(value);
instance->destroy();
- pthread_exit (NULL);
+ pthread_exit(NULL);
return NULL;
}
TEST(SingletonTest, CreateSingletonInDifferentThreads) {
- //arrange
+ // arrange
SingletonTest::instance();
ASSERT_TRUE(SingletonTest::exists());
pthread_t thread1;
pthread_create(&thread1, NULL, func_pthread1, NULL);
- void *instance2;
+ void* instance2;
pthread_join(thread1, &instance2);
- SingletonTest * instance_2 = reinterpret_cast<SingletonTest *>(instance2);
+ SingletonTest* instance_2 = reinterpret_cast<SingletonTest*>(instance2);
- //assert
+ // assert
ASSERT_EQ(SingletonTest::instance(), instance_2);
- //act
+ // act
SingletonTest::destroy();
- //assert
+ // assert
ASSERT_FALSE(SingletonTest::exists());
}
TEST(SingletonTest, CreateDeleteSingletonInDifferentThreads) {
- //arrange
+ // arrange
pthread_t thread1;
pthread_create(&thread1, NULL, func_pthread1, NULL);
pthread_t thread2;
pthread_create(&thread2, NULL, func_pthread1, NULL);
- void *instance1;
+ void* instance1;
pthread_join(thread1, &instance1);
- SingletonTest * instance_1 = reinterpret_cast<SingletonTest *>(instance1);
+ SingletonTest* instance_1 = reinterpret_cast<SingletonTest*>(instance1);
- void *instance2;
+ void* instance2;
pthread_join(thread2, &instance2);
- SingletonTest * instance_2 = reinterpret_cast<SingletonTest *>(instance2);
+ SingletonTest* instance_2 = reinterpret_cast<SingletonTest*>(instance2);
- //assert
+ // assert
ASSERT_TRUE(instance_1->exists());
ASSERT_TRUE(instance_2->exists());
ASSERT_EQ(instance_1, instance_2);
- //act
+ // act
SingletonTest::destroy();
- //assert
+ // assert
ASSERT_FALSE(instance_1->exists());
ASSERT_FALSE(instance_2->exists());
}
TEST(SingletonTest, DeleteSingletonInDifferentThread) {
- //arrange
+ // arrange
SingletonTest::instance();
ASSERT_TRUE(SingletonTest::exists());
@@ -180,7 +180,7 @@ TEST(SingletonTest, DeleteSingletonInDifferentThread) {
pthread_join(thread1, NULL);
- //assert
+ // assert
ASSERT_FALSE(SingletonTest::exists());
}
diff --git a/src/components/utils/test/sqlite_wrapper/sql_database_test.cc b/src/components/utils/test/sqlite_wrapper/sql_database_test.cc
index ab72fb0eff..927f9dd88f 100644
--- a/src/components/utils/test/sqlite_wrapper/sql_database_test.cc
+++ b/src/components/utils/test/sqlite_wrapper/sql_database_test.cc
@@ -50,55 +50,52 @@ namespace dbms {
}
TEST(SQLDatabaseTest, OpenCloseMemory_OpenAndCloseDB_ActsWithoutError) {
-
- //arrange
+ // arrange
SQLDatabase db;
bool ret = db.Open();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
ASSERT_TRUE(ret);
- //act
+ // act
db.Close();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
}
TEST(SQLDatabaseTest, OpenCloseFile_OpenAndCloseSpecifiedDB_ActsWithoutError) {
-
- //arrange
+ // arrange
SQLDatabase db("test-database");
bool ret = db.Open();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
ASSERT_TRUE(ret);
- //act
+ // act
db.Close();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
remove("test-database.sqlite");
}
TEST(SQLDatabaseTest, OpenDBTwice_NoError) {
-
- //arrange
+ // arrange
SQLDatabase db;
bool ret = db.Open();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
ASSERT_TRUE(ret);
- //act
+ // act
ret = db.Open();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
ASSERT_TRUE(ret);
@@ -106,44 +103,42 @@ TEST(SQLDatabaseTest, OpenDBTwice_NoError) {
}
TEST(SQLDatabaseTest, CloseDBTwice_NoError) {
-
- //arrange
+ // arrange
SQLDatabase db;
bool ret = db.Open();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
ASSERT_TRUE(ret);
- //act
+ // act
db.Close();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
- //act
+ // act
db.Close();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
}
TEST(SQLDatabaseTest, Close_DBWasNotOpened_NoError) {
-
- //act
+ // act
SQLDatabase db;
db.Close();
- //assert
+ // assert
EXPECT_FALSE(IsError(db.LastError()));
}
-TEST(SQLDatabaseTest, CommitTransaction_StartAndCommitTransaction_ExpectActsWithoutError) {
-
- //arrange
+TEST(SQLDatabaseTest,
+ CommitTransaction_StartAndCommitTransaction_ExpectActsWithoutError) {
+ // arrange
SQLDatabase db;
- //assert
+ // assert
ASSERT_TRUE(db.Open());
EXPECT_TRUE(db.BeginTransaction());
EXPECT_FALSE(IsError(db.LastError()));
@@ -153,12 +148,12 @@ TEST(SQLDatabaseTest, CommitTransaction_StartAndCommitTransaction_ExpectActsWith
db.Close();
}
-TEST(SQLDatabaseTest, RollbackTransaction_StartAndRollbackTransaction_ExpectActsWithoutError) {
-
- //arrange
+TEST(SQLDatabaseTest,
+ RollbackTransaction_StartAndRollbackTransaction_ExpectActsWithoutError) {
+ // arrange
SQLDatabase db;
- //assert
+ // assert
ASSERT_TRUE(db.Open());
EXPECT_TRUE(db.BeginTransaction());
EXPECT_FALSE(IsError(db.LastError()));
@@ -168,12 +163,12 @@ TEST(SQLDatabaseTest, RollbackTransaction_StartAndRollbackTransaction_ExpectActs
db.Close();
}
-TEST(SQLDatabaseTest, FailedCommitTransaction_CommitTransactionWithoutBeginning_ExpectError) {
-
- //arrange
+TEST(SQLDatabaseTest,
+ FailedCommitTransaction_CommitTransactionWithoutBeginning_ExpectError) {
+ // arrange
SQLDatabase db;
- //assert
+ // assert
ASSERT_TRUE(db.Open());
EXPECT_FALSE(db.CommitTransaction());
EXPECT_TRUE(IsError(db.LastError()));
@@ -181,12 +176,13 @@ TEST(SQLDatabaseTest, FailedCommitTransaction_CommitTransactionWithoutBeginning_
db.Close();
}
-TEST(SQLDatabaseTest, FailedRollbackTransaction_RollbackTransactionWithoutBeginning_ExpectError) {
-
- //arrange
+TEST(
+ SQLDatabaseTest,
+ FailedRollbackTransaction_RollbackTransactionWithoutBeginning_ExpectError) {
+ // arrange
SQLDatabase db;
- //assert
+ // assert
ASSERT_TRUE(db.Open());
EXPECT_FALSE(db.RollbackTransaction());
EXPECT_TRUE(IsError(db.LastError()));
@@ -195,27 +191,25 @@ TEST(SQLDatabaseTest, FailedRollbackTransaction_RollbackTransactionWithoutBeginn
}
TEST(SQLDatabaseTest, BadTransaction_BeginTransitionWithoutOpenDB_ExpectError) {
-
- //arrange
+ // arrange
SQLDatabase db;
- //assert
+ // assert
EXPECT_FALSE(db.BeginTransaction());
EXPECT_TRUE(IsError(db.LastError()));
}
TEST(SQLDatabaseTest, IsReadWrite_FirstOpenDBIsRWSecondIsNot) {
-
- //arrange
+ // arrange
SQLDatabase db("test-database");
- //assert
+ // assert
ASSERT_TRUE(db.Open());
EXPECT_TRUE(db.IsReadWrite());
db.Close();
chmod("test-database.sqlite", S_IRUSR);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
EXPECT_FALSE(db.IsReadWrite());
diff --git a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
index 07aff6127e..0cf378bab5 100644
--- a/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
+++ b/src/components/utils/test/sqlite_wrapper/sql_query_test.cc
@@ -54,9 +54,12 @@ class SQLQueryTest : public ::testing::Test {
static void SetUpTestCase() {
sqlite3_open((kDatabaseName + ".sqlite").c_str(), &conn);
- sqlite3_exec(conn, "CREATE TABLE testTable (integerValue INTEGER,"
+ sqlite3_exec(conn,
+ "CREATE TABLE testTable (integerValue INTEGER,"
" doubleValue REAL, stringValue TEXT)",
- NULL, NULL, NULL);
+ NULL,
+ NULL,
+ NULL);
}
static void TearDownTestCase() {
@@ -97,131 +100,132 @@ sqlite3* SQLQueryTest::conn = 0;
const std::string SQLQueryTest::kDatabaseName = "test-query";
TEST_F(SQLQueryTest, Query_CreateQuery_QueryInDBEqualCreated) {
-
- //arrange
+ // arrange
const std::string kSelect("SELECT * FROM testTable WHERE integerValue = ?");
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
query.Prepare(kSelect);
- //assert
+ // assert
EXPECT_STREQ(kSelect.c_str(), query.query().c_str());
}
TEST_F(SQLQueryTest, ExecString_ExecuteQuery_ActWithoutError) {
-
- //arrange
- const std::string kInsert("INSERT INTO testTable"
- " (integerValue, doubleValue, stringValue)"
- " VALUES(2, 3.4, 'five-пять')");
+ // arrange
+ const std::string kInsert(
+ "INSERT INTO testTable"
+ " (integerValue, doubleValue, stringValue)"
+ " VALUES(2, 3.4, 'five-пять')");
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
- //assert
+ // assert
EXPECT_TRUE(query.Exec(kInsert));
EXPECT_FALSE(IsError(query.LastError()));
}
-TEST_F(SQLQueryTest, Bind_BindSeveralQueries_ExpectExecutedQueriesWithoutErrors) {
-
- //arrange
+TEST_F(SQLQueryTest,
+ Bind_BindSeveralQueries_ExpectExecutedQueriesWithoutErrors) {
+ // arrange
const std::string kInsert1("INSERT INTO testTable (integerValue) VALUES (?)");
const std::string kInsert2("INSERT INTO testTable (doubleValue) VALUES (?)");
const std::string kInsert3("INSERT INTO testTable (stringValue) VALUES (?)");
- const std::string kInsert4("INSERT INTO testTable (integerValue, doubleValue,"
- " stringValue) VALUES (?, ?, ?)");
+ const std::string kInsert4(
+ "INSERT INTO testTable (integerValue, doubleValue,"
+ " stringValue) VALUES (?, ?, ?)");
const int kIntegerValue = 1;
const double kDoubleValue = 2.3;
const std::string kStringValue = "four";
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query1(&db);
- //assert
+ // assert
EXPECT_TRUE(query1.Prepare(kInsert1));
EXPECT_FALSE(IsError(query1.LastError()));
query1.Bind(0, kIntegerValue);
- //assert
+ // assert
EXPECT_FALSE(IsError(query1.LastError()));
EXPECT_TRUE(query1.Exec());
EXPECT_TRUE(IsDone(query1.LastError()));
- //act
+ // act
SQLQuery query2(&db);
- //assert
+ // assert
EXPECT_TRUE(query2.Prepare(kInsert2));
EXPECT_FALSE(IsError(query2.LastError()));
query2.Bind(0, kDoubleValue);
- //assert
+ // assert
EXPECT_FALSE(IsError(query2.LastError()));
EXPECT_TRUE(query2.Exec());
EXPECT_TRUE(IsDone(query2.LastError()));
- //act
+ // act
SQLQuery query3(&db);
EXPECT_TRUE(query3.Prepare(kInsert3));
EXPECT_FALSE(IsError(query3.LastError()));
query3.Bind(0, kStringValue);
- //assert
+ // assert
EXPECT_FALSE(IsError(query3.LastError()));
EXPECT_TRUE(query3.Exec());
EXPECT_TRUE(IsDone(query3.LastError()));
- //act
+ // act
SQLQuery query4(&db);
- //assert
+ // assert
EXPECT_TRUE(query4.Prepare(kInsert4));
EXPECT_FALSE(IsError(query4.LastError()));
query4.Bind(0, kIntegerValue);
query4.Bind(1, kDoubleValue);
query4.Bind(2, kStringValue);
- //assert
+ // assert
EXPECT_FALSE(IsError(query4.LastError()));
EXPECT_TRUE(query4.Exec());
EXPECT_TRUE(IsDone(query4.LastError()));
}
TEST_F(SQLQueryTest, SetValue_InsertValues_ExpectDBHasInsertedValues) {
-
- //arrange
- const char* insert = "INSERT INTO testTable "
+ // arrange
+ const char* insert =
+ "INSERT INTO testTable "
"(integerValue, doubleValue, stringValue) "
"VALUES (1, 2.3, 'four');";
- //assert
+ // assert
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, insert, NULL, NULL, NULL));
- //act
- const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
- " FROM testTable");
+ // act
+ const std::string kSelect(
+ "SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable");
const int kIntegerValue = 1;
const double kDoubleValue = 2.3;
const std::string kStringValue = "four";
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
- //assert
+ // assert
EXPECT_TRUE(query.Prepare(kSelect));
EXPECT_FALSE(IsError(query.LastError()));
EXPECT_TRUE(query.Exec());
@@ -234,39 +238,42 @@ TEST_F(SQLQueryTest, SetValue_InsertValues_ExpectDBHasInsertedValues) {
}
TEST_F(SQLQueryTest, EmptySelect_SelectValuesEqual0_ExecWithoutErrors) {
-
- //arrange
- const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
- " FROM testTable WHERE 0");
+ // arrange
+ const std::string kSelect(
+ "SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE 0");
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
- //assert
+ // assert
EXPECT_TRUE(query.Prepare(kSelect));
EXPECT_FALSE(IsError(query.LastError()));
EXPECT_TRUE(query.Exec());
EXPECT_TRUE(IsDone(query.LastError()));
}
-TEST_F(SQLQueryTest, NextAndBind_InsertValuesAndBindQuery_ExecWithoutErrorsAndBindingQueryIsLast) {
-
- //arrange
- const char* insert = "INSERT INTO testTable "
+TEST_F(
+ SQLQueryTest,
+ NextAndBind_InsertValuesAndBindQuery_ExecWithoutErrorsAndBindingQueryIsLast) {
+ // arrange
+ const char* insert =
+ "INSERT INTO testTable "
"(integerValue, doubleValue, stringValue) "
"VALUES (1, 2.3, 'four');";
- //assert
+ // assert
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, insert, NULL, NULL, NULL));
- const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
- " FROM testTable WHERE stringValue = ?");
+ const std::string kSelect(
+ "SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE stringValue = ?");
- //act
+ // act
const int kIntegerValue = 1;
const double kDoubleValue = 2.3;
const std::string kStringValue = "four";
@@ -276,12 +283,12 @@ TEST_F(SQLQueryTest, NextAndBind_InsertValuesAndBindQuery_ExecWithoutErrorsAndBi
SQLQuery query(&db);
- //assert
+ // assert
ASSERT_TRUE(query.Prepare(kSelect));
EXPECT_FALSE(IsError(query.LastError()));
- //act
+ // act
query.Bind(0, kStringValue);
- //assert
+ // assert
EXPECT_FALSE(IsError(query.LastError()));
EXPECT_TRUE(query.Exec());
ASSERT_TRUE(IsRow(query.LastError()));
@@ -293,36 +300,35 @@ TEST_F(SQLQueryTest, NextAndBind_InsertValuesAndBindQuery_ExecWithoutErrorsAndBi
}
TEST_F(SQLQueryTest, LastInsertId_InsertValuesAndBindQuery_GetExpectedId) {
-
- //arrange
- const char* create = "CREATE TABLE idTable ( "
+ // arrange
+ const char* create =
+ "CREATE TABLE idTable ( "
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"value TEXT)";
- //assert
+ // assert
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, create, NULL, NULL, NULL));
-
const int64_t kExpectId = 1;
const std::string kValue("Test last id of insert row");
const std::string kInsert("INSERT INTO idTable (value) VALUES(?)");
- //act
+ // act
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
- //assert
+ // assert
ASSERT_TRUE(query.Prepare(kInsert));
EXPECT_FALSE(IsError(query.LastError()));
- //act
+ // act
query.Bind(0, kValue);
- //assert
+ // assert
EXPECT_FALSE(IsError(query.LastError()));
EXPECT_TRUE(query.Exec());
ASSERT_TRUE(IsDone(query.LastError()));
@@ -333,36 +339,35 @@ TEST_F(SQLQueryTest, LastInsertId_InsertValuesAndBindQuery_GetExpectedId) {
}
TEST_F(SQLQueryTest, BindNull_BindWithoutValue_ActWithoutErrors) {
-
- //arrange
- const std::string kInsert("INSERT INTO testTable (`integerValue`)"
- " VALUES (?)");
+ // arrange
+ const std::string kInsert(
+ "INSERT INTO testTable (`integerValue`)"
+ " VALUES (?)");
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
- //assert
+ // assert
ASSERT_TRUE(query.Prepare(kInsert));
EXPECT_FALSE(IsError(query.LastError()));
query.Bind(0);
- //assert
+ // assert
EXPECT_FALSE(IsError(query.LastError()));
EXPECT_TRUE(query.Exec());
ASSERT_TRUE(IsDone(query.LastError()));
}
TEST_F(SQLQueryTest, DoublePrepare_TwicePrepareQuery_ActWithoutErrors) {
-
- //arrange
+ // arrange
SQLDatabase db(kDatabaseName);
- //assert
+ // assert
ASSERT_TRUE(db.Open());
- //act
+ // act
SQLQuery query(&db);
- //assert
+ // assert
EXPECT_TRUE(query.Prepare("SELECT * FROM testTable"));
EXPECT_FALSE(IsError(query.LastError()));
EXPECT_TRUE(query.Prepare("SELECT * FROM testTable"));
diff --git a/src/components/utils/test/stl_utils_test.cc b/src/components/utils/test/stl_utils_test.cc
index dfc00de982..1fbde052f1 100644
--- a/src/components/utils/test/stl_utils_test.cc
+++ b/src/components/utils/test/stl_utils_test.cc
@@ -44,8 +44,7 @@ using ::utils::StlMapDeleter;
class TestObject {
public:
- ~TestObject() {
- }
+ ~TestObject() {}
};
typedef std::map<int, TestObject*> TestMap;
@@ -56,9 +55,7 @@ TEST(StlDeleter, DestructMapWithOneElement) {
test_map[1] = new TestObject();
EXPECT_EQ(1u, test_map.size());
- {
- StlMapDeleter<TestMap> test_list_deleter_(&test_map);
- }
+ { StlMapDeleter<TestMap> test_list_deleter_(&test_map); }
EXPECT_EQ(1u, test_map.size());
EXPECT_EQ(NULL, test_map[1]);
}
@@ -69,9 +66,7 @@ TEST(StlDeleter, DestructMapWithSeveralElements) {
test_map[2] = new TestObject();
EXPECT_EQ(2u, test_map.size());
- {
- StlMapDeleter<TestMap> test_list_deleter_(&test_map);
- }
+ { StlMapDeleter<TestMap> test_list_deleter_(&test_map); }
EXPECT_EQ(2u, test_map.size());
EXPECT_EQ(NULL, test_map[1]);
EXPECT_EQ(NULL, test_map[2]);
@@ -82,9 +77,7 @@ TEST(StlDeleter, DestructVectorWithOneElement) {
test_vector.push_back(new TestObject());
EXPECT_EQ(1u, test_vector.size());
- {
- StlCollectionDeleter<TestVector> test_list_deleter_(&test_vector);
- }
+ { StlCollectionDeleter<TestVector> test_list_deleter_(&test_vector); }
EXPECT_EQ(1u, test_vector.size());
EXPECT_EQ(NULL, test_vector[0]);
}
@@ -95,9 +88,7 @@ TEST(StlDeleter, DestructVectorWithSeveralElements) {
test_vector.push_back(new TestObject());
EXPECT_EQ(2u, test_vector.size());
- {
- StlCollectionDeleter<TestVector> test_list_deleter_(&test_vector);
- }
+ { StlCollectionDeleter<TestVector> test_list_deleter_(&test_vector); }
EXPECT_EQ(2u, test_vector.size());
EXPECT_EQ(NULL, test_vector[0]);
EXPECT_EQ(NULL, test_vector[1]);
diff --git a/src/components/utils/test/system_test.cc b/src/components/utils/test/system_test.cc
index 42307998b4..aced77f849 100644
--- a/src/components/utils/test/system_test.cc
+++ b/src/components/utils/test/system_test.cc
@@ -62,7 +62,6 @@ TEST(SystemTest, Constructor_WithFileNameCommandName_ExpectArgsStored) {
// Check if actual number of arguments arec correct
int vec_size = object.argv().size();
ASSERT_EQ(vec_size, 1); // Correct number of arguments is 1
-
}
TEST(SystemTest, AddTwoArgsToCommand_ExpectTwoArgsAdded) {
@@ -93,33 +92,39 @@ TEST(SystemTest, AddTwoArgsToCommand_CheckOrder_ExpectOrderCorrect) {
EXPECT_STREQ(object.argv()[2].c_str(), args[1]);
}
-
-
TEST(SystemTest, SynchronousInvokeWithExistingCommand_ExpectSuccessfull) {
const std::string test_command("./testscript.sh");
System object(test_command);
- // Check if Execute() method is working properly with synchronous command invoke
+ // Check if Execute() method is working properly with synchronous command
+ // invoke
ASSERT_TRUE(object.Execute(true));
}
-TEST(SystemTest, SynchronousInvokeWithEmptyCommand_IncorrectCommand_ExpectFailed) {
+TEST(SystemTest,
+ SynchronousInvokeWithEmptyCommand_IncorrectCommand_ExpectFailed) {
const std::string test_command(""); // any incorrect command
System object(test_command);
- // Check if Execute() method will fail with not correct command (synchronous command invoke)
+ // Check if Execute() method will fail with not correct command (synchronous
+ // command invoke)
ASSERT_FALSE(object.Execute(true));
}
TEST(SystemTest, ASynchronousInvokeEmptyCommand_InvokeSuccessfull) {
- const std::string test_command(""); // Possible to put here any command (existing or incorrect)
- const std::string test_list_args("anything"); // as command will never be executed from child process
- System object(test_command, test_list_args); // as parrent process does not wait for child process to be finished
-
- // Check if Execute() method is working properly with asynchronous command invoke
+ const std::string test_command(
+ ""); // Possible to put here any command (existing or incorrect)
+ const std::string test_list_args(
+ "anything"); // as command will never be executed from child process
+ System object(test_command, test_list_args); // as parrent process does not
+ // wait for child process to be
+ // finished
+
+ // Check if Execute() method is working properly with asynchronous command
+ // invoke
ASSERT_TRUE(object.Execute());
}
-} // namespace utils
-} // namespace components
-} // namespace test
+} // namespace utils
+} // namespace components
+} // namespace test
diff --git a/src/components/utils/test/thread_validator_test.cc b/src/components/utils/test/thread_validator_test.cc
index 16d9d12874..b6e21d7157 100644
--- a/src/components/utils/test/thread_validator_test.cc
+++ b/src/components/utils/test/thread_validator_test.cc
@@ -45,9 +45,8 @@ using namespace ::threads;
TEST(ThreadValidatorTest, CompareID_CurrentThreadAndPthread_AreEqual) {
SingleThreadSimpleValidator object;
ASSERT_EQ(object.creation_thread_id(), pthread_self());
-
}
-} // namespace utils
-} // namespace components
-} // namespace test
+} // namespace utils
+} // namespace components
+} // namespace test