File: test_iconv.sl

package info (click to toggle)
slang2 2.3.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,488 kB
  • sloc: ansic: 101,756; sh: 3,435; makefile: 1,046; pascal: 440
file content (40 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (5)
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
% -*- mode: slang; mode: fold -*-

() = evalfile ("./test.sl");

require ("iconv");

% FIXME: Add additional tests and charsets.
private define test_iconv ()
{
   variable ustr = "áéíóúüþëé", ucs = "utf-8";
   variable istr = "\xE1\xE9\xED\xF3\xFA\xFC\xFE\xEB\xE9", ics = "iso-8859-1";

   variable s = iconv_open (ics, ucs);
   variable str = iconv (s, ustr);
   iconv_close (s);
   if (str != istr)
     failed ("conversion from %s->%s failed", ucs, ics);

   % The iconv_reset functions are not necessary for simple tests.
   % They are there just to exercise the interface
   s = iconv_open (ucs, ics);
   iconv_reset (s);
   str = iconv (s, istr);
   () = iconv_reset_shift (s);
   iconv_close (s);

   if (str != ustr)
     failed ("conversion from %s->%s failed", ics, ucs);

   () = iconv_open (ucs, ics);
   %iconv_reset ();
   %iconv_reset_shift ();
}

define slsh_main ()
{
   testing_module ("iconv");
   test_iconv ();
   end_test ();
}