Hi
I am tring to test some method of vector STL. I putting here entire code. Please some try it out. Please Tell me, why setUp is not failing?
**************************************************
#ifndef __TEST_H__
#define __TEST_H__
#include<vector>
#include "cppunit/extensions/HelperMacros.h"
using namespace std;
typedef vector <char>charvect;
class vect : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( vect );
CPPUNIT_TEST( SizePushBackTest );
CPPUNIT_TEST_SUITE_END();
private:
charvect v;
}
void vect::SizePushBackTest ()
{
CPPUNIT_ASSERT_EQUAL(char('f'),v[5]);
int siz=v.size();
CPPUNIT_ASSERT_EQUAL(5,siz);
for( int i=0; i<v.size();i++)
{
CPPUNIT_ASSERT_EQUAL(char(i+'a'),v[i]);
}
}
As initialy v size was zero. then i am resizing in the setup to 5. while assigning the value to v. It should fail setUp.
I have tried this thing without the CPPUNIT.
So here Cppunit is not fullfilling the purpose.
- Regards
Ritesh
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-04-09
The member function returns a reference to the element of the controlled sequence at position pos. If that position is invalid, the behavior is undefined.
In another word, it does not have to fail!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Xiaofeng Zhao" <xf10036@users.sourceforge.net> wrote in message
news:162@37108.11795.sourceforge.net...
>
> The member function returns a reference to the element of the controlled
sequence at position pos. If that position is invalid, the behavior is
undefined.
>
The member function "at()" throws an exception if out of bounds. The array
subscription operator "[]" has undefined behaviour under the same condition.
// Johan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I am tring to test some method of vector STL. I putting here entire code. Please some try it out. Please Tell me, why setUp is not failing?
**************************************************
#ifndef __TEST_H__
#define __TEST_H__
#include<vector>
#include "cppunit/extensions/HelperMacros.h"
using namespace std;
typedef vector <char>charvect;
class vect : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( vect );
CPPUNIT_TEST( SizePushBackTest );
CPPUNIT_TEST_SUITE_END();
private:
charvect v;
public:
void setUp();
void SizePushBackTest ();
};
#endif
**************************************************
#include<cctype>
#include"text1.h"
void vect::setUp()
{
v.resize(5);
for(int i=0;i<10;i++)
{
//push_back(i+'a');
v[i]=i+'a';
}
}
void vect::SizePushBackTest ()
{
CPPUNIT_ASSERT_EQUAL(char('f'),v[5]);
int siz=v.size();
CPPUNIT_ASSERT_EQUAL(5,siz);
for( int i=0; i<v.size();i++)
{
CPPUNIT_ASSERT_EQUAL(char(i+'a'),v[i]);
}
}
As initialy v size was zero. then i am resizing in the setup to 5. while assigning the value to v. It should fail setUp.
I have tried this thing without the CPPUNIT.
So here Cppunit is not fullfilling the purpose.
- Regards
Ritesh
The member function returns a reference to the element of the controlled sequence at position pos. If that position is invalid, the behavior is undefined.
In another word, it does not have to fail!
"Xiaofeng Zhao" <xf10036@users.sourceforge.net> wrote in message
news:162@37108.11795.sourceforge.net...
>
> The member function returns a reference to the element of the controlled
sequence at position pos. If that position is invalid, the behavior is
undefined.
>
The member function "at()" throws an exception if out of bounds. The array
subscription operator "[]" has undefined behaviour under the same condition.
// Johan