From a23cc13ada98ffcd82262871e96932dcfabbf7b9 Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Fri, 20 Sep 2024 15:11:49 -0700 Subject: [PATCH] Split out tests into separate files --- tests/tests-ica05/test_addLists.sml | 15 ++++++++++++++ tests/tests-ica05/test_andList.sml | 14 +++++++++++++ tests/tests-ica05/test_combineLists.sml | 27 +++++++++++++++++++++++++ tests/tests-ica05/test_countZeros.sml | 17 ++++++++++++++++ tests/tests-ica05/test_factorial.sml | 18 +++++++++++++++++ tests/tests-ica05/test_fib.sml | 20 ++++++++++++++++++ tests/tests-ica05/test_log2.sml | 17 ++++++++++++++++ tests/tests-ica05/test_orList.sml | 18 +++++++++++++++++ tests/tests-ica05/test_removeZeros.sml | 16 +++++++++++++++ tests/tests-ica05/test_reverseList.sml | 16 +++++++++++++++ 10 files changed, 178 insertions(+) create mode 100644 tests/tests-ica05/test_addLists.sml create mode 100644 tests/tests-ica05/test_andList.sml create mode 100644 tests/tests-ica05/test_combineLists.sml create mode 100644 tests/tests-ica05/test_countZeros.sml create mode 100644 tests/tests-ica05/test_factorial.sml create mode 100644 tests/tests-ica05/test_fib.sml create mode 100644 tests/tests-ica05/test_log2.sml create mode 100644 tests/tests-ica05/test_orList.sml create mode 100644 tests/tests-ica05/test_removeZeros.sml create mode 100644 tests/tests-ica05/test_reverseList.sml diff --git a/tests/tests-ica05/test_addLists.sml b/tests/tests-ica05/test_addLists.sml new file mode 100644 index 0000000..8c97e2e --- /dev/null +++ b/tests/tests-ica05/test_addLists.sml @@ -0,0 +1,15 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesAddLists = [ + (addLists, ([1, 2, 3], [4, 5, 6]), [5, 7, 9]), + (addLists, ([1, 2], [4, 5, 6]), [5, 7]), + (addLists, ([1, 2, 3], []), []), + (addLists, ([], [4, 5, 6]), []), + (addLists, ([], []), []), + (addLists, ([1, 2, 3], [4, 5, 6, 7]), [5, 7, 9]), + (addLists, ([1, 2, 3, 4, 5], [4, 5, 6, 0, 0]), [5, 7, 9, 4, 5]) +]; +runTestCasesIntListIntList(testCasesAddLists); diff --git a/tests/tests-ica05/test_andList.sml b/tests/tests-ica05/test_andList.sml new file mode 100644 index 0000000..daf06b7 --- /dev/null +++ b/tests/tests-ica05/test_andList.sml @@ -0,0 +1,14 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesAndList = [ + (andList, [true, true, true], true), + (andList, [true, false, true], false), + (andList, [false, false, false], false), + (andList, [], true), (* Empty list case *) + (andList, [true], true), + (andList, [false], false) +]; +runTestCasesBoolListBool(testCasesAndList); diff --git a/tests/tests-ica05/test_combineLists.sml b/tests/tests-ica05/test_combineLists.sml new file mode 100644 index 0000000..f52c430 --- /dev/null +++ b/tests/tests-ica05/test_combineLists.sml @@ -0,0 +1,27 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +fun mockAdd(x, y) = x + y; +fun mockModulus(x, y) = x mod y; +fun mockDiv(x, y) = x div y; +fun doNothing(x, y) = x; + +val testCasesCombineLists = [ + (combineLists, [1, 2, 3], [4, 5, 6], mockAdd, [5, 7, 9]), + (combineLists, [1, 2], [4, 5, 6], mockAdd, [5, 7]), + (combineLists, [], [4, 5, 6], mockModulus, []), + (combineLists, [], [], mockModulus, []), + (combineLists, [1, 2, 3], [4, 5, 6], mockDiv, [0, 0, 0]), + (combineLists, [1, 2], [4, 5, 6], mockDiv, [0, 0]), + (combineLists, [8, 8, 3], [4], mockDiv, [2]), + (combineLists, [4], [4, 5, 6], mockDiv, [1]), + (combineLists, [], [], mockDiv, []), + (combineLists, [1, 2, 3], [4, 5, 6], doNothing, [1, 2, 3]), + (combineLists, [1, 2], [4, 5, 6], doNothing, [1, 2]), + (combineLists, [1, 2, 3], [], doNothing, []), + (combineLists, [], [4, 5, 6], doNothing, []), + (combineLists, [], [], doNothing, []) +]; +runTestCasesIntListIntListOperatorToIntList(testCasesCombineLists); \ No newline at end of file diff --git a/tests/tests-ica05/test_countZeros.sml b/tests/tests-ica05/test_countZeros.sml new file mode 100644 index 0000000..3a5bfd8 --- /dev/null +++ b/tests/tests-ica05/test_countZeros.sml @@ -0,0 +1,17 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesCountZeros = [ + (countZeros, [0, 1, 0, 1, 0], 3), + (countZeros, [1, 1, 1, 1, 1], 0), + (countZeros, [0, 0, 0, 0, 0], 5), + (countZeros, [], 0), + (countZeros, [0], 1), + (countZeros, [1], 0), + (countZeros, [0, 0, 0, 1, 0], 4), + (countZeros, [1, 0, 1, 0, 1], 2), + (countZeros, [0, 0, 1, 0, 0, 0], 5) +]; +runTestCasesIntListInt(testCasesCountZeros); \ No newline at end of file diff --git a/tests/tests-ica05/test_factorial.sml b/tests/tests-ica05/test_factorial.sml new file mode 100644 index 0000000..894a510 --- /dev/null +++ b/tests/tests-ica05/test_factorial.sml @@ -0,0 +1,18 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesFactorial = [ + (factorial, 0, 1), (* 0! = 1 *) + (factorial, 1, 1), (* 1! = 1 *) + (factorial, 2, 2), (* 2! = 2 *) + (factorial, 3, 6), (* 3! = 6 *) + (factorial, 4, 24), (* 4! = 24 *) + (factorial, 5, 120), (* 5! = 120 *) + (factorial, 6, 720), (* 6! = 720 *) + (factorial, 7, 5040), (* 7! = 5040 *) + (factorial, 8, 40320), (* 8! = 40320 *) + (factorial, 10, 3628800) (* 10! = 3628800 *) +]; +runTestCasesIntInt(testCasesFactorial); \ No newline at end of file diff --git a/tests/tests-ica05/test_fib.sml b/tests/tests-ica05/test_fib.sml new file mode 100644 index 0000000..67f05c2 --- /dev/null +++ b/tests/tests-ica05/test_fib.sml @@ -0,0 +1,20 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesFib = [ + (* a_n = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55} *) + (fib, 0, 0), + (fib, 1, 1), + (fib, 2, 1), + (fib, 3, 2), + (fib, 4, 3), + (fib, 5, 5), + (fib, 6, 8), + (fib, 7, 13), + (fib, 8, 21), + (fib, 9, 34), + (fib, 10, 55) +]; +runTestCasesIntInt(testCasesFib); \ No newline at end of file diff --git a/tests/tests-ica05/test_log2.sml b/tests/tests-ica05/test_log2.sml new file mode 100644 index 0000000..d59cd9b --- /dev/null +++ b/tests/tests-ica05/test_log2.sml @@ -0,0 +1,17 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesLog2 = [ + (log2, 1, 0), (* 2^0 = 1 *) + (log2, 2, 1), (* 2^1 = 2 *) + (log2, 4, 2), (* 2^2 = 4 *) + (log2, 8, 3), (* 2^3 = 8 *) + (log2, 16, 4), (* 2^4 = 16 *) + (log2, 32, 5), (* 2^5 = 32 *) + (log2, 64, 6), (* 2^6 = 64 *) + (log2, 128, 7), (* 2^7 = 128 *) + (log2, 256, 8) (* 2^8 = 256 *) +]; +runTestCasesIntInt(testCasesLog2); diff --git a/tests/tests-ica05/test_orList.sml b/tests/tests-ica05/test_orList.sml new file mode 100644 index 0000000..4cefc07 --- /dev/null +++ b/tests/tests-ica05/test_orList.sml @@ -0,0 +1,18 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesOrList = [ + (orList, [true, true, true], true), + (orList, [true, false, true], true), + (orList, [false, false, false], false), + (orList, [true, true, false], true), + (orList, [false, false, true], true), + (orList, [false, false, false, false], false), + (orList, [false, true, false, true], true), + (orList, [], false), (* Empty list case *) + (orList, [false], false), (* Single false element *) + (orList, [true], true) (* Single true element *) +]; +runTestCasesBoolListBool(testCasesOrList); diff --git a/tests/tests-ica05/test_removeZeros.sml b/tests/tests-ica05/test_removeZeros.sml new file mode 100644 index 0000000..3976cad --- /dev/null +++ b/tests/tests-ica05/test_removeZeros.sml @@ -0,0 +1,16 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesRemoveZeros = [ + (removeZeros, [0, 1, 0, 2], [1, 2]), + (removeZeros, [0, 0, 0], []), + (removeZeros, [1, 2, 3], [1, 2, 3]), + (removeZeros, [], []), + (removeZeros, [0], []), + (removeZeros, [1], [1]), + (removeZeros, [0, 0, 0, 1, 0], [1]), + (removeZeros, [1, 0, 1, 0, 1], [1, 1, 1]) +]; +runTestCasesIntListIntList(testCasesRemoveZeros); diff --git a/tests/tests-ica05/test_reverseList.sml b/tests/tests-ica05/test_reverseList.sml new file mode 100644 index 0000000..5166070 --- /dev/null +++ b/tests/tests-ica05/test_reverseList.sml @@ -0,0 +1,16 @@ +(* ICA 5 tests *) + +use "src/ica05/ica5.sml"; +use "tests/utils.sml"; + +val testCasesReverseList = [ + (reverseList, [1, 2, 3], [3, 2, 1]), + (reverseList, [1], [1]), + (reverseList, [], []), + (reverseList, [4, 5, 6, 7], [7, 6, 5, 4]), + (reverseList, [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]), + (reverseList, [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]), + (reverseList, [1, 0, 0, 1, 0], [0, 1, 0, 0, 1]), + (reverseList, [0, 0, 0], [0, 0, 0]) +]; +runTestCasesIntListIntList(testCasesReverseList);