mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
* Refine AUTHORS.txt to AUTHORS.md, etc. 5.0.8 * Update README.md * Update README.md * Refine format for AUTHORS.md
76 lines
1.5 KiB
C++
76 lines
1.5 KiB
C++
//
|
|
// Copyright (c) 2013-2021 The SRS Authors
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
//
|
|
#include <srs_utest_core.hpp>
|
|
|
|
using namespace std;
|
|
|
|
#include <srs_core_autofree.hpp>
|
|
|
|
VOID TEST(CoreAutoFreeTest, Free)
|
|
{
|
|
char* data = new char[32];
|
|
srs_freepa(data);
|
|
EXPECT_TRUE(data == NULL);
|
|
|
|
if (true) {
|
|
data = new char[32];
|
|
SrsAutoFreeA(char, data);
|
|
}
|
|
EXPECT_TRUE(data == NULL);
|
|
}
|
|
|
|
VOID TEST(CoreMacroseTest, Check)
|
|
{
|
|
#ifndef SRS_BUILD_TS
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
#ifndef SRS_BUILD_DATE
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
#ifndef SRS_UNAME
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
#ifndef SRS_USER_CONFIGURE
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
#ifndef SRS_CONFIGURE
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
#ifndef SRS_PREFIX
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
#ifndef SRS_CONSTRIBUTORS
|
|
EXPECT_TRUE(false);
|
|
#endif
|
|
}
|
|
|
|
VOID TEST(CoreLogger, CheckVsnprintf)
|
|
{
|
|
if (true) {
|
|
char buf[1024];
|
|
HELPER_ARRAY_INIT(buf, sizeof(buf), 0xf);
|
|
|
|
// Return the number of characters printed.
|
|
EXPECT_EQ(6, sprintf(buf, "%s", "Hello!"));
|
|
EXPECT_EQ('H', buf[0]);
|
|
EXPECT_EQ('!', buf[5]);
|
|
EXPECT_EQ(0x0, buf[6]);
|
|
EXPECT_EQ(0xf, buf[7]);
|
|
}
|
|
|
|
if (true) {
|
|
char buf[1024];
|
|
HELPER_ARRAY_INIT(buf, sizeof(buf), 0xf);
|
|
|
|
// Return the number of characters that would have been printed if the size were unlimited.
|
|
EXPECT_EQ(6, snprintf(buf, 3, "%s", "Hello!"));
|
|
EXPECT_EQ('H', buf[0]);
|
|
EXPECT_EQ('e', buf[1]);
|
|
EXPECT_EQ(0, buf[2]);
|
|
EXPECT_EQ(0xf, buf[3]);
|
|
}
|
|
}
|
|
|