From c8aac41efecce8d9cdace7586dab0d65faa64011 Mon Sep 17 00:00:00 2001 From: wenner Date: Wed, 21 Jul 2021 15:34:07 -0300 Subject: [PATCH 1/3] test: ensure be able to returns the average of all elements in the array --- shapesimilarity/__init__.py | 3 ++- tests/utils/__init__.py | 0 tests/utils/test_array_average.py | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/utils/__init__.py create mode 100644 tests/utils/test_array_average.py diff --git a/shapesimilarity/__init__.py b/shapesimilarity/__init__.py index df8efbf..c56bfc8 100644 --- a/shapesimilarity/__init__.py +++ b/shapesimilarity/__init__.py @@ -1,4 +1,5 @@ from .procrustesanalysis import * from .shapesimilarity import * from .frechetdistance import * -from .geometry import * \ No newline at end of file +from .geometry import * +from .utils import * \ No newline at end of file diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/test_array_average.py b/tests/utils/test_array_average.py new file mode 100644 index 0000000..ab8a667 --- /dev/null +++ b/tests/utils/test_array_average.py @@ -0,0 +1,6 @@ +from shapesimilarity import array_average +import unittest + +class TestArrayAverage(unittest.TestCase): + def test_returns_the_average_of_all_elements_in_the_array(self): + self.assertEqual(array_average([1, 3, 5]), 3) \ No newline at end of file From c8eadf3c6325369658b0366a0653ffadfe468e43 Mon Sep 17 00:00:00 2001 From: wenner Date: Wed, 21 Jul 2021 15:39:59 -0300 Subject: [PATCH 2/3] test: ensure be able to returns the sum of all elements in the array --- tests/utils/test_array_sum.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/utils/test_array_sum.py diff --git a/tests/utils/test_array_sum.py b/tests/utils/test_array_sum.py new file mode 100644 index 0000000..611de07 --- /dev/null +++ b/tests/utils/test_array_sum.py @@ -0,0 +1,6 @@ +from shapesimilarity import array_sum +import unittest + +class TestArraySum(unittest.TestCase): + def test_returns_the_sum_of_all_elements_in_the_array(self): + self.assertEqual(array_sum([1, 3, 5]), 9) \ No newline at end of file From ea73d444b1c5f80ffd62184d42a367507ef00bb2 Mon Sep 17 00:00:00 2001 From: wenner Date: Wed, 21 Jul 2021 15:42:57 -0300 Subject: [PATCH 3/3] test: ensure be able to returns 0 for empty arrays --- tests/utils/test_array_sum.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/utils/test_array_sum.py b/tests/utils/test_array_sum.py index 611de07..474f12e 100644 --- a/tests/utils/test_array_sum.py +++ b/tests/utils/test_array_sum.py @@ -3,4 +3,7 @@ class TestArraySum(unittest.TestCase): def test_returns_the_sum_of_all_elements_in_the_array(self): - self.assertEqual(array_sum([1, 3, 5]), 9) \ No newline at end of file + self.assertEqual(array_sum([1, 3, 5]), 9) + + def test_returns_0_for_empty_arrays(self): + self.assertEqual(array_sum([]), 0) \ No newline at end of file