mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
amf0 utest: finish utest for string to any
This commit is contained in:
parent
cae8228b09
commit
4a0023ae63
2 changed files with 27 additions and 0 deletions
|
@ -60,6 +60,10 @@ public:
|
||||||
virtual bool is_object_eof();
|
virtual bool is_object_eof();
|
||||||
virtual bool is_ecma_array();
|
virtual bool is_ecma_array();
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* get the string of any when is_string() indicates true.
|
||||||
|
* user must ensure the type is a string, or assert failed.
|
||||||
|
*/
|
||||||
virtual std::string to_str();
|
virtual std::string to_str();
|
||||||
public:
|
public:
|
||||||
virtual int size() = 0;
|
virtual int size() = 0;
|
||||||
|
|
|
@ -22,6 +22,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <srs_utest_amf0.hpp>
|
#include <srs_utest_amf0.hpp>
|
||||||
|
|
||||||
|
#include <srs_core_autofree.hpp>
|
||||||
|
|
||||||
VOID TEST(AMF0Test, Size)
|
VOID TEST(AMF0Test, Size)
|
||||||
{
|
{
|
||||||
// size of elem
|
// size of elem
|
||||||
|
@ -259,3 +261,24 @@ VOID TEST(AMF0Test, Size)
|
||||||
EXPECT_EQ(size, SrsAmf0Size::array(&o));
|
EXPECT_EQ(size, SrsAmf0Size::array(&o));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID TEST(AMF0Test, AnyElem)
|
||||||
|
{
|
||||||
|
SrsAmf0Any* o = NULL;
|
||||||
|
|
||||||
|
// string
|
||||||
|
if (true) {
|
||||||
|
o = SrsAmf0Any::str();
|
||||||
|
SrsAutoFree(SrsAmf0Any, o, false);
|
||||||
|
EXPECT_TRUE(NULL != o);
|
||||||
|
EXPECT_TRUE(o->is_string());
|
||||||
|
EXPECT_STREQ("", o->to_str().c_str());
|
||||||
|
}
|
||||||
|
if (true) {
|
||||||
|
o = SrsAmf0Any::str("winlin");
|
||||||
|
SrsAutoFree(SrsAmf0Any, o, false);
|
||||||
|
EXPECT_TRUE(NULL != o);
|
||||||
|
EXPECT_TRUE(o->is_string());
|
||||||
|
EXPECT_STREQ("winlin", o->to_str().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue