diff --git a/Makefile b/Makefile index 47466619..f8be8361 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 85d2ffbf..1600a323 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tests/test_pHashtbl.ml b/tests/test_pHashtbl.ml new file mode 100644 index 00000000..d2535ecb --- /dev/null +++ b/tests/test_pHashtbl.ml @@ -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; + ] diff --git a/tests/tests.ml b/tests/tests.ml new file mode 100644 index 00000000..62d7d57a --- /dev/null +++ b/tests/tests.ml @@ -0,0 +1,11 @@ +open OUnit + +(* TODO more tests *) + +let suite = + "all_tests" >::: + [ Test_pHashtbl.suite; + ] + +let _ = + run_test_tt_main suite