unit testing with oUnit

This commit is contained in:
Simon Cruanes 2013-03-04 13:49:08 +01:00
parent 30b69a95a3
commit 3fe75af98e
4 changed files with 34 additions and 4 deletions

View file

@ -3,14 +3,16 @@ INTERFACE_FILES = $(shell find -name '*.mli')
IMPLEMENTATION_FILES = $(shell find -name '*.ml')
TARGETS_LIB = containers.cmxa containers.cma
OPTIONS = -use-ocamlfind -lib sequence
OPTIONS = -use-ocamlfind -package sequence
all:
ocamlbuild -use-ocamlfind $(TARGETS_LIB)
ocamlbuild $(OPTIONS) $(TARGETS_LIB)
tests:
ocamlbuild $(OPTIONS) -package oUnit -I . tests/tests.native
clean:
ocamlbuild -clean
.PHONY: all clean
.PHONY: all clean tests

View file

@ -19,6 +19,11 @@ Then:
$ make
To build and run tests (requires `oUnit`):
$ make tests
$ ./tests.native
## License
This code is free, under the BSD license. The module `leftistheap` is due

12
tests/test_pHashtbl.ml Normal file
View file

@ -0,0 +1,12 @@
open OUnit
let test_add () =
let h = PHashtbl.create 5 in
PHashtbl.replace h 42 "foo";
OUnit.assert_equal (PHashtbl.find h 42) "foo"
let suite =
"test_pHashtbl" >:::
[ "test_add" >:: test_add;
]

11
tests/tests.ml Normal file
View file

@ -0,0 +1,11 @@
open OUnit
(* TODO more tests *)
let suite =
"all_tests" >:::
[ Test_pHashtbl.suite;
]
let _ =
run_test_tt_main suite