feat update
This commit is contained in:
parent
0529df0411
commit
c59e814eed
@ -102,6 +102,7 @@ target_include_directories(
|
|||||||
3party/mongoose
|
3party/mongoose
|
||||||
3party/nlohmann
|
3party/nlohmann
|
||||||
3party/nonstd
|
3party/nonstd
|
||||||
|
3party/nonstd/ulib
|
||||||
3party/sigslot
|
3party/sigslot
|
||||||
3party/rxcpp/Rx/v2/src
|
3party/rxcpp/Rx/v2/src
|
||||||
3party/rxcpp/Ix/CPP/src
|
3party/rxcpp/Ix/CPP/src
|
||||||
|
@ -57,4 +57,20 @@ Location::ToString() const
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Location
|
||||||
|
Location::Current(const char *function_name,
|
||||||
|
const char *file_name,
|
||||||
|
int line_number)
|
||||||
|
{
|
||||||
|
return Location(function_name, file_name, line_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
Location::Location(const char *function_name,
|
||||||
|
const char *file_name,
|
||||||
|
int line_number)
|
||||||
|
: function_name_(function_name),
|
||||||
|
file_name_(file_name + StrippedFilePathPrefixLength()),
|
||||||
|
line_number_(line_number)
|
||||||
|
{}
|
||||||
|
|
||||||
}// namespace ulib
|
}// namespace ulib
|
||||||
|
@ -24,6 +24,18 @@ public:
|
|||||||
const char *file_name = __builtin_FILE(),
|
const char *file_name = __builtin_FILE(),
|
||||||
int line_number = __builtin_LINE());
|
int line_number = __builtin_LINE());
|
||||||
|
|
||||||
|
bool operator==(const Location &other) const
|
||||||
|
{
|
||||||
|
return this->ToString() == other.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Location &other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
bool operator<(const Location &other) const
|
||||||
|
{
|
||||||
|
return this->ToString() < other.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Location(const char *function_name, const char *file_name, int line_number);
|
Location(const char *function_name, const char *file_name, int line_number);
|
||||||
const char *function_name_ = nullptr;
|
const char *function_name_ = nullptr;
|
||||||
|
@ -5,6 +5,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
|
|||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
ulib_test
|
ulib_test
|
||||||
|
ulib/base/location_unittest.cpp
|
||||||
ulib/base/types_unittest.cpp
|
ulib/base/types_unittest.cpp
|
||||||
ulib/log/log_unittest.cpp
|
ulib/log/log_unittest.cpp
|
||||||
ulib/concorrency/mutex_unittest.cpp
|
ulib/concorrency/mutex_unittest.cpp
|
||||||
|
19
tests/ulib/base/location_unittest.cpp
Normal file
19
tests/ulib/base/location_unittest.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <ulib/base/location.h>
|
||||||
|
|
||||||
|
ulib::Location
|
||||||
|
LocationTest(ulib::Location location = ULIB_FROM_HERE)
|
||||||
|
{
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Location, base)
|
||||||
|
{
|
||||||
|
auto l1 = LocationTest();
|
||||||
|
auto l2 = LocationTest();
|
||||||
|
EXPECT_NE(l1, l2);
|
||||||
|
|
||||||
|
EXPECT_EQ(l1.line_number() + 1, l2.line_number());
|
||||||
|
EXPECT_EQ(l1.function_name(), l2.function_name());
|
||||||
|
EXPECT_EQ(l1.file_name(), l2.file_name());
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user