mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-13 10:42:56 +01:00
Merge pull request #84 from KjellKod/checkmarx-update
removed false positives as detected by Checkmarx code analysis tool. …
This commit is contained in:
commit
7d0779d92d
@ -100,7 +100,6 @@ namespace g3 {
|
||||
|
||||
|
||||
friend void swap(LogMessage& first, LogMessage& second) {
|
||||
// enable ADL (not necessary in our case, but good practice)
|
||||
using std::swap;
|
||||
swap(first._timestamp, second._timestamp);
|
||||
swap(first._call_thread_id, second._call_thread_id);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "performance.h"
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(G3LOG_PERFORMANCE)
|
||||
const std::string title = "G3LOG";
|
||||
|
@ -56,6 +56,8 @@ std::future<std::string> sillyFutureReturn()
|
||||
result.wait();
|
||||
return result; // already wasted
|
||||
}
|
||||
|
||||
|
||||
TEST(Configuration, FutureSilly)
|
||||
{
|
||||
std::string hello = sillyFutureReturn().get();
|
||||
@ -182,10 +184,10 @@ TEST(Yalla, Testar)
|
||||
{
|
||||
using namespace WORKING;
|
||||
auto f = spawn_task(get_res);
|
||||
std::cout << "Res = " << f.get() << std::endl;
|
||||
ASSERT_EQ(42.2, f.get());
|
||||
|
||||
auto f2 = spawn_task(msg3);
|
||||
std::cout << "Res2 = " << f2.get() << std::endl;
|
||||
ASSERT_EQ("msg3", f2.get());
|
||||
|
||||
|
||||
ASSERT_TRUE(true);
|
||||
|
@ -79,7 +79,7 @@ TEST(TestOf_ChangingLogFile, Expecting_NewLogFileUsed) {
|
||||
|
||||
TEST(TestOf_ChangingLogFile_Id, Expecting_NewLogFileUsed1) {
|
||||
auto old_log = getLogName();
|
||||
std::string name = setLogNameAndAddCount(name_path_1);
|
||||
setLogNameAndAddCount(name_path_1);
|
||||
auto new_log = setLogName("foo", "new_logger_id");
|
||||
ASSERT_NE(old_log, new_log);
|
||||
std::string new_name = getLogName();
|
||||
@ -90,7 +90,7 @@ TEST(TestOf_ChangingLogFile_Id, Expecting_NewLogFileUsed1) {
|
||||
|
||||
TEST(TestOf_ChangingLogFile_NoId, Expecting_NewLogFileUsed2) {
|
||||
auto old_log = getLogName();
|
||||
std::string name = setLogNameAndAddCount(name_path_1);
|
||||
setLogNameAndAddCount(name_path_1);
|
||||
auto new_log = setLogName("foo", "");
|
||||
ASSERT_NE(old_log, new_log);
|
||||
std::string new_name = getLogName();
|
||||
@ -137,6 +137,7 @@ TEST(TestOf_SinkHandleDifferentId, Expecting_DifferentId) {
|
||||
TEST(TestOf_LegalLogFileNam, With_parenthesis) {
|
||||
std::string original = getLogName();
|
||||
auto perhaps_a_name = setLogName("(test)"); // does not exist
|
||||
EXPECT_NE(original, perhaps_a_name);
|
||||
std::string post_legal = getLogName();
|
||||
EXPECT_TRUE(std::string::npos != post_legal.find("(test)")) << "filename was: " << post_legal;
|
||||
}
|
||||
|
@ -463,7 +463,6 @@ TEST(CheckTest, CHECK_F__thisWILL_PrintErrorMsg) {
|
||||
TEST(CHECK_F_Test, CHECK_F__thisWILL_PrintErrorMsg) {
|
||||
RestoreFileLogger logger(log_directory);
|
||||
std::string msg = "This message is added to throw %s and %s";
|
||||
std::string msg3 = "This message is added to throw message and log";
|
||||
std::string arg1 = "message";
|
||||
std::string arg3 = "log";
|
||||
|
||||
@ -477,25 +476,19 @@ TEST(CHECK_F_Test, CHECK_F__thisWILL_PrintErrorMsg) {
|
||||
|
||||
TEST(CHECK_Test, CHECK__thisWILL_PrintErrorMsg) {
|
||||
RestoreFileLogger logger(log_directory);
|
||||
std::string msg = "This message is added to throw %s and %s";
|
||||
std::string msg3 = "This message is added to throw message and log";
|
||||
std::string arg1 = "message";
|
||||
std::string arg3 = "log";
|
||||
CHECK(1 >= 2) << msg3;
|
||||
std::string msg = "This message is added to throw message and log";
|
||||
CHECK(1 >= 2) << msg;
|
||||
|
||||
logger.reset();
|
||||
std::string file_content = readFileToText(logger.logFile());
|
||||
EXPECT_TRUE(verifyContent(mockFatalMessage(), "EXIT trigger caused by "));
|
||||
EXPECT_TRUE(verifyContent(file_content, "CONTRACT"));
|
||||
EXPECT_TRUE(verifyContent(file_content, msg3));
|
||||
EXPECT_TRUE(verifyContent(file_content, msg));
|
||||
}
|
||||
TEST(CHECK, CHECK_ThatWontThrow) {
|
||||
RestoreFileLogger logger(log_directory);
|
||||
std::string msg = "This %s should never appear in the %s";
|
||||
std::string msg3 = "This message should never appear in the log";
|
||||
std::string arg1 = "message";
|
||||
std::string arg3 = "log";
|
||||
|
||||
CHECK(1 == 1);
|
||||
CHECK_F(1 == 1, msg.c_str(), "message", "log");
|
||||
logger.reset();
|
||||
@ -662,7 +655,6 @@ TEST(DynamicLogging, DynamicLogging_No_Logs_If_Disabled) {
|
||||
|
||||
std::string msg_debugOn = "This %s SHOULD appear in the %s";
|
||||
std::string msg_debugOff = "This message should never appear in the log";
|
||||
std::string msg_info1 = "This info msg log";
|
||||
try {
|
||||
{
|
||||
RestoreFileLogger logger(log_directory);
|
||||
@ -681,8 +673,7 @@ TEST(DynamicLogging, DynamicLogging_No_Logs_If_Disabled) {
|
||||
}
|
||||
|
||||
} catch (std::exception const& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
ADD_FAILURE() << "Should never have thrown";
|
||||
ADD_FAILURE() << "Should never have thrown: " << e.what();
|
||||
}
|
||||
}
|
||||
TEST(DynamicLogging, DynamicLogging_No_Fatal_If_Disabled) {
|
||||
|
@ -75,6 +75,7 @@ namespace testing_helpers {
|
||||
std::ostringstream oss;
|
||||
oss << in.rdbuf();
|
||||
return oss.str();
|
||||
// RAII of std::ifstream will automatically close the file
|
||||
}
|
||||
|
||||
size_t LogFileCleaner::size() {
|
||||
|
Loading…
Reference in New Issue
Block a user