Blame string/tst-svc2.c

Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
static struct
Packit 6c4009
{
Packit 6c4009
  const char *str1;
Packit 6c4009
  const char *str2;
Packit 6c4009
} tests[] =
Packit 6c4009
  {
Packit 6c4009
    { "B0075022800016.gbp.corp.com", "B007502280067.gbp.corp.com" },
Packit 6c4009
    { "B0075022800016.gbp.corp.com", "B007502357019.GBP.CORP.COM" },
Packit 6c4009
    { "B007502280067.gbp.corp.com", "B007502357019.GBP.CORP.COM" }
Packit 6c4009
  };
Packit 6c4009
#define ntests (sizeof (tests) / sizeof (tests[0]))
Packit 6c4009
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
compare (const char *str1, const char *str2, int exp)
Packit 6c4009
{
Packit 6c4009
  int c = strverscmp (str1, str2);
Packit 6c4009
  if (c != 0)
Packit 6c4009
    c /= abs (c);
Packit 6c4009
  return c != exp;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  int res = 0;
Packit 6c4009
  for (int i = 0; i < ntests; ++i)
Packit 6c4009
    {
Packit 6c4009
      if (compare (tests[i].str1, tests[i].str2, -1))
Packit 6c4009
	{
Packit 6c4009
	  printf ("FAIL: \"%s\" > \"%s\"\n", tests[i].str1, tests[i].str2);
Packit 6c4009
	  res = 1;
Packit 6c4009
	}
Packit 6c4009
      if (compare (tests[i].str2, tests[i].str1, +1))
Packit 6c4009
	{
Packit 6c4009
	  printf ("FAIL: \"%s\" > \"%s\"\n", tests[i].str2, tests[i].str1);
Packit 6c4009
	  res = 1;
Packit 6c4009
	}
Packit 6c4009
      char *copy1 = strdupa (tests[i].str1);
Packit 6c4009
      if (compare (tests[i].str1, copy1, 0))
Packit 6c4009
	{
Packit 6c4009
	  printf ("FAIL: \"%s\" != \"%s\"\n", tests[i].str1, copy1);
Packit 6c4009
	  res = 1;
Packit 6c4009
	}
Packit 6c4009
      char *copy2 = strdupa (tests[i].str2);
Packit 6c4009
      if (compare (tests[i].str2, copy2, 0))
Packit 6c4009
	{
Packit 6c4009
	  printf ("FAIL: \"%s\" != \"%s\"\n", tests[i].str2, copy2);
Packit 6c4009
	  res = 1;
Packit 6c4009
	}
Packit 6c4009
    }
Packit 6c4009
  return res;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#include <support/test-driver.c>