Hi, I'm new with boost, and I'm actually experiencing some weird issues... I wrote a class which is basically a wrapper around boost::adjacency_list, and two other nested classes which are wrappers around boost::adjacency_list::vertex_iterator and boost::adjacency_list::out_edge_iterator. I tested theses three classes with the boost unit test framework : everything works fine. Then I wrote a class Tree, which uses boost::shared_/weak_ptr. But when I try to test this class with boost UTF, the test case of the previous graph's out_edge_iterator returns some failures (different depending of the functions from the Tree class called on the test). It's particularly weird considering that these classes share nothing in common except the fact that they use different part of boost. Maybe somebody have a hint on what I am doing wrong !? I used UTF with dynamic lininking, boost1.42 from ubuntu 10.10 package. Thanks, Bruno
AMDG On 04/04/2011 07:32 AM, Bruno Belarte wrote:
I'm new with boost, and I'm actually experiencing some weird issues...
I wrote a class which is basically a wrapper around boost::adjacency_list, and two other nested classes which are wrappers around boost::adjacency_list::vertex_iterator and boost::adjacency_list::out_edge_iterator. I tested theses three classes with the boost unit test framework : everything works fine.
Then I wrote a class Tree, which uses boost::shared_/weak_ptr. But when I try to test this class with boost UTF, the test case of the previous graph's out_edge_iterator returns some failures (different depending of the functions from the Tree class called on the test). It's particularly weird considering that these classes share nothing in common except the fact that they use different part of boost.
Maybe somebody have a hint on what I am doing wrong !? I used UTF with dynamic lininking, boost1.42 from ubuntu 10.10 package.
Sounds like undefined behavior. You should check that you're not using invalid iterators. Other than that I'd have to see the code. In Christ, Steven Watanabe
On 04/04/2011 16:58, Steven Watanabe wrote:
AMDG
On 04/04/2011 07:32 AM, Bruno Belarte wrote:
I'm new with boost, and I'm actually experiencing some weird issues...
I wrote a class which is basically a wrapper around boost::adjacency_list, and two other nested classes which are wrappers around boost::adjacency_list::vertex_iterator and boost::adjacency_list::out_edge_iterator. I tested theses three classes with the boost unit test framework : everything works fine.
Then I wrote a class Tree, which uses boost::shared_/weak_ptr. But when I try to test this class with boost UTF, the test case of the previous graph's out_edge_iterator returns some failures (different depending of the functions from the Tree class called on the test). It's particularly weird considering that these classes share nothing in common except the fact that they use different part of boost.
Maybe somebody have a hint on what I am doing wrong !? I used UTF with dynamic lininking, boost1.42 from ubuntu 10.10 package.
Sounds like undefined behavior. You should check that you're not using invalid iterators. Other than that I'd have to see the code.
Thanks for your quick answer Steven. I don't think it's undefined behavior (but I may be wrong of course :). Everything works fine, the program run as I expect when I only test all the graph stuff. I attached some code (the makefile is generated by Qt4). As you will probably see if you compile and execute, a test fails. But if I comment the tests in TreeTesting.cxx, everything run smoothely, but the previous error was not related to the commented piece of code. Bruno
In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
[Please do not mail me a copy of your followup] boost-users@lists.boost.org spake the secret code <4D99D669.1050504@gmail.com> thusly:
Maybe somebody have a hint on what I am doing wrong !? I used UTF with dynamic lininking, boost1.42 from ubuntu 10.10 package.
Aside from checking for undefined behavior at Steven mentioned, you might want to check that each unit test case is completely independent of other test cases: no static data, no shared globals, etc. This pattern is called the "Fresh Fixture" pattern: http://xunitpatterns.com/Fresh%20Fixture.html You may also find it useful to read through my 5-part tutorial on doing test-driven development in C++ with Boost.Test: http://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/ Legalize Adulthood! http://legalizeadulthood.wordpress.com
On 04/04/2011 23:07, Richard wrote:
Aside from checking for undefined behavior at Steven mentioned, you might want to check that each unit test case is completely independent of other test cases: no static data, no shared globals, etc. This pattern is called the "Fresh Fixture" pattern: http://xunitpatterns.com/Fresh%20Fixture.html
You may also find it useful to read through my 5-part tutorial on doing test-driven development in C++ with Boost.Test: http://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te...
Thanks for your answer Richard. I already have read your tutorial. I wrote my classes to be self sufficient, so they don't access any global or shared memory. In my test suite, I use fixture and all I set during the set-up is a data structure (the one I want to test) and some stuff to fill the data structure (int and std::string, no pointers), so the fixture do not share anything (except if boost's smart pointers or BGL has some memory issues, but I really doubt it :) But again, the weird part is when I call Tree's template member function (template on iterators), Graph's tests that previously passed now failed (some values are not in the right place, like if they were add in the wrong order). Anyway, thanks for your help. Bruno
participants (3)
-
Bruno Belarte
-
legalize+jeeves@mail.xmission.com
-
Steven Watanabe