Lines Matching defs:MAX_LEN
135 StringTestState(size_t MAX_LEN) : MAX_LEN(MAX_LEN) {
138 // TODO: fix the tests to not sometimes use twice their specified "MAX_LEN".
139 glob_ptr = reinterpret_cast<char*>(valloc(2 * MAX_LEN + max_alignment));
140 glob_ptr1 = reinterpret_cast<char*>(valloc(2 * MAX_LEN + max_alignment));
141 glob_ptr2 = reinterpret_cast<char*>(valloc(2 * MAX_LEN + max_alignment));
165 const size_t MAX_LEN;
175 // smallest (0) and biggest (MAX_LEN) lengths. Avoid repeats.
181 int l = (int) exp(log((double) MAX_LEN) * i / ITER);
186 len[n++] = MAX_LEN;
196 memset(state.ptr2, '\2', state.MAX_LEN);
197 state.ptr2[state.MAX_LEN - 1] = '\0';
198 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN);
204 strcpy(state.ptr + state.MAX_LEN - 1, state.ptr1);
207 EXPECT_TRUE(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN) == 0);
227 int pos = random() % state.MAX_LEN;
251 memset(state.ptr1, 'v', state.MAX_LEN);
252 memset(state.ptr2, 'n', state.MAX_LEN);
256 int pos = 1 + (random() % (state.MAX_LEN - 1));
287 size_t pos = random() % state.MAX_LEN;
291 state.ptr1[state.MAX_LEN - 1] = '\0';
293 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
295 memset(state.ptr2, '\1', state.MAX_LEN);
296 state.ptr2[state.MAX_LEN - 1] = '\0';
298 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN);
299 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
300 state.ptr[2 * state.MAX_LEN - 1] = '\0';
303 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN)) != 0 ||
304 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
349 memset(state.ptr2, '\2', state.MAX_LEN + state.len[i]);
350 state.ptr2[state.MAX_LEN - 1] = '\0';
351 memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]);
353 int pos = random() % state.MAX_LEN;
357 memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, pos + 1);
359 memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, state.len[i]);
360 state.ptr[state.MAX_LEN + state.len[i] - 1] = '\0';
363 strlcat(state.ptr2, state.ptr1, state.MAX_LEN + state.len[i]);
365 ASSERT_TRUE(memcmp(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]) == 0);
381 memset(state.ptr1, rand, state.MAX_LEN);
383 size_t pos = random() % state.MAX_LEN;
384 if (pos < state.MAX_LEN) {
387 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
389 memset(state.ptr2, random() & 255, state.MAX_LEN);
390 memcpy(state.ptr + state.MAX_LEN, state.ptr2, state.MAX_LEN);
392 if (pos > state.MAX_LEN - 1) {
393 memcpy(state.ptr + state.MAX_LEN, state.ptr1, state.MAX_LEN);
394 state.ptr[2 * state.MAX_LEN - 1] = '\0';
396 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
399 ASSERT_EQ(strlcpy(state.ptr2, state.ptr1, state.MAX_LEN), strlen(state.ptr1));
400 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0) ||
401 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
412 memset(state.ptr2, '\2', state.MAX_LEN);
413 state.ptr2[state.MAX_LEN - 1] = '\0';
414 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN);
423 strncpy(state.ptr + state.MAX_LEN - 1, state.ptr1, std::min(actual, pos));
424 state.ptr[state.MAX_LEN + std::min(actual, pos) - 1] = '\0';
427 ASSERT_EQ(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN), 0);
438 memset(state.ptr1, 'v', state.MAX_LEN);
439 memset(state.ptr2, 'n', state.MAX_LEN);
443 int pos = 1 + (random() % (state.MAX_LEN - 1));
474 memset(state.ptr1, random() & 255, state.MAX_LEN);
475 state.ptr1[random () % state.MAX_LEN] = '\0';
476 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
478 memset(state.ptr2, '\1', state.MAX_LEN);
481 if (memchr(state.ptr1, 0, state.MAX_LEN)) {
484 pos = state.MAX_LEN - 1;
487 memset(state.ptr + state.MAX_LEN, '\0', state.MAX_LEN);
488 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
490 ASSERT_TRUE(strncpy(state.ptr2, state.ptr1, state.MAX_LEN) == state.ptr2);
491 ASSERT_FALSE(memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0 ||
492 memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0);
510 int pos = random() % state.MAX_LEN;
537 int pos = random() % state.MAX_LEN;
560 int pos = random() % state.MAX_LEN;
582 memset(state.ptr1, c1, state.MAX_LEN);
583 memset(state.ptr2, c1, state.MAX_LEN);
589 int actual = memcmp(state.ptr1, state.ptr2, state.MAX_LEN);
603 size_t pos = random() % (state.MAX_LEN - state.len[i]);
606 memset(state.ptr1 + state.len[i], ~rand, state.MAX_LEN - state.len[i]);
609 memset(state.ptr2 + state.len[i], ~rand, state.MAX_LEN - state.len[i]);
613 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
625 memset(state.ptr1, ~ch, state.MAX_LEN);
626 memcpy(state.ptr2, state.ptr1, state.MAX_LEN);
628 size_t pos = random () % (state.MAX_LEN - state.len[i]);
635 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
646 memset(state.ptr1, random() & 255, 2 * state.MAX_LEN);
648 size_t pos = random() % (state.MAX_LEN - state.len[i]);
651 memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN);
656 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr1, 2 * state.MAX_LEN));
667 memset(state.ptr1, random() & 255, state.MAX_LEN);
668 memset(state.ptr1 + state.MAX_LEN, random() & 255, state.MAX_LEN);
669 memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN);
671 size_t start = random() % (2 * state.MAX_LEN - state.len[i]);
675 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, 2 * state.MAX_LEN));
685 memset(state.ptr1, random() & 255, state.MAX_LEN);
687 size_t start = random() % state.MAX_LEN;
688 size_t end = start + random() % (state.MAX_LEN - start);
692 memcpy(state.ptr2 + end, state.ptr1 + end, state.MAX_LEN - end);
696 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));