MCPcopy Create free account
hub / github.com/ddnet/ddnet / ExpectAddString5

Function ExpectAddString5

src/test/packer_test.cpp:10–30  ·  view source on GitHub ↗

pExpected is NULL if an error is expected

Source from the content-addressed store, hash-verified

8
9// pExpected is NULL if an error is expected
10static void ExpectAddString5(const char *pString, int Limit, bool AllowTruncation, const char *pExpected)
11{
12 static char ZEROS[CPacker::PACKER_BUFFER_SIZE] = {0};
13 static const int OFFSET = CPacker::PACKER_BUFFER_SIZE - 5;
14 CPacker Packer;
15 Packer.Reset();
16 Packer.AddRaw(ZEROS, OFFSET);
17 Packer.AddString(pString, Limit, AllowTruncation);
18
19 EXPECT_EQ(pExpected == 0, Packer.Error()) << "for String='" << pString << "', Limit='" << Limit << "', AllowTruncation='" << AllowTruncation << "'";
20 if(pExpected)
21 {
22 // Include null termination.
23 int ExpectedLength = str_length(pExpected) + 1;
24 EXPECT_EQ(ExpectedLength, Packer.Size() - OFFSET) << "for String='" << pString << "', Limit='" << Limit << "', AllowTruncation='" << AllowTruncation << "'";
25 if(ExpectedLength == Packer.Size() - OFFSET)
26 {
27 EXPECT_STREQ(pExpected, (const char *)Packer.Data() + OFFSET) << "for String='" << pString << "', Limit='" << Limit << "', AllowTruncation='" << AllowTruncation << "'";
28 }
29 }
30}
31
32static void ExpectAddInt(int Input, int Expected)
33{

Callers 1

TESTFunction · 0.85

Calls 7

str_lengthFunction · 0.85
AddRawMethod · 0.80
ResetMethod · 0.45
AddStringMethod · 0.45
ErrorMethod · 0.45
SizeMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected