MCPcopy Create free account
hub / github.com/catboost/catboost / CheckConvertToBuffer

Function CheckConvertToBuffer

util/string/cast_ut.cpp:129–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127#if 0
128template <class T>
129inline void CheckConvertToBuffer(const T& value, const size_t size, const TString& canonValue) {
130 const size_t maxSize = 256;
131 char buffer[maxSize];
132 const char magic = 0x7F;
133 memset(buffer, magic, maxSize);
134 size_t length = 0;
135 if (canonValue.size() > size) { // overflow will occur
136 UNIT_ASSERT_EXCEPTION(length = ToString(value, buffer, size), yexception);
137 // check that no bytes after size was trashed
138 for (size_t i = size; i < maxSize; ++i)
139 UNIT_ASSERT_VALUES_EQUAL(buffer[i], magic);
140 } else {
141 length = ToString(value, buffer, size);
142 UNIT_ASSERT(length < maxSize);
143 // check that no bytes after length was trashed
144 for (size_t i = length; i < maxSize; ++i)
145 UNIT_ASSERT_VALUES_EQUAL(buffer[i], magic);
146 TStringBuf result(buffer, length);
147 UNIT_ASSERT_VALUES_EQUAL(result, TStringBuf(canonValue));
148 }
149}
150#endif
151
152Y_UNIT_TEST_SUITE(TCastTest) {

Callers

nothing calls this directly

Calls 2

ToStringFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected