MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / TestMbToDb

Function TestMbToDb

src/twtest/codeconvert_t.cpp:166–218  ·  view source on GitHub ↗

mbchar_t to dbchar_t TestMbToDb in codeconvert_t.cpp seems to hit an infinite loop or runs verrrry long; ifdef'd"

Source from the content-addressed store, hash-verified

164// mbchar_t to dbchar_t
165//TestMbToDb in codeconvert_t.cpp seems to hit an infinite loop or runs verrrry long; ifdef'd"
166void TestMbToDb()
167{
168 skip("This test is flaky & needs to be fixed/replaced; currently disabled.");
169
170#if 0
171 std::string s;
172 s.resize( 0x10000 * 2 ); // two bytes for each combination
173
174 for( size_t i = 0; i < 0x1000; i++ )
175 {
176 for( size_t j = 0; j < 0x10; j++ )
177 {
178 size_t first_byte = ( i & 0xFF00 ) >> 8;
179 TEST( first_byte <= 0xFF );
180
181 size_t second_byte = ( ( i & 0x00F0 ) >> 4 ) | j;
182 TEST( second_byte <= 0xFF );
183
184 s[ 2 * j ] = NonZeroChar( (char)first_byte );
185 s[ ( 2 * j ) + 1 ] = NonZeroChar( (char)second_byte );
186 }
187
188 ConvertAndCompareString( s );
189 }
190#endif
191 /*
192 const std::string::size_type TOTAL_VALUE_COMBINATIONS = 0x10000; // 0x100 ^ 2 (256 possible per byte, and two bytes) (must always be this value)
193 const std::string::size_type CHARS_AT_A_TIME = 0x10; // can change this, but needs to be a power of 2
194 const std::string::size_type FIRST_BYTE_MASK = TOTAL_VALUE_COMBINATIONS - CHARS_AT_A_TIME;
195 const std::string::size_type SECOND_BYTE_MASK = CHARS_AT_A_TIME - 1;
196
197 std::string s;
198 s.resize( CHARS_AT_A_TIME * 2 ); // two bytes for each combination
199
200 for( size_t i = 0; i < TOTAL_VALUE_COMBINATIONS / CHARS_AT_A_TIME; i++ )
201 {
202 for( size_t j = 0; j < CHARS_AT_A_TIME; j++ )
203 {
204 size_t first_byte = ( ( i & FIRST_BYTE_MASK ) >> DistanceToOne( CHARS_AT_A_TIME ) );
205 TEST( first_byte <= 0xFF );
206
207 size_t second_byte = ( ( i & ( SECOND_BYTE_MASK << DistanceToOne( CHARS_AT_A_TIME ) ) | j );
208 TEST( second_byte <= 0xFF );
209
210 s[ 2 * j ] = NonZeroChar( (char)first_byte );
211 s[ ( 2 * j ) + 1 ] = NonZeroChar( (char)second_byte );
212 }
213
214 ConvertAndCompareString( s );
215 }
216
217 */
218}
219
220
221// dbchar_t to mbchar_t

Callers 1

TestCodeConverterFunction · 0.85

Calls 4

skipFunction · 0.85
NonZeroCharFunction · 0.85
ConvertAndCompareStringFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected