Skip to content

adding SepTest - #400

Open
godardma wants to merge 7 commits into
codac-team:codac2_devfrom
godardma:parallelepiped_update
Open

adding SepTest#400
godardma wants to merge 7 commits into
codac-team:codac2_devfrom
godardma:parallelepiped_update

Conversation

@godardma

@godardma godardma commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Je n'ai pas fait de page dédiée dans la doc, je ne sais pas si c'est nécessaire pour ça. Au besoin j'en ferais une minimale.

@Jordan08

Jordan08 commented Sep 5, 2026

Copy link
Copy Markdown

The CI failures on this branch all come down to one line in SepTest, plus a second, independent issue in the same separate().

The failures

  • macosmatrix.yml fails at compile time, on the Python bindings:
    codac2_SepTest.h:30:42: error: while substituting deduced template arguments into function template 'shared_ptr...' while building python/src/core/separators/codac2_py_SepTest.cpp.
  • tests.yml, vcmatrix.yml and dockercentos.yml fail at run time, in the Python package suite:
    ERROR: test_SepTest (codac.tests.test_SepTest.TestSepTest)
      File ".../codac/tests/test_SepTest.py", line 25, in test_SepTest
        inner,outer = sep_test.separate(x1)
    ValueError: The following Codac assertion failed:
      In function: separate      x.size() == _sep.size()
      In file: src/core/separators/codac2_SepTest.cpp:19
    
  • unixmatrix.yml and dockermatrix.yml are green because they do not run python -m unittest discover codac.tests, and because the C++ test never runs either (see the third point below).

1. _sep is a reference member bound to a temporary

class SepTest : public Sep<SepTest>
{
    template<typename S> requires IsSepBaseOrPtr<S>
    SepTest(const S& s) : Sep<SepTest>(size_of(s)), _sep(s) { }   // line 30
  protected:
    const Collection<SepBase>& _sep;                              // reference
};

s is a separator, not a Collection, so _sep(s) has to materialize a temporary Collection<SepBase> and bind the reference to it. Lifetime extension does not apply to a reference member initialized in a ctor-initializer: the temporary is destroyed when the constructor exits, and _sep dangles for every later use.

SepNot, which stores the same thing, holds it by value:

const Collection<SepBase> _sep;    // codac2_SepNot.h:44

That is also exactly what the macOS error points at — column 42 of line 30 is _sep(s). AppleClang rejects the conversion outright; GCC and MSVC accept it and produce the dangling member instead, which is why the same defect surfaces as a compile error on one platform and as a runtime failure on the others.

2. _sep.size() is not the dimension

Collection<T> derives from std::list<std::shared_ptr<T>>, so _sep.size() is the number of separators in the collection — one — not the dimension of the domain. The test passes boxes of dimension 3, so the assertion fails on every platform that reaches it. SepNot compares against the separator's own size, set from size_of(s) in the base initializer:

assert_release(x.size() == this->size());   // codac2_SepNot.h:35

3. codac2_tests_SepTest.cpp never runs

tests/CMakeLists.txt registers tests through an explicit SRC_TESTS list, and core/separators/codac2_tests_SepTest is not in it (the separator entries stop at SepCartProd, SepCtcBoundary, SepInter, SepInverse, SepPolygon, SepProj, SepQInter, SepTransform, SepUnion, SepVisible). So the C++ test is compiled by no one and ctest reports 156/156 green; only the Python suite, which discovers by file name, catches the bug. Adding the entry would have caught both issues in the C++ matrix too.

Suggested patch

--- a/src/core/separators/codac2_SepTest.h
+++ b/src/core/separators/codac2_SepTest.h
@@
     protected:
 
-      const Collection<SepBase>& _sep;
+      const Collection<SepBase> _sep;
--- a/src/core/separators/codac2_SepTest.cpp
+++ b/src/core/separators/codac2_SepTest.cpp
@@
-    assert_release(x.size() == _sep.size());
+    assert_release(x.size() == this->size());
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@
   core/separators/codac2_tests_SepQInter
+  core/separators/codac2_tests_SepTest
   core/separators/codac2_tests_SepTransform
   core/separators/codac2_tests_SepUnion

@godardma

godardma commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Le problème venait bien du "&" en trop, merci Jordan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants