Boost logo

Boost Users :

Subject: [Boost-users] [Test] strange test behavior
From: Emre Guney (emreguney_at_[hidden])
Date: 2009-07-29 12:40:12


Greetings,

I have the following class to test a class named Scoring (implements a graph
using Boost Graph Library). If the line marked with //!!! below is
uncommented the scores yielded by _s.getNetwork().getVertexScore(*it) are
garbage values (like 2.57117366e+29 ). If it is commented test fails but the
values are initial (sensible) values. When I run the same function apart
from the tests, the function behaves correctly and gives correct calculated
scores.

There should be a context problem but I could not figure it out. I would be
grateful for any suggestions and ideas.

class TestScoring
{
    Scoring _s;

public:

    TestScoring() {
        _s = Scoring("test_vertices_small.txt", "test_edges_small.txt");
    }

    ~TestScoring()
{

}

    void test_calculatedScores()
    {
        float vertex_scores[] = { 0.75, 4.0/3, 1.5, 1.0/3, 0.005 };
        std::size_t n_vertex = sizeof(vertex_scores)/sizeof(float);

        //!!! this call changes the behavior of the test
        //!!!
_s.run(1,2);
        VertexIterator it, itEnd;
        for(boost::tie(it, itEnd) = _s.getNetwork().getVertexIterator(); it
!= itEnd;
it++)

        {
            BOOST_CHECK_CLOSE(_s.getNetwork().getVertexScore(*it),
vertex_scores[_s.getNetwork().getVertexIndex(*it)], 0.00001f);
        }
 }

};

// TestScoring is called from the following suite

class TestSuiteScoring: public
test_suite
{

public:
    TestSuiteScoring():
test_suite("test_suite_scoring")
    {
        shared_ptr<TestScoring> instance(new TestScoring());
        test_case *calculatedScores = BOOST_CLASS_TEST_CASE(
&TestScoring::test_calculatedScores, instance);
        add(calculatedScores);
    }
    ~TestScoring() {
        //instance.release();
    }
};

Emre



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net