pExpected is NULL if an error is expected
| 8 | |
| 9 | // pExpected is NULL if an error is expected |
| 10 | static 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 | |
| 32 | static void ExpectAddInt(int Input, int Expected) |
| 33 | { |