-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
161 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
verbose: -crc -sys -load -db -parse +task; | ||
verbose: | ||
-crc | ||
-sys | ||
+db load | ||
-db | ||
-parse | ||
+task; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright © 2016 George Georgiev. All rights reserved. | ||
// | ||
|
||
#include "log/hex.h" | ||
#include "gtest/framework.h" | ||
#include <memory> | ||
#include <str> | ||
|
||
TEST(HexTest, simple) | ||
{ | ||
struct Test | ||
{ | ||
string input; | ||
string dump; | ||
}; | ||
|
||
const auto zero = string(5, 0); | ||
|
||
Test tests[]{ | ||
Test{.input = zero, .dump = "0000 : ..... 00 00 00 00 00 \n"}, | ||
Test{.input = "dumptest", | ||
.dump = "0000 : dumptest 64 75 6D 70 74 65 73 74 \n"}, | ||
Test{.input = "dumptestfullline", | ||
.dump = "0000 : dumptestfullline 64 75 6D 70 74 65 73 74 " | ||
" 66 75 6C 6C 6C 69 6E 65 \n"}, | ||
Test{.input = "dumptest2partiallines", | ||
.dump = "0000 : dumptest2partial 64 75 6D 70 74 65 73 74 " | ||
" 32 70 61 72 74 69 61 6C \n" | ||
"0010 : lines 6C 69 6E 65 73 \n"}, | ||
Test{.input = "\n\r\t\v\xff", | ||
.dump = "0000 : ..... 0A 0D 09 0B FF \n"}, | ||
}; | ||
|
||
for (const auto& test : tests) | ||
{ | ||
SCOPED_TRACE(::testing::Message() << "Input: \"" << test.input << "\""); | ||
const auto& result = dbslog::hexdump(test.input); | ||
EXPECT_EQ(test.dump, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright © 2016 George Georgiev. All rights reserved. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <sstream> | ||
#include <string> | ||
#include <string_view> | ||
|
||
namespace dbslog | ||
{ | ||
std::string hexdump(const string_view& array, | ||
std::size_t group = 8, | ||
std::size_t width = 16) | ||
{ | ||
const auto start = array.begin(); | ||
const auto end = array.end(); | ||
|
||
std::stringstream stream; | ||
|
||
auto line = start; | ||
while (line != end) | ||
{ | ||
stream.width(4); | ||
stream.fill('0'); | ||
stream << std::hex << line - start << " : "; | ||
std::size_t lineLength = std::min(width, static_cast<std::size_t>(end - line)); | ||
for (auto next = line; next != end && next != line + width; ++next) | ||
stream << (*next < 32 ? '.' : *next); | ||
|
||
stream << std::string(width - lineLength, ' '); | ||
stream << " "; | ||
|
||
std::size_t split = group; | ||
for (auto next = line; next != end && next != line + width; ++next) | ||
{ | ||
if (split-- == 0) | ||
{ | ||
split = group; | ||
stream << " "; | ||
} | ||
if (next != line) | ||
stream << " "; | ||
stream.width(2); | ||
stream.fill('0'); | ||
int byte = static_cast<unsigned int>(static_cast<unsigned char>(*next)); | ||
stream << std::hex << std::uppercase << byte; | ||
stream << " "; | ||
} | ||
stream << std::endl; | ||
line = line + lineLength; | ||
} | ||
|
||
return stream.str(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright © 2016 George Georgiev. All rights reserved. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <sstream> | ||
#include <string> | ||
#include <string_view> | ||
|
||
namespace dbslog | ||
{ | ||
std::string hexdump(const string_view& array, | ||
std::size_t group = 8, | ||
std::size_t width = 16); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,10 @@ | ||
// Copyright © 2016 George Georgiev. All rights reserved. | ||
// | ||
|
||
#include "log/log.h" | ||
#include "log/log_function.hpp" | ||
#include "logex/log.h" | ||
#include "gtest/framework.h" | ||
#include <memory> | ||
|
||
TEST(Log, basic) | ||
TEST(Logex, basic) | ||
{ | ||
dbslog::gLogger->info() << "test"; | ||
dbslog::gLogger->info("test"); | ||
} | ||
|
||
void foo() | ||
{ | ||
TLOG_FUNCTION; | ||
DLOG("test"); | ||
} | ||
void bar() | ||
{ | ||
TLOG_FUNCTION; | ||
foo(); | ||
} | ||
|
||
void baz() | ||
{ | ||
TLOG_FUNCTION; | ||
bar(); | ||
} | ||
|
||
TEST(Log, SLOW_LOG_FUNCTION) | ||
{ | ||
TLOG_FUNCTION; | ||
baz(); | ||
} |
Oops, something went wrong.