1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

Merge branch '3.0release' into develop

This commit is contained in:
winlin 2019-10-22 08:54:56 +08:00
commit cd208bcc33
3 changed files with 72 additions and 2 deletions

View file

@ -27,7 +27,7 @@
// The version config.
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION 60
#define VERSION_REVISION 62
// The macros generated by configure script.
#include <srs_auto_headers.hpp>

View file

@ -1585,7 +1585,7 @@ string SrsJsonAny::dumps()
case SRS_JSON_Number: {
// len(max int64_t) is 20, plus one "+-."
char tmp[22];
snprintf(tmp, 22, "%.6f", to_number());
snprintf(tmp, 22, "%.2f", to_number());
return tmp;
}
case SRS_JSON_Null: {

View file

@ -2493,3 +2493,73 @@ VOID TEST(ProtocolAMF0Test, Amf0Object2)
}
}
VOID TEST(ProtocolJSONTest, Interfaces)
{
if (true) {
SrsJsonAny* p = SrsJsonAny::str();
EXPECT_TRUE(p->is_string());
EXPECT_TRUE(p->to_str().empty());
srs_freep(p);
}
if (true) {
SrsJsonAny* p = SrsJsonAny::str("hello");
EXPECT_TRUE(p->is_string());
EXPECT_TRUE(string("hello") == p->to_str());
srs_freep(p);
}
if (true) {
SrsJsonAny* p = SrsJsonAny::str("hello", 2);
EXPECT_TRUE(p->is_string());
EXPECT_TRUE(string("he") == p->to_str());
srs_freep(p);
}
}
VOID TEST(ProtocolJSONTest, Dumps)
{
if (true) {
SrsJsonAny* p = SrsJsonAny::str("hello");
EXPECT_TRUE(p->is_string());
EXPECT_STREQ("\"hello\"", p->dumps().c_str());
srs_freep(p);
}
if (true) {
SrsJsonAny* p = SrsJsonAny::boolean(true);
EXPECT_STREQ("true", p->dumps().c_str());
srs_freep(p);
}
if (true) {
SrsJsonAny* p = SrsJsonAny::integer(3);
EXPECT_STREQ("3", p->dumps().c_str());
srs_freep(p);
}
if (true) {
SrsJsonAny* p = SrsJsonAny::number(3.1);
EXPECT_STREQ("3.10", p->dumps().c_str());
srs_freep(p);
}
if (true) {
SrsJsonAny* p = SrsJsonAny::null();
EXPECT_STREQ("null", p->dumps().c_str());
srs_freep(p);
}
if (true) {
SrsJsonObject* p = SrsJsonAny::object();
EXPECT_STREQ("{}", p->dumps().c_str());
srs_freep(p);
}
if (true) {
SrsJsonArray* p = SrsJsonAny::array();
EXPECT_STREQ("[]", p->dumps().c_str());
srs_freep(p);
}
}