[Clam-devel] Re: Some steps to take on your own
JunJun
wangjun at dsp.ac.cn
Tue Jun 10 22:07:23 PDT 2008
The patch on ContiguousSegmentation, and notice that the test/UnitTests/SConscript and test/FunctionalTests/SConscript are not included in the patch.
----- Original Message -----
From: "JunJun" <wangjun at dsp.ac.cn>
To: "David García Garzón" <dgarcia at iua.upf.edu>
Cc: <clam-devel at llistes.projectes.lafarga.org>
Sent: Wednesday, June 11, 2008 1:02 PM
Subject: Re: Some steps to take on your own
>
>
>> 1. Implement the testStoreOn() test method. The code could be something like
>> that:
>>
>> #include "XMLTestHelper.hxx"
>> ....
>>
>> void testStoreOn()
>> {
>> const double onsets[] = {90,100,110};
>> ContiguousSegmentation segmentation(200, onsets, onsets+3);
>>
>> std::ostringstream stream;
>> XMLStorage::Dump(segmentation, "Segmentation", stream);
>>
>> CLAMTEST_ASSERT_XML_EQUAL(
>> "<Segmentation size="3">90 100 110</Segmentation>"
>> , stream.str());
>> }
>>
>> Notice that this would be the output we are outputing now for such
>> segmentation as we are doing now.
>> Do the needed changes to compile and to make it fail (by doing nothing in
>> StoreOn)
>
> Done. It fails.
>>
>> 2. We should make it green by building in StoreOn an array, filling it in with
>> the method we did the other day, and delegating onto the array store on.
>>
>> ContinuousSegmentation::StoreOn(Storage & storage) const
>> {
>> CLAM::Array array;
>> fillArray(array);
>> array.StoreOn(storage);
>> }
>>
>> In order to be able to use the fillArray method in StoreOn which is a const
>> method, you should define fillArray method also as a constant one:
>> void fillArray(DataArray & array) const <- this const
>> The constness should be changed at onece in the base class and in the derived
>> classes.
>>
>> After doing that you will see that the test is not as green as we should
>> expect. We catched an error!! What's happening there?
>>
>> Reply with copy to the list or at irc.
>
> Yes, we catch the error displayed as below:
> ************************************************************************
> * . CLAMTest::ContiguousSegmentationTest::testStoreOn
> *
> *This application has requested the Runtime to terminate it in an unusual way.
> *Please contact the application's support team for more information.
> *
> *...................................................................................................
> *
> *..........................terminate called after throwing an instance of 'CLAM::ErrAssertionFailed'
> * what(): Array::operator[]: Index out of range
> *This may happen if you forgot to call SetSize(...) in your code.
> *This is now needed. Just calling Resize() is not enough any more
> **************************************************************************
> Then I checked the code and caught a bug in ContiguousSegmentation:
> void fillArray(DataArray& segmentation) const
> {
> unsigned nSegments= _onsets.size();
> segmentation.Resize(nSegments-1);
> segmentation.SetSize(nSegments-1);
> for(unsigned i=1; i<nSegments; i++)
> segmentation[i]=_onsets[i]; //Bug!! it should be "segmentation[i-1]=_onsets[i]; "
> }
> which is not introduced by me who just did a copy&paste job :-)
> I've fixed that and the test is GREEN now:
>
> .............................................................................................................................
>
>
> OK (125 tests)
>
>
> Cool!
> What's the next?
>
>>
>> David.
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6_11_fillArrayAndDumpToXML_Congtiguous.patch
Type: application/octet-stream
Size: 5060 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080611/89936317/attachment-0004.obj>
More information about the clam-devel
mailing list