1% -*- mode: slang; mode: fold -*-
2
3() = evalfile ("./test.sl");
4
5require ("varray");
6
7private define test_varray ()
8{
9   variable file = __FILE__;
10   variable fp = fopen (file, "r");
11   if (fp == NULL)
12     failed ("failed to open %s", file);
13   variable bytes, nbytes, array, i0, i1;
14
15   nbytes = fread (&bytes, UChar_Type, 0xFFFF, fp);
16   i0 = nbytes/2;
17   i1 = (3*nbytes)/4;
18   array = mmap_array (file, i0, UChar_Type, [i1-i0+1]);
19
20   if (length (array) != i1-i0+1)
21     failed ("mmap_array returned wrong sized array");
22
23   if (_typeof(array) != UChar_Type)
24     failed ("mmap_array returned wrong array type [%S]", _typeof(array));
25
26   if (not _eqs(array, bytes[[i0:i1]]))
27     failed ("mmap_array produced an array with unexpected values");
28}
29
30define slsh_main ()
31{
32   testing_module ("varray");
33   test_varray ();
34   end_test ();
35}
36