mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Log: Refine log context.
This commit is contained in:
parent
d68b6b8609
commit
0a16b1c1e3
3 changed files with 51 additions and 0 deletions
|
@ -37,6 +37,12 @@ _SrsContextId::_SrsContextId(const _SrsContextId& cp)
|
|||
v_ = cp.v_;
|
||||
}
|
||||
|
||||
_SrsContextId& _SrsContextId::operator=(const _SrsContextId& cp)
|
||||
{
|
||||
v_ = cp.v_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_SrsContextId::~_SrsContextId()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ public:
|
|||
_SrsContextId();
|
||||
_SrsContextId(std::string v);
|
||||
_SrsContextId(const _SrsContextId& cp);
|
||||
_SrsContextId& operator=(const _SrsContextId& cp);
|
||||
virtual ~_SrsContextId();
|
||||
public:
|
||||
const char* c_str() const;
|
||||
|
|
|
@ -137,3 +137,47 @@ VOID TEST(SampleTest, StringEQTest)
|
|||
EXPECT_STREQ("100", str.c_str());
|
||||
}
|
||||
|
||||
class MockSrsContextId
|
||||
{
|
||||
public:
|
||||
MockSrsContextId() {
|
||||
bind_ = NULL;
|
||||
}
|
||||
MockSrsContextId(const MockSrsContextId& cp){
|
||||
bind_ = NULL;
|
||||
if (cp.bind_) {
|
||||
bind_ = cp.bind_->copy();
|
||||
}
|
||||
}
|
||||
MockSrsContextId& operator= (const MockSrsContextId& cp) {
|
||||
srs_freep(bind_);
|
||||
if (cp.bind_) {
|
||||
bind_ = cp.bind_->copy();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
virtual ~MockSrsContextId() {
|
||||
srs_freep(bind_);
|
||||
}
|
||||
public:
|
||||
MockSrsContextId* copy() const {
|
||||
MockSrsContextId* cp = new MockSrsContextId();
|
||||
if (bind_) {
|
||||
cp->bind_ = bind_->copy();
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
private:
|
||||
MockSrsContextId* bind_;
|
||||
};
|
||||
|
||||
VOID TEST(SampleTest, ContextTest)
|
||||
{
|
||||
MockSrsContextId cid;
|
||||
cid.bind_ = new MockSrsContextId();
|
||||
|
||||
static std::map<int, MockSrsContextId> cache;
|
||||
cache[0] = cid;
|
||||
cache[0] = cid;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue