Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-07-05 17:50:36 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b13fd5112b8cea7062c0090cfdf13756f6b62275
b13fd511
1 parent
1e395e7c
merge buffer to kernel utest
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
117 行增加
和
180 行删除
trunk/configure
trunk/src/srs/srs.upp
trunk/src/utest/srs_utest_buffer.cpp
trunk/src/utest/srs_utest_buffer.hpp
trunk/src/utest/srs_utest_kernel.cpp
trunk/src/utest/srs_utest_kernel.hpp
trunk/configure
查看文件 @
b13fd51
...
...
@@ -517,8 +517,7 @@ fi
#
# utest, the unit-test cases of srs, base on gtest1.6
MODULE_FILES
=(
"srs_utest"
"srs_utest_amf0"
"srs_utest_handshake"
"srs_utest_buffer"
"srs_utest_protocol"
"srs_utest_kernel"
"srs_utest_core"
)
"srs_utest_protocol"
"srs_utest_kernel"
"srs_utest_core"
)
ModuleLibIncs
=(
${
SRS_OBJS
}
${
LibSTRoot
}
)
ModuleLibFiles
=(
${
LibSTfile
}
${
LibHttpParserfile
}
${
LibSSLfile
}
)
MODULE_DEPENDS
=(
"CORE"
"KERNEL"
"RTMP"
"APP"
)
...
...
trunk/src/srs/srs.upp
查看文件 @
b13fd51
...
...
@@ -114,8 +114,6 @@ file
..\utest\srs_utest.cpp,
..\utest\srs_utest_amf0.hpp,
..\utest\srs_utest_amf0.cpp,
..\utest\srs_utest_buffer.hpp,
..\utest\srs_utest_buffer.cpp,
..\utest\srs_utest_core.hpp,
..\utest\srs_utest_core.cpp,
..\utest\srs_utest_handshake.hpp,
...
...
trunk/src/utest/srs_utest_buffer.cpp
已删除
100644 → 0
查看文件 @
1e395e7
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_buffer.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_utility.hpp>
MockBufferReader
::
MockBufferReader
(
const
char
*
data
)
{
str
=
data
;
}
MockBufferReader
::~
MockBufferReader
()
{
}
int
MockBufferReader
::
read
(
void
*
buf
,
size_t
size
,
ssize_t
*
nread
)
{
int
len
=
srs_min
(
str
.
length
(),
size
);
memcpy
(
buf
,
str
.
data
(),
len
);
if
(
nread
)
{
*
nread
=
len
;
}
return
ERROR_SUCCESS
;
}
VOID
TEST
(
BufferTest
,
DefaultObject
)
{
SrsBuffer
b
;
EXPECT_EQ
(
0
,
b
.
length
());
EXPECT_EQ
(
NULL
,
b
.
bytes
());
}
VOID
TEST
(
BufferTest
,
AppendBytes
)
{
SrsBuffer
b
;
char
winlin
[]
=
"winlin"
;
b
.
append
(
winlin
,
strlen
(
winlin
));
EXPECT_EQ
((
int
)
strlen
(
winlin
),
b
.
length
());
ASSERT_TRUE
(
NULL
!=
b
.
bytes
());
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
0
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
5
]);
b
.
append
(
winlin
,
strlen
(
winlin
));
EXPECT_EQ
(
2
*
(
int
)
strlen
(
winlin
),
b
.
length
());
ASSERT_TRUE
(
NULL
!=
b
.
bytes
());
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
0
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
5
]);
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
6
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
11
]);
}
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
());
}
VOID
TEST
(
BufferTest
,
Grow
)
{
SrsBuffer
b
;
MockBufferReader
r
(
"winlin"
);
b
.
grow
(
&
r
,
1
);
EXPECT_EQ
(
6
,
b
.
length
());
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
0
]);
b
.
grow
(
&
r
,
3
);
EXPECT_EQ
(
6
,
b
.
length
());
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
2
]);
b
.
grow
(
&
r
,
100
);
EXPECT_EQ
(
102
,
b
.
length
());
EXPECT_EQ
(
'l'
,
b
.
bytes
()[
99
]);
}
trunk/src/utest/srs_utest_buffer.hpp
已删除
100644 → 0
查看文件 @
1e395e7
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_UTEST_BUFFER_HPP
#define SRS_UTEST_BUFFER_HPP
/*
#include <srs_utest_buffer.hpp>
*/
#include <srs_utest.hpp>
#include <string>
#include <srs_kernel_buffer.hpp>
class
MockBufferReader
:
public
ISrsBufferReader
{
private
:
std
::
string
str
;
public
:
MockBufferReader
(
const
char
*
data
);
virtual
~
MockBufferReader
();
public
:
virtual
int
read
(
void
*
buf
,
size_t
size
,
ssize_t
*
nread
);
};
#endif
trunk/src/utest/srs_utest_kernel.cpp
查看文件 @
b13fd51
...
...
@@ -176,6 +176,110 @@ void MockSrsFileReader::mock_reset_offset()
offset
=
0
;
}
MockBufferReader
::
MockBufferReader
(
const
char
*
data
)
{
str
=
data
;
}
MockBufferReader
::~
MockBufferReader
()
{
}
int
MockBufferReader
::
read
(
void
*
buf
,
size_t
size
,
ssize_t
*
nread
)
{
int
len
=
srs_min
(
str
.
length
(),
size
);
memcpy
(
buf
,
str
.
data
(),
len
);
if
(
nread
)
{
*
nread
=
len
;
}
return
ERROR_SUCCESS
;
}
VOID
TEST
(
BufferTest
,
DefaultObject
)
{
SrsBuffer
b
;
EXPECT_EQ
(
0
,
b
.
length
());
EXPECT_EQ
(
NULL
,
b
.
bytes
());
}
VOID
TEST
(
BufferTest
,
AppendBytes
)
{
SrsBuffer
b
;
char
winlin
[]
=
"winlin"
;
b
.
append
(
winlin
,
strlen
(
winlin
));
EXPECT_EQ
((
int
)
strlen
(
winlin
),
b
.
length
());
ASSERT_TRUE
(
NULL
!=
b
.
bytes
());
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
0
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
5
]);
b
.
append
(
winlin
,
strlen
(
winlin
));
EXPECT_EQ
(
2
*
(
int
)
strlen
(
winlin
),
b
.
length
());
ASSERT_TRUE
(
NULL
!=
b
.
bytes
());
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
0
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
5
]);
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
6
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
11
]);
}
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
());
}
VOID
TEST
(
BufferTest
,
Grow
)
{
SrsBuffer
b
;
MockBufferReader
r
(
"winlin"
);
b
.
grow
(
&
r
,
1
);
EXPECT_EQ
(
6
,
b
.
length
());
EXPECT_EQ
(
'w'
,
b
.
bytes
()[
0
]);
b
.
grow
(
&
r
,
3
);
EXPECT_EQ
(
6
,
b
.
length
());
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
2
]);
b
.
grow
(
&
r
,
100
);
EXPECT_EQ
(
102
,
b
.
length
());
EXPECT_EQ
(
'l'
,
b
.
bytes
()[
99
]);
}
/**
* test the codec,
* whether H.264 keyframe
...
...
trunk/src/utest/srs_utest_kernel.hpp
查看文件 @
b13fd51
...
...
@@ -31,6 +31,18 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <srs_kernel_file.hpp>
#include <srs_kernel_buffer.hpp>
class
MockBufferReader
:
public
ISrsBufferReader
{
private
:
std
::
string
str
;
public
:
MockBufferReader
(
const
char
*
data
);
virtual
~
MockBufferReader
();
public
:
virtual
int
read
(
void
*
buf
,
size_t
size
,
ssize_t
*
nread
);
};
class
MockSrsFileWriter
:
public
SrsFileWriter
{
...
...
请
注册
或
登录
后发表评论