about summary refs log tree commit diff
path: root/localedata/tests-mbwc/tst_strcoll.c
blob: 4c5a84f697a7fda0877f84038f6f15cba50a7954 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
  STRCOLL: int strcoll (const char *s1, const char *s2)
*/

#define TST_FUNCTION strcoll

#include "tsp_common.c"
#include "dat_strcoll.c"

int
tst_strcoll (FILE * fp, int debug_flg)
{
  TST_DECL_VARS (int);
  const char *s1, *s2;

  TST_DO_TEST (strcoll)
  {
    TST_HEAD_LOCALE (strcoll, S_STRCOLL);
    TST_DO_REC (strcoll)
    {
      TST_GET_ERRET (strcoll);
      s1 = TST_INPUT (strcoll).s1;
      s2 = TST_INPUT (strcoll).s2;

      TST_CLEAR_ERRNO;
      ret = strcoll (s1, s2);
      TST_SAVE_ERRNO;

      if (debug_flg)
	{
	  fprintf (stdout, "strcoll() [ %s : %d ] ret = %d\n", locale,
		   rec + 1, ret);
	  fprintf (stdout, "			    errno = %d\n",
		   errno_save);
	  fprintf (stdout, "			    LC_COLLATE = %s\n",
		   (setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
							       NULL) : "");
	}

      TST_IF_RETURN (S_STRCOLL)
      {
	if (ret_exp == +1)
	  {
	    if (ret > 0)
	      {
		Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
	      }
	    else
	      {
		err_count++;
		Result (C_FAILURE, S_STRCOLL, CASE_3,
			"the return value should be greater than 0,"
			" but is not ...");
	      }
	  }
	else if (ret_exp == -1)
	  {
	    if (ret < 0)
	      {
		Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
	      }
	    else
	      {
		err_count++;
		Result (C_FAILURE, S_STRCOLL, CASE_3,
			"the return value should less than 0, but not ...");
	      }
	  }
	else if (ret_exp != 0)
	  {
	    if (debug_flg)
	      {
		fprintf (stderr, "*** Warning *** : tst_strcoll : "
			 "(check the test data); should set ret_flg=1"
			 " to check a return value");
	      }

	    warn_count++;
	    Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data); "
		    "should set ret_flg=1 to check a return value");
	  }
      }
    }
  }

  return err_count;
}