CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Common/tests/test_expandingstring.cpp
Views: 1799
1
#include <AP_gtest.h>
2
#include <AP_Common/ExpandingString.h>
3
#include <AP_HAL/AP_HAL.h>
4
5
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
6
7
TEST(ExpandingString, Tests)
8
{
9
ExpandingString *test_string = NEW_NOTHROW ExpandingString();
10
test_string->printf("Test\n");
11
EXPECT_STREQ("Test\n", test_string->get_string());
12
EXPECT_STREQ("Test\n", test_string->get_writeable_string());
13
EXPECT_EQ(5u, test_string->get_length());
14
EXPECT_FALSE(test_string->has_failed_allocation());
15
EXPECT_TRUE(test_string->append("Test2\n", 6));
16
test_string->~ExpandingString();
17
EXPECT_STRNE("Test\n", test_string->get_string());
18
test_string = NEW_NOTHROW ExpandingString();
19
char long_string[2048];
20
std::fill(std::begin(long_string),std::end(long_string),'a');
21
test_string->printf("%s", long_string);
22
}
23
24
AP_GTEST_MAIN()
25
26