|
rpm-build |
0f2925 |
(*
|
|
rpm-build |
0f2925 |
* ExtLib Testing Suite
|
|
rpm-build |
0f2925 |
* Copyright (C) 2004 John Skaller
|
|
rpm-build |
0f2925 |
* Copyright (C) 2004 Janne Hellsten
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is free software; you can redistribute it and/or
|
|
rpm-build |
0f2925 |
* modify it under the terms of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License as published by the Free Software Foundation; either
|
|
rpm-build |
0f2925 |
* version 2.1 of the License, or (at your option) any later version,
|
|
rpm-build |
0f2925 |
* with the special exception on linking described in file LICENSE.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is distributed in the hope that it will be useful,
|
|
rpm-build |
0f2925 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rpm-build |
0f2925 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
rpm-build |
0f2925 |
* Lesser General Public License for more details.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* You should have received a copy of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License along with this library; if not, write to the Free Software
|
|
rpm-build |
0f2925 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
rpm-build |
0f2925 |
*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
(* NOTE this is a copy of Skaller's trivial DynArray test. Apparently
|
|
rpm-build |
0f2925 |
he hit the nail on the head with a first try, since test_triv causes a
|
|
rpm-build |
0f2925 |
segfault if you run Gc.major () after test_triv. If you change the
|
|
rpm-build |
0f2925 |
initial size of the DynArray to one or bigger, the crash does not
|
|
rpm-build |
0f2925 |
occur. *)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
open DynArray
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let test_triv () =
|
|
rpm-build |
0f2925 |
let a = make 0 in (* ZERO here causes a segfault later in GC??? *)
|
|
rpm-build |
0f2925 |
let b = copy a in
|
|
rpm-build |
0f2925 |
assert (length a == 0);
|
|
rpm-build |
0f2925 |
assert (length b == 0);
|
|
rpm-build |
0f2925 |
Gc.major ()
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
(* Failure reported by Jeff Henrikson. Should be fixed in CVS
|
|
rpm-build |
0f2925 |
already? JH 2005/Mar/01 *)
|
|
rpm-build |
0f2925 |
let test_regr_1 () =
|
|
rpm-build |
0f2925 |
for i = 0 to 30 do
|
|
rpm-build |
0f2925 |
ignore (DynArray.of_array [||])
|
|
rpm-build |
0f2925 |
done
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
(* Memory corruption in DynArray.insert; fixed. BD 2009/Jun/18. *)
|
|
rpm-build |
0f2925 |
let test_insert () =
|
|
rpm-build |
0f2925 |
let d = ref (DynArray.create ()) and n = 4100 in
|
|
rpm-build |
0f2925 |
for i = 0 to n do
|
|
rpm-build |
0f2925 |
assert (i = DynArray.length !d);
|
|
rpm-build |
0f2925 |
(* This is needed in order to expose the memory corruption. *)
|
|
rpm-build |
0f2925 |
Printf.ifprintf stdout "%d %d\n" i (DynArray.length !d); flush stdout;
|
|
rpm-build |
0f2925 |
DynArray.insert !d 0 (Array.create 42 "")
|
|
rpm-build |
0f2925 |
done
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
(* Issue 2: Error in DynArray exponential resizer *)
|
|
rpm-build |
0f2925 |
let test_dynarray1 () =
|
|
rpm-build |
0f2925 |
let a = DynArray.create () in
|
|
rpm-build |
0f2925 |
for i = 1 to 2817131 do
|
|
rpm-build |
0f2925 |
DynArray.add a i
|
|
rpm-build |
0f2925 |
done
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let test_dynarray2 () =
|
|
rpm-build |
0f2925 |
let a = DynArray.make 2817131 in
|
|
rpm-build |
0f2925 |
for i = 1 to 2817131 do
|
|
rpm-build |
0f2925 |
DynArray.add a i
|
|
rpm-build |
0f2925 |
done
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let () =
|
|
rpm-build |
0f2925 |
Util.register "DynArray" [
|
|
rpm-build |
0f2925 |
"triv", test_triv;
|
|
rpm-build |
0f2925 |
"regr_1", test_regr_1;
|
|
rpm-build |
0f2925 |
"insert", test_insert;
|
|
rpm-build |
0f2925 |
"simple_1",test_dynarray1;
|
|
rpm-build |
0f2925 |
"simple_2",test_dynarray2;
|
|
rpm-build |
0f2925 |
]
|