From 146a83c2ab76ccec943f5c146d72f7d2f3abfccb Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 9 Mar 2024 12:17:27 -0800 Subject: [PATCH] test_icosahedron_faces --- tests/test_apis/test_ico_faces.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_apis/test_ico_faces.py diff --git a/tests/test_apis/test_ico_faces.py b/tests/test_apis/test_ico_faces.py new file mode 100644 index 00000000..26afeb99 --- /dev/null +++ b/tests/test_apis/test_ico_faces.py @@ -0,0 +1,30 @@ +import h3 + + +def test_icosahedron_faces(): + """ + get_icosahedron_faces is kind of a special case, because it always returns + a list of integers no matter the API + """ + answers = { + '804dfffffffffff': [2, 3, 7, 8, 12], + '80c1fffffffffff': [13], + '80bbfffffffffff': [15, 16], + } + + interfaces = [ + (h3.api.basic_str, lambda x: x), + (h3.api.basic_int, h3.str_to_int), + (h3.api.memview_int, h3.str_to_int), + (h3.api.numpy_int, h3.str_to_int), + ] + + for api, conv in interfaces: + for h in answers: + expected = answers[h] + + h = conv(h) # convert to int or str, depending on API + out = api.get_icosahedron_faces(h) + + assert isinstance(out, list) + assert set(out) == set(expected)