• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ do_one_test函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中do_one_test函数的典型用法代码示例。如果您正苦于以下问题:C++ do_one_test函数的具体用法?C++ do_one_test怎么用?C++ do_one_test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了do_one_test函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int
main (void)
{
  size_t i;
  int ret = 0;

  mtrace ();

  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
    {
      if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
	{
	  puts ("setlocale de_DE.ISO-8859-1 failed");
	  ret = 1;
	}
      ret |= do_one_test (&tests[i], "");
      if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
	{
	  puts ("setlocale de_DE.UTF-8 failed");
	  ret = 1;
	}
      ret |= do_one_test (&tests[i], "UTF-8 ");
      ret |= do_mb_tests (&tests[i]);
    }

  return ret;
}
开发者ID:czankel,项目名称:xtensa-glibc,代码行数:27,代码来源:bug-regex19.c


示例2: do_test_limit

static void
do_test_limit (size_t align1, size_t align2, size_t len, size_t n, int max_char,
	 int exp_result)
{
  size_t i, align_n;
  char *s1, *s2;

  if (n == 0)
    {
      s1 = (char*)(buf1 + page_size);
      s2 = (char*)(buf2 + page_size);
      printf ("Length %d/%d:", len, n);

      FOR_EACH_IMPL (impl, 0)
	do_one_test (impl, s1, s2, n, 0);

      putchar ('\n');

      return;
    }

  align1 &= 15;
  align2 &= 15;
  align_n = (page_size - n) & 15;

  s1 = (char*)(buf1 + page_size - n);
  s2 = (char*)(buf2 + page_size - n);

  if (align1 < align_n)
    s1 -= (align_n - align1);

  if (align2 < align_n)
    s2 -= (align_n - align2);

  for (i = 0; i < n; i++)
    s1[i] = s2[i] = 1 + 23 * i % max_char;

  if (len < n)
    {
      s1[len] = 0;
      s2[len] = 0;
      if (exp_result < 0)
	s2[len] = 32;
      else if (exp_result > 0)
	s1[len] = 64;
    }

  printf ("Length %d/%d, alignment %d/%d:", len, n, align1, align2);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s1, s2, n, exp_result);

  putchar ('\n');
}
开发者ID:jiaojinxing,项目名称:benchtests,代码行数:54,代码来源:bench-strncmp.c


示例3: do_test

static void
do_test (size_t align1, size_t align2, size_t len, int max_char)
{
  size_t i;
  CHAR *s1, *s2;
/* For wcscpy: align1 and align2 here mean alignment not in bytes,
   but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t))
   len for wcschr here isn't in bytes but it's number of wchar_t symbols.  */
  align1 &= 7;
  if ((align1 + len) * sizeof(CHAR) >= page_size)
    return;

  align2 &= 7;
  if ((align2 + len) * sizeof(CHAR) >= page_size)
    return;

  s1 = (CHAR *) (buf1) + align1;
  s2 = (CHAR *) (buf2) + align2;

  for (i = 0; i < len; i++)
    s1[i] = 32 + 23 * i % (max_char - 32);
  s1[len] = 0;

  printf ("Length %4zd, alignments in bytes %2zd/%2zd:", len, align1 * sizeof(CHAR), align2 * sizeof(CHAR));

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s2, s1, len);

  putchar ('\n');
}
开发者ID:ddstreet,项目名称:glibc,代码行数:30,代码来源:bench-strcpy.c


示例4: do_test

static void
do_test (size_t align1, size_t align2, size_t len)
{
  size_t i, j;
  char *s1, *s2;

  align1 &= 63;
  if (align1 + len >= page_size)
    return;

  align2 &= 63;
  if (align2 + len >= page_size)
    return;

  s1 = (char *) (buf1 + align1);
  s2 = (char *) (buf2 + align2);

  for (i = 0, j = 1; i < len; i++, j += 23)
    s1[i] = j;

  printf ("Length %4zd, alignment %d/%d:", len, align1, align2);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s2, (char *) (buf2 + align1), s1, len);

  putchar ('\n');
}
开发者ID:jiaojinxing,项目名称:benchtests,代码行数:27,代码来源:bench-memmove.c


示例5: do_test

static void
do_test (size_t align1, size_t align2, size_t len, int exp_result)
{
    size_t i;
    CHAR *s1, *s2;

    if (len == 0)
        return;

    align1 &= 63;
    if (align1 + (len + 1) * CHARBYTES >= page_size)
        return;

    align2 &= 63;
    if (align2 + (len + 1) * CHARBYTES >= page_size)
        return;

    s1 = (CHAR *) (buf1 + align1);
    s2 = (CHAR *) (buf2 + align2);

    for (i = 0; i < len; i++)
        s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;

    s1[len] = align1;
    s2[len] = align2;
    s2[len - 1] -= exp_result;

    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);

    FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s1, s2, len, exp_result);

    putchar ('\n');
}
开发者ID:cmjonze,项目名称:eglibc_svn,代码行数:34,代码来源:bench-memcmp.c


示例6: do_random_tests

static void
do_random_tests (void)
{
  for (size_t n = 0; n < ITERATIONS; ++n)
    {
      char tmpbuf[32];

      size_t shift = random () % 11;
      size_t rel = random () % ((2 << (shift + 1)) * 64);
      size_t idx = MIN ((2 << shift) * 64 + rel, BUF1PAGES * page_size - 2);
      size_t len = random () % (sizeof (tmpbuf) - 1) + 1;
      len = MIN (len, BUF1PAGES * page_size - idx - 1);
      memcpy (tmpbuf, buf1 + idx, len);
      for (size_t i = random () % len / 2 + 1; i > 0; --i)
	{
	  size_t off = random () % len;
	  char ch = '0' + random () % 10;

	  buf1[idx + off] = ch;
	}

      printf ("String %.*s, offset %zd:", (int) len, buf1 + idx, idx);

      FOR_EACH_IMPL (impl, 0)
	do_one_test (impl, buf1, BUF1PAGES * page_size, buf1 + idx, len,
		     buf1 + idx);

      putchar ('\n');

      memcpy (buf1 + idx, tmpbuf, len);
    }
}
开发者ID:bminor,项目名称:glibc,代码行数:32,代码来源:bench-memmem.c


示例7: do_test

static void
do_test (size_t align1, size_t align2, size_t len, size_t dlen, int max_char)
{
  size_t i;
  char *s1, *s2;

  align1 &= 7;
  if (align1 + len >= page_size)
    return;

  align2 &= 7;
  if (align2 + len >= page_size)
    return;

  s1 = (char *) buf1 + align1;
  s2 = (char *) buf2 + align2;

  for (i = 0; i < len; i++)
    s1[i] = 32 + 23 * i % (max_char - 32);
  s1[len] = 0;

  if (dlen > len)
    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s2, s1, len, dlen);

  if (dlen > len)
    putchar ('\n');
}
开发者ID:AubrCool,项目名称:glibc,代码行数:30,代码来源:bench-strcpy_chk.c


示例8: do_test

static void
do_test (size_t align1, size_t align2, int c, size_t len, size_t n,
	 int max_char)
{
  size_t i;
  char *s1, *s2;

  align1 &= 7;
  if (align1 + len >= page_size)
    return;

  align2 &= 7;
  if (align2 + len >= page_size)
    return;

  s1 = (char *) (buf1 + align1);
  s2 = (char *) (buf2 + align2);

  for (i = 0; i < len - 1; ++i)
    {
      s1[i] = 32 + 23 * i % (max_char - 32);
      if (s1[i] == (char) c)
	--s1[i];
    }
  s1[len - 1] = c;
  for (i = len; i + align1 < page_size && i < len + 64; ++i)
    s1[i] = 32 + 32 * i % (max_char - 32);

  printf ("Length %4zd, n %4zd, char %d, alignment %2zd/%2zd:", len, n, c, align1, align2);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s2, s1, c, len, n);

  putchar ('\n');
}
开发者ID:abellgithub,项目名称:glibc,代码行数:35,代码来源:bench-memccpy.c


示例9: do_test

static void
do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
{
  size_t i;
  CHAR *s1, *s2;

/* For wcsncpy: align1 and align2 here mean alignment not in bytes,
   but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t)).  */
  align1 &= 7;
  if ((align1 + len) * sizeof (CHAR) >= page_size)
    return;

  align2 &= 7;
  if ((align2 + len) * sizeof (CHAR) >= page_size)
    return;

  s1 = (CHAR *) (buf1) + align1;
  s2 = (CHAR *) (buf2) + align2;

  for (i = 0; i < len; ++i)
    s1[i] = 32 + 23 * i % (max_char - 32);
  s1[len] = 0;
  for (i = len + 1; (i + align1) * sizeof (CHAR) < page_size && i < len + 64;
       ++i)
    s1[i] = 32 + 32 * i % (max_char - 32);

  printf ("Length %4zd, n %4zd, alignment %2zd/%2zd:", len, n, align1, align2);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s2, s1, len, n);

  putchar ('\n');
}
开发者ID:Distrotech,项目名称:glibc,代码行数:33,代码来源:bench-strncpy.c


示例10: do_test

static void
do_test (size_t align, size_t pos, size_t len, int seek_char)
{
  size_t i;
  char *result;

  align &= 7;
  if (align + len >= page_size)
    return;

  for (i = 0; i < len; ++i)
    {
      buf1[align + i] = 1 + 23 * i % 127;
      if (buf1[align + i] == seek_char)
	buf1[align + i] = seek_char + 1;
    }
  buf1[align + len] = 0;

  assert (pos < len);

  buf1[align + pos] = seek_char;
  buf1[align + len] = -seek_char;
  result = (char *) (buf1 + align + pos);

  if (HP_TIMING_AVAIL)
    printf ("Length %4zd, alignment %2zd:", pos, align);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, (char *) (buf1 + align), seek_char, result);

  if (HP_TIMING_AVAIL)
    putchar ('\n');
}
开发者ID:Boshin,项目名称:workspace,代码行数:33,代码来源:bench-rawmemchr.c


示例11: do_test

static void
do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
{
  size_t i, j;
  char *s1, *s2;

  align1 &= 63;
  if (align1 + len >= page_size)
    return;

  align2 &= 63;
  if (align2 + len >= page_size)
    return;

  s1 = (char *) (buf2 + align1);
  s2 = (char *) (buf2 + align2);

  for (i = 0, j = 1; i < len; i++, j += 23)
    s1[i] = j;

  json_element_object_begin (json_ctx);
  json_attr_uint (json_ctx, "length", (double) len);
  json_attr_uint (json_ctx, "align1", (double) align1);
  json_attr_uint (json_ctx, "align2", (double) align2);
  json_array_begin (json_ctx, "timings");

  FOR_EACH_IMPL (impl, 0)
    do_one_test (json_ctx, impl, s2, s1, len);

  json_array_end (json_ctx);
  json_element_object_end (json_ctx);
}
开发者ID:bminor,项目名称:glibc,代码行数:32,代码来源:bench-memmove.c


示例12: do_test

static void
do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
{
  size_t i;
  char *s1, *s2;

  align1 &= 7;
  if (align1 + len >= page_size)
    return;

  align2 &= 7;
  if (align2 + len >= page_size)
    return;

  s1 = (char *) (buf1 + align1);
  s2 = (char *) (buf2 + align2);

  for (i = 0; i < len; ++i)
    s1[i] = 32 + 23 * i % (max_char - 32);
  s1[len] = 0;
  for (i = len + 1; i + align1 < page_size && i < len + 64; ++i)
    s1[i] = 32 + 32 * i % (max_char - 32);

  if (HP_TIMING_AVAIL)
    printf ("Length %4zd, n %4zd, alignment %2zd/%2zd:", len, n, align1, align2);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s2, s1, len, n);

  if (HP_TIMING_AVAIL)
    putchar ('\n');
}
开发者ID:Boshin,项目名称:workspace,代码行数:32,代码来源:bench-strncpy.c


示例13: do_test

static int
do_test (void)
{
  int mode, ret = 0;
  for (mode = 0; mode <= 4; mode++)
    ret |= do_one_test (mode);
  return ret;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:8,代码来源:bug-ungetc4.c


示例14: do_test

static void
do_test (size_t align, size_t pos, size_t len)
{
  size_t i;
  int c;
  RES_TYPE result;
  char *rej, *s;

  align &= 7;
  if (align + pos + 10 >= page_size || len > 240)
    return;

  rej = (char *) (buf2 + (random () & 255));
  s = (char *) (buf1 + align);

  for (i = 0; i < len; ++i)
    {
      rej[i] = random () & 255;
      if (!rej[i])
	rej[i] = random () & 255;
      if (!rej[i])
	rej[i] = 1 + (random () & 127);
    }
  rej[len] = '\0';
  for (c = 1; c <= 255; ++c)
    if (strchr (rej, c) == NULL)
      break;

  for (i = 0; i < pos; ++i)
    {
      s[i] = random () & 255;
      if (strchr (rej, s[i]))
	{
	  s[i] = random () & 255;
	  if (strchr (rej, s[i]))
	    s[i] = c;
	}
    }
  s[pos] = rej[random () % (len + 1)];
  if (s[pos])
    {
      for (i = pos + 1; i < pos + 10; ++i)
	s[i] = random () & 255;
      s[i] = '\0';
    }
  result = STRPBRK_RESULT (s, pos);

  if (HP_TIMING_AVAIL)
    printf ("Length %4zd, alignment %2zd, rej len %2zd:", pos, align, len);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s, rej, result);

  if (HP_TIMING_AVAIL)
    putchar ('\n');
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:56,代码来源:test-strpbrk.c


示例15: do_test

static int
do_test (void)
{
  struct passwd *pwd = getpwnam ("nobody");
  if (pwd == NULL)
    {
      puts ("User nobody doesn't exist");
      return 0;
    }
  nobody_uid = pwd->pw_uid;
  nobody_gid = pwd->pw_gid;

  if (getresuid (&prev_ruid, &prev_euid, &prev_suid) < 0)
    {
      printf ("getresuid failed: %m\n");
      exit (1);
    }

  if (getresgid (&prev_rgid, &prev_egid, &prev_sgid) < 0)
    {
      printf ("getresgid failed: %m\n");
      exit (1);
    }

  if (prev_ruid == nobody_uid || prev_euid == nobody_uid
      || prev_suid == nobody_uid)
    {
      puts ("already running as user nobody, skipping tests");
      exit (0);
    }

  if (prev_rgid == nobody_gid || prev_egid == nobody_gid
      || prev_sgid == nobody_gid)
    {
      puts ("already running as group nobody, skipping tests");
      exit (0);
    }

  if (pthread_barrier_init (&b3, NULL, 3) != 0)
    {
      puts ("barrier_init failed");
      exit (1);
    }

  if (pthread_barrier_init (&b4, NULL, 4) != 0)
    {
      puts ("barrier_init failed");
      exit (1);
    }

  for (unsigned long int testno = 0;
       testno < sizeof (setuid_tests) / sizeof (setuid_tests[0]);
       ++testno)
    do_one_test (testno);
  return 0;
}
开发者ID:AdvancedC,项目名称:glibc,代码行数:56,代码来源:tst-setuid1.c


示例16: do_test

static void
do_test (size_t align, size_t pos, size_t len)
{
  size_t i;
  int c;
  RES_TYPE result;
  CHAR *rej, *s;

  align &= 7;
  if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240)
    return;

  rej = (CHAR *) (buf2) + (random () & 255);
  s = (CHAR *) (buf1) + align;

  for (i = 0; i < len; ++i)
    {
      rej[i] = random () & BIG_CHAR;
      if (!rej[i])
	rej[i] = random () & BIG_CHAR;
      if (!rej[i])
	rej[i] = 1 + (random () & SMALL_CHAR);
    }
  rej[len] = '\0';
  for (c = 1; c <= BIG_CHAR; ++c)
    if (STRCHR (rej, c) == NULL)
      break;

  for (i = 0; i < pos; ++i)
    {
      s[i] = random () & BIG_CHAR;
      if (STRCHR (rej, s[i]))
	{
	  s[i] = random () & BIG_CHAR;
	  if (STRCHR (rej, s[i]))
	    s[i] = c;
	}
    }
  s[pos] = rej[random () % (len + 1)];
  if (s[pos])
    {
      for (i = pos + 1; i < pos + 10; ++i)
	s[i] = random () & BIG_CHAR;
      s[i] = '\0';
    }
  result = STRPBRK_RESULT (s, pos);

  printf ("Length %4zd, alignment %2zd, rej len %2zd:", pos, align, len);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, s, rej, result);

  putchar ('\n');
}
开发者ID:ddstreet,项目名称:glibc,代码行数:54,代码来源:bench-strpbrk.c


示例17: test_main

int
test_main (void)
{
  json_ctx_t json_ctx;
  size_t i;

  bench_start ();

  json_init (&json_ctx, 2, stdout);
  json_attr_object_begin (&json_ctx, TEST_NAME);

  /* Create 2 test arrays, one with 10% zeroes, 10% negative values,
     79% positive values and 1% infinity/NaN.  The other contains
     50% inf, 50% NaN.  This relies on rand behaving correctly.  */

  for (i = 0; i < SIZE; i++)
    {
      int x = rand () & 255;
      arr1[i] = (x < 25) ? 0.0 : ((x < 50) ? -1 : 100);
      if (x == 255) arr1[i] = __builtin_inf ();
      if (x == 254) arr1[i] = __builtin_nan ("0");
      arr2[i] = (x < 128) ? __builtin_inf () : __builtin_nan ("0");
    }

  for (i = 0; i < sizeof (test_list) / sizeof (test_list[0]); i++)
    {
      json_attr_object_begin (&json_ctx, test_list[i].name);
      do_one_test (&json_ctx, test_list[i].fn, arr2, SIZE, "inf/nan");
      json_attr_object_end (&json_ctx);
    }

  for (i = 0; i < sizeof (test_list) / sizeof (test_list[0]); i++)
    {
      json_attr_object_begin (&json_ctx, test_list[i].name);
      do_one_test (&json_ctx, test_list[i].fn, arr1, SIZE, "normal");
      json_attr_object_end (&json_ctx);
    }

  json_attr_object_end (&json_ctx);
  return 0;
}
开发者ID:Distrotech,项目名称:glibc,代码行数:41,代码来源:bench-math-inlines.c


示例18: do_test

/* Run the tests for regular files and wide mode files.  */
static int
do_test (void)
{
  int ret = 0;
  char *filename;
  int fd = create_temp_file ("tst-ftell-append-tmp.", &filename);

  if (fd == -1)
    {
      printf ("create_temp_file: %m\n");
      return 1;
    }

  close (fd);

  /* Tests for regular files.  */
  puts ("Regular mode:");
  fputs_func = (fputs_func_t) fputs;
  fgets_func = (fgets_func_t) fgets;
  data = char_data;
  buf = char_buf;
  data_len = strlen (char_data);
  ret |= do_one_test (filename);

  /* Tests for wide files.  */
  puts ("Wide mode:");
  if (setlocale (LC_ALL, "en_US.UTF-8") == NULL)
    {
      printf ("Cannot set en_US.UTF-8 locale.\n");
      return 1;
    }
  fputs_func = (fputs_func_t) fputws;
  fgets_func = (fgets_func_t) fgetws;
  data = wide_data;
  buf = wide_buf;
  data_len = wcslen (wide_data);
  ret |= do_one_test (filename);

  return ret;
}
开发者ID:Xilinx,项目名称:glibc,代码行数:41,代码来源:tst-ftell-append.c


示例19: do_test

static void
do_test (json_ctx_t *json_ctx, size_t len)
{
  json_element_object_begin (json_ctx);
  json_attr_uint (json_ctx, "length", (double) len);
  json_array_begin (json_ctx, "timings");

  FOR_EACH_IMPL (impl, 0)
    do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);

  json_array_end (json_ctx);
  json_element_object_end (json_ctx);
}
开发者ID:riscv,项目名称:riscv-glibc,代码行数:13,代码来源:bench-memcpy-walk.c


示例20: do_test

static void
do_test (size_t align, int c, size_t len)
{
  align &= 63;
  if ((align + len) * sizeof (CHAR) > page_size)
    return;

  printf ("Length %4zd, alignment %2zd, c %2d:", len, align, c);

  FOR_EACH_IMPL (impl, 0)
    do_one_test (impl, (CHAR *) (buf1) + align, c, len);

  putchar ('\n');
}
开发者ID:kraj,项目名称:glibc,代码行数:14,代码来源:bench-memset.c



注:本文中的do_one_test函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ do_read函数代码示例发布时间:2022-05-30
下一篇:
C++ do_one_initcall函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap