From a34a8eb51ca7e178dfcb0b4f61eaa2caf663b4de Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Wed, 3 May 2023 21:52:22 -0600 Subject: [PATCH] Added unit tests for prolog --- PA009/list_operations_tests.pl | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 PA009/list_operations_tests.pl diff --git a/PA009/list_operations_tests.pl b/PA009/list_operations_tests.pl new file mode 100644 index 0000000..b8a2422 --- /dev/null +++ b/PA009/list_operations_tests.pl @@ -0,0 +1,42 @@ +:- use_module(library(plunit)). + +:- consult(custom_report). % include the custom report hook + +:- begin_tests(hw5_arafat_ziad). + +:- consult(hw5_arafat_ziad). + +test(list_len_empty) :- + listLen(0, []). + +test(list_len_single) :- + listLen(1, [1]). + +test(list_len_multiple) :- + listLen(5, [1, 2, 3, 4, 5]). + +test(drop_k_first) :- + dropK([2, 3, 4, 5], [1, 2, 3, 4, 5], 1). + +test(drop_k_middle) :- + dropK([1, 3, 4, 5], [1, 2, 3, 4, 5], 2). + +test(drop_k_last) :- + dropK([1, 2, 3, 4], [1, 2, 3, 4, 5], 5). + +test(split_list_empty) :- + split_list([], [], [], 0). + +test(split_list_first) :- + split_list([1], [2, 3, 4, 5], [1, 2, 3, 4, 5], 1). + +test(split_list_middle) :- + split_list([1, 2, 3], [4, 5], [1, 2, 3, 4, 5], 3). + +test(split_list_last) :- + split_list([1, 2, 3, 4], [5], [1, 2, 3, 4, 5], 4). + +test(split_list_after_last) :- + split_list([1, 2, 3, 4, 5], [], [1, 2, 3, 4, 5], 5). + +:- end_tests(hw5_arafat_ziad). \ No newline at end of file