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:
commit
cd208bcc33
3 changed files with 72 additions and 2 deletions
|
@ -27,7 +27,7 @@
|
||||||
// The version config.
|
// The version config.
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 60
|
#define VERSION_REVISION 62
|
||||||
|
|
||||||
// The macros generated by configure script.
|
// The macros generated by configure script.
|
||||||
#include <srs_auto_headers.hpp>
|
#include <srs_auto_headers.hpp>
|
||||||
|
|
|
@ -1585,7 +1585,7 @@ string SrsJsonAny::dumps()
|
||||||
case SRS_JSON_Number: {
|
case SRS_JSON_Number: {
|
||||||
// len(max int64_t) is 20, plus one "+-."
|
// len(max int64_t) is 20, plus one "+-."
|
||||||
char tmp[22];
|
char tmp[22];
|
||||||
snprintf(tmp, 22, "%.6f", to_number());
|
snprintf(tmp, 22, "%.2f", to_number());
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
case SRS_JSON_Null: {
|
case SRS_JSON_Null: {
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue