mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix bug of buffer assert, erase can accept any value
This commit is contained in:
parent
d48d739fa7
commit
a639eb0596
4 changed files with 29 additions and 12 deletions
|
@ -79,20 +79,34 @@ VOID TEST(BufferTest, EraseBytes)
|
|||
{
|
||||
SrsBuffer b;
|
||||
|
||||
b.erase(0);
|
||||
b.erase(-1);
|
||||
EXPECT_EQ(0, b.length());
|
||||
|
||||
char winlin[] = "winlin";
|
||||
b.append(winlin, strlen(winlin));
|
||||
b.erase(b.length());
|
||||
EXPECT_EQ(0, b.length());
|
||||
|
||||
b.erase(0);
|
||||
b.erase(-1);
|
||||
EXPECT_EQ(0, b.length());
|
||||
|
||||
b.append(winlin, strlen(winlin));
|
||||
b.erase(1);
|
||||
EXPECT_EQ(5, b.length());
|
||||
EXPECT_EQ('i', b.bytes()[0]);
|
||||
EXPECT_EQ('n', b.bytes()[4]);
|
||||
|
||||
b.erase(2);
|
||||
EXPECT_EQ(3, b.length());
|
||||
EXPECT_EQ('l', b.bytes()[0]);
|
||||
EXPECT_EQ('n', b.bytes()[2]);
|
||||
|
||||
b.erase(0);
|
||||
b.erase(-1);
|
||||
EXPECT_EQ(3, b.length());
|
||||
|
||||
b.erase(3);
|
||||
EXPECT_EQ(0, b.length());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue