1() = evalfile ("./test.sl");
2try
3{
4   require ("png");
5}
6catch ImportError:
7{
8   () = fprintf (stderr, "png-module not available.  Test not performed\n");
9   exit (1);
10}
11require ("rand");
12
13private define test_png ()
14{
15   variable nrows = 61, ncols = 83;
16   variable img = typecast (rand (nrows*ncols), UInt32_Type);
17   reshape (img, [nrows, ncols]);
18
19   variable file = sprintf ("/tmp/testpng-%ld.png", _time() mod getpid());
20   try
21     {
22	png_write (file, img, 1);
23	variable img1 = png_read (file);
24	ifnot (_eqs (img1, img))
25	  {
26	     failed ("png_read failed to read the ARGB image png_write created\n");
27	     return;
28	  }
29	png_write (file, img, 0);
30	img1 = png_read (file);
31	ifnot (_eqs (img&0x00FFFFFFU, img1))
32	  {
33	     failed ("png_read failed to read the RGB image png_write created\n");
34	     return;
35	  }
36     }
37   finally
38     {
39	() = remove (file);
40     }
41}
42
43define slsh_main ()
44{
45   testing_module ("png");
46   test_png ();
47   end_test ();
48}
49
50
51