From 705b18da96cdb09326f1becc1490fd440baac356 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Fri, 22 Nov 2019 16:20:57 +0000 Subject: [PATCH 01/12] Add test case for issue #35. --- test/test_issue35.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/test_issue35.py diff --git a/test/test_issue35.py b/test/test_issue35.py new file mode 100644 index 0000000..e10188c --- /dev/null +++ b/test/test_issue35.py @@ -0,0 +1,8 @@ +import cdd + + +# this should not segfault +def test_issue35(): + m = cdd.Matrix([[0, 0, 0]], number_type="float") + m.rep_type = cdd.RepType.INEQUALITY + m.canonicalize() From 59ce64f0f688df04374e8ec80d6c934a7c3d51df Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 17 Sep 2024 11:00:15 +0100 Subject: [PATCH 02/12] Update test for v3.0.0. --- test/test_issue35.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test_issue35.py b/test/test_issue35.py index e10188c..4a43509 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -3,6 +3,5 @@ # this should not segfault def test_issue35(): - m = cdd.Matrix([[0, 0, 0]], number_type="float") - m.rep_type = cdd.RepType.INEQUALITY - m.canonicalize() + mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) + cdd.matrix_canonicalize(mat) From e030f1aec066a2a0ed03363c5b074d6a9cf621c4 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 17 Sep 2024 11:02:09 +0100 Subject: [PATCH 03/12] Minor fixes. --- test/test_issue35.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_issue35.py b/test/test_issue35.py index 4a43509..2890eb8 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -2,6 +2,6 @@ # this should not segfault -def test_issue35(): +def test_issue35() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) cdd.matrix_canonicalize(mat) From 24a0908ad92c95e0cfa17ba7ca25d89a7e137315 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:17:14 +0100 Subject: [PATCH 04/12] Add segfault tests for other canonicalize functions. --- test/test_issue35_2.py | 7 +++++++ test/test_issue35_3.py | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 test/test_issue35_2.py create mode 100644 test/test_issue35_3.py diff --git a/test/test_issue35_2.py b/test/test_issue35_2.py new file mode 100644 index 0000000..60368d7 --- /dev/null +++ b/test/test_issue35_2.py @@ -0,0 +1,7 @@ +import cdd + + +# this should not segfault +def test_issue35_2() -> None: + mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) + cdd.matrix_canonicalize(mat) diff --git a/test/test_issue35_3.py b/test/test_issue35_3.py new file mode 100644 index 0000000..a9e888c --- /dev/null +++ b/test/test_issue35_3.py @@ -0,0 +1,7 @@ +import cdd + + +# this should not segfault +def test_issue35_3() -> None: + mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) + cdd.matrix_canonicalize_linearity(mat) From b6148f5abec142423a77e4d792a623c93919f6a3 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:22:05 +0100 Subject: [PATCH 05/12] Temp disable test for regression. --- test/test_issue35.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_issue35.py b/test/test_issue35.py index 2890eb8..788c8f2 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -1,7 +1,9 @@ import cdd +import pytest # this should not segfault +@pytest.mark.skip # temporarily disabled to check other tests def test_issue35() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) cdd.matrix_canonicalize(mat) From 2379e1a3c35a3017d38268c1e0df4ad3ec0e643d Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:24:32 +0100 Subject: [PATCH 06/12] Correct test. --- test/test_issue35_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_issue35_2.py b/test/test_issue35_2.py index 60368d7..e1f8741 100644 --- a/test/test_issue35_2.py +++ b/test/test_issue35_2.py @@ -4,4 +4,4 @@ # this should not segfault def test_issue35_2() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - cdd.matrix_canonicalize(mat) + cdd.matrix_redundancy_remove(mat) From 6d15564492a235fb217a4abedd6bed301c6eb570 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:26:41 +0100 Subject: [PATCH 07/12] Merge tests. --- test/test_issue35.py | 10 ++++++++++ test/test_issue35_2.py | 7 ------- test/test_issue35_3.py | 7 ------- 3 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 test/test_issue35_2.py delete mode 100644 test/test_issue35_3.py diff --git a/test/test_issue35.py b/test/test_issue35.py index 788c8f2..7d93a62 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -7,3 +7,13 @@ def test_issue35() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) cdd.matrix_canonicalize(mat) + + +def test_issue35_2() -> None: + mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) + cdd.matrix_redundancy_remove(mat) + + +def test_issue35_3() -> None: + mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) + cdd.matrix_canonicalize_linearity(mat) diff --git a/test/test_issue35_2.py b/test/test_issue35_2.py deleted file mode 100644 index e1f8741..0000000 --- a/test/test_issue35_2.py +++ /dev/null @@ -1,7 +0,0 @@ -import cdd - - -# this should not segfault -def test_issue35_2() -> None: - mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - cdd.matrix_redundancy_remove(mat) diff --git a/test/test_issue35_3.py b/test/test_issue35_3.py deleted file mode 100644 index a9e888c..0000000 --- a/test/test_issue35_3.py +++ /dev/null @@ -1,7 +0,0 @@ -import cdd - - -# this should not segfault -def test_issue35_3() -> None: - mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - cdd.matrix_canonicalize_linearity(mat) From a3cd6a9b2c66c1187174728396b9d00fdeb9ee14 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:28:16 +0100 Subject: [PATCH 08/12] Enhance tests. --- test/test_issue35.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_issue35.py b/test/test_issue35.py index 7d93a62..c02b77f 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -11,9 +11,11 @@ def test_issue35() -> None: def test_issue35_2() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - cdd.matrix_redundancy_remove(mat) + assert cdd.matrix_redundancy_remove(mat) == ({0}, [None]) + assert mat.array == [] def test_issue35_3() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - cdd.matrix_canonicalize_linearity(mat) + assert cdd.matrix_canonicalize_linearity(mat) == ({0}, [None]) + assert mat.array == [] From 232e2d912cce8cf2c6afc96cd55165b5c3a982be Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:29:27 +0100 Subject: [PATCH 09/12] Test more special cases. --- test/test_issue35.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_issue35.py b/test/test_issue35.py index c02b77f..201b31c 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -19,3 +19,15 @@ def test_issue35_3() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) assert cdd.matrix_canonicalize_linearity(mat) == ({0}, [None]) assert mat.array == [] + + +def test_issue35_4() -> None: + mat = cdd.matrix_from_array([], rep_type=cdd.RepType.INEQUALITY) + assert cdd.matrix_redundancy_remove(mat) == (set(), []) + assert mat.array == [] + + +def test_issue35_5() -> None: + mat = cdd.matrix_from_array([], rep_type=cdd.RepType.INEQUALITY) + assert cdd.matrix_canonicalize_linearity(mat) == (set(), []) + assert mat.array == [] From f2f81eeee77131fca0a702df921cf0a012fcdc53 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 13:32:06 +0100 Subject: [PATCH 10/12] One more test. --- test/test_issue35.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/test_issue35.py b/test/test_issue35.py index 201b31c..99caece 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -4,9 +4,10 @@ # this should not segfault @pytest.mark.skip # temporarily disabled to check other tests -def test_issue35() -> None: +def test_issue35_1() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - cdd.matrix_canonicalize(mat) + assert cdd.matrix_canonicalize(mat) == ({0}, None) + assert mat.array == [] def test_issue35_2() -> None: @@ -23,11 +24,17 @@ def test_issue35_3() -> None: def test_issue35_4() -> None: mat = cdd.matrix_from_array([], rep_type=cdd.RepType.INEQUALITY) - assert cdd.matrix_redundancy_remove(mat) == (set(), []) + assert cdd.matrix_canonicalize(mat) == (set(), set(), []) assert mat.array == [] def test_issue35_5() -> None: + mat = cdd.matrix_from_array([], rep_type=cdd.RepType.INEQUALITY) + assert cdd.matrix_redundancy_remove(mat) == (set(), []) + assert mat.array == [] + + +def test_issue35_6() -> None: mat = cdd.matrix_from_array([], rep_type=cdd.RepType.INEQUALITY) assert cdd.matrix_canonicalize_linearity(mat) == (set(), []) assert mat.array == [] From eca3bd969e2f752d97e0cbab2fea647b16876a44 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 21:27:21 +0100 Subject: [PATCH 11/12] Unmark test as skip. --- test/test_issue35.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/test_issue35.py b/test/test_issue35.py index 99caece..c62e302 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -2,8 +2,6 @@ import pytest -# this should not segfault -@pytest.mark.skip # temporarily disabled to check other tests def test_issue35_1() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) assert cdd.matrix_canonicalize(mat) == ({0}, None) From e36065935ea978a838bbe87363095cb659415b20 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Tue, 24 Sep 2024 21:35:15 +0100 Subject: [PATCH 12/12] Fix test. --- test/test_issue35.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_issue35.py b/test/test_issue35.py index c62e302..593871b 100644 --- a/test/test_issue35.py +++ b/test/test_issue35.py @@ -4,7 +4,7 @@ def test_issue35_1() -> None: mat = cdd.matrix_from_array([[0, 0, 0]], rep_type=cdd.RepType.INEQUALITY) - assert cdd.matrix_canonicalize(mat) == ({0}, None) + assert cdd.matrix_canonicalize(mat) == ({0}, set(), [None]) assert mat.array == []