~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to gnulib-tests/test-mbsalign.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- buffer-read-only: t -*- vi: set ro: */
2
 
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3
1
/* Test that mbsalign works as advertised.
4
 
   Copyright (C) 2010-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 2010-2012 Free Software Foundation, Inc.
5
3
 
6
4
   This program is free software: you can redistribute it and/or modify
7
5
   it under the terms of the GNU General Public License as published by
40
38
  width = 4;
41
39
  n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
42
40
  ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
 
41
  ASSERT (n == 4);
 
42
 
 
43
  /* Test center alignment, with no trailing padding.  */
 
44
  width = 4;
 
45
  n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
 
46
                MBA_NO_RIGHT_PAD);
 
47
  ASSERT (n == 3);
 
48
  ASSERT (*dest == ' ' && *(dest + n - 1) == 's');
 
49
 
 
50
  /* Test left alignment, with no trailing padding. (truncate only).  */
 
51
  width = 4;
 
52
  n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
 
53
                MBA_NO_RIGHT_PAD);
 
54
  ASSERT (n == 2);
 
55
  ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
 
56
 
 
57
  /* Test center alignment, with no padding. (truncate only).  */
 
58
  width = 4;
 
59
  n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
 
60
                MBA_NO_LEFT_PAD | MBA_NO_RIGHT_PAD);
 
61
  ASSERT (n == 2);
 
62
  ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
 
63
 
 
64
  /* Test center alignment, with no left padding. (may be useful for RTL?)  */
 
65
  width = 4;
 
66
  n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
 
67
                MBA_NO_LEFT_PAD);
 
68
  ASSERT (n == 3);
 
69
  ASSERT (*dest == 'e' && *(dest + n - 1) == ' ');
43
70
 
44
71
  if (setlocale (LC_ALL, "en_US.UTF8"))
45
72
    {
57
84
      /* Test multibyte center alignment.  */
58
85
      width = 4;
59
86
      n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
 
87
      ASSERT (n == 5);
60
88
      ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
61
89
 
62
90
      /* Test multibyte left alignment.  */
63
91
      width = 4;
64
92
      n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
 
93
      ASSERT (n == 5);
65
94
      ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' ');
66
95
 
67
96
      /* Test multibyte right alignment.  */
68
97
      width = 4;
69
98
      n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0);
 
99
      ASSERT (n == 5);
70
100
      ASSERT (*(dest) == ' ' && *(dest + 1) == ' ');
71
101
 
72
102
      /* multibyte multicell truncation.  */
96
126
      n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
97
127
                    &width, MBS_ALIGN_LEFT, 0);
98
128
      ASSERT (n == 7);
 
129
 
 
130
      /* Test forced unibyte truncation.  */
 
131
      width = 4;
 
132
      n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
 
133
                    MBA_UNIBYTE_ONLY);
 
134
      ASSERT (n == 4);
99
135
    }
100
136
 
101
137
  return 0;