[Quickfix-developers] Additional test cases for ParserTestCase::extractLength
Brought to you by:
orenmnero
From: Brian E. <Br...@ma...> - 2003-11-04 20:29:32
|
In ParserTestCase.h: class extractLength : public Test { bool onSetup( Parser*& pObject ); void onRun( Parser& object ); std::string m_normalLength; std::string m_badLength; std::string m_negativeLength; // New Code Start std::string m_incomplete_1; std::string m_incomplete_2; // New Code End } In ParserTestCase.cpp: bool ParserTestCase::extractLength::onSetup( Parser*& pObject ) { m_normalLength =3D = "8=3DFIX.4.2\0019=3D12\00135=3DA\001108=3D30\00110=3D31\001"; m_badLength =3D = "8=3DFIX.4.2\0019=3DA\00135=3DA\001108=3D30\00110=3D31\001"; m_negativeLength =3D = "8=3DFIX.4.2\0019=3D-1\00135=3DA\001108=3D30\00110=3D31\001"; // New Code Start m_incomplete_1 =3D "8=3DFIX.4.2"; m_incomplete_2 =3D "8=3DFIX.4.2\0019=3D12"; // New Code End return true; } void ParserTestCase::extractLength::onRun( Parser& object ) { int length =3D 0; std::string::size_type pos =3D 0; assert( object.extractLength(length, pos, m_normalLength) ); assert( length =3D=3D 12 ); assert( pos =3D=3D 15 ); // Add this line: pos =3D 0; try { object.extractLength(length, pos, m_badLength); assert(false); } catch( MessageParseError& ) {} // Add this line: assert(pos =3D=3D 0); try { object.extractLength(length, pos, m_negativeLength); assert(false); } catch( MessageParseError& ) {} // New Code Start assert(pos =3D=3D 0); try { assert( object.extractLength(length, pos, m_incomplete_1) =3D=3D = false); assert(pos =3D=3D 0); } catch( MessageParseError& ) { assert(false) } =09 try { assert( object.extractLength(length, pos, m_incomplete_2) =3D=3D = false); assert(pos =3D=3D 0); } catch( MessageParseError& ) { assert(false) } // New Code End assert( !object.extractLength(length, pos, "") ); } -----Original Message----- From: Joerg Thoennes [mailto:Joe...@ma...] Sent: Monday, November 03, 2003 11:12 AM To: Oren Miller Cc: Brian Egge; 'Miller, Oren'; 'qui...@li...' Subject: Re: [Quickfix-developers] BodyLength or CheckSum missing Oren Miller wrote: > Post you're fix to the developers list and someone > will check it in. It would be a good idea to update > the test case to reflect this problem. Do you have a > test case that will make the old code fail but is > succesfull with your code? Something like this will > allow us to get it into the codebase quicker. Thanks! I already thought of checking this in, but was lacking the test case. So if you have a test case, Brian, I could do the check-in. Cheers, J=F6rg > --- Brian Egge <Br...@ma...> wrote: >=20 >>I think I have found the problem that is causing >>this error. The error only >>surfaces when the 8=3DFix is received, but the >>9=3Dlength has not been. >> >>The problem is in Parser.cpp: >> >>bool Parser::extractLength( int& length, >>std::string::size_type& pos, >> const std::string& >>buffer ) >>throw( MessageParseError& ) >>{ QF_STACK_PUSH(Parser::extractLength) >> >> if( !buffer.size() ) return false; >> =20 >> std::string::size_type startPos =3D buffer.find( >>"\0019=3D", 0 ); >> if( pos =3D=3D std::string::npos ) return false; >>// This should be: >>// if( startPos =3D=3D std::string::npos ) return >>false; >>// >> startPos +=3D 3; >> std::string::size_type endPos =3D buffer.find( >>"\001", startPos ); >>// This should be: >>// if( endPos =3D=3D std::string::npos ) return false; >>// >> pos =3D endPos + 1; >> >>What happens with the current code is strLength gets >>set to 'FIX.4.x'. This >>raises and exception and throws a MessageParseError. >> >>I'd like to get this fix checked in to CVS. I >>haven't used CVS before, and >>I don't know who is given access to check in >>changes. >> >>Brian=20 >> >> >>-----Original Message----- >>From: Miller, Oren >>[mailto:OM...@ri...] >>Sent: Tuesday, October 14, 2003 6:02 PM >>To: Br...@ma...; >>qui...@li... >>Subject: Re: [Quickfix-developers] BodyLength or >>CheckSum missing >> >> >>Do yo have an example of a message that causes this >>error? >> >>-------------------------- >>Sent from my BlackBerry Wireless Handheld >> >> >>-----Original Message----- >>From: Brian Egge <Br...@ma...> >>To: qui...@li... >><qui...@li...> >>Sent: Tue Oct 14 10:10:55 2003 >>Subject: [Quickfix-developers] BodyLength or >>CheckSum missing >> >>I seem to be having a problem where I get an >>InvalidMessage("BodyLength or >>CheckSum missing") exception thrown from >>Message::validate(). When I look >>at my logs, or even re-parse the message, everything >>is in tact. I can't >>see any reason why this exception is being thrown.=20 >>I only get this with one >>venue, and it only happens every couple of days or >>so. Has anyone else had >>this problem before? >> >>I've added some more logging to this area, and I >>think I will figure it out >>soon. The item that concerns me more is that this >>exception does not get >>handled, and the EH eventually calls terminate() or >>abort() and the program >>ends. I'm using version 1.6, and I have two >>suggestions. >> >>1) "bool SocketConnection::read( SocketAcceptor& a, >>SocketServer& s )" has >>an exception handler, while bool >>"SocketConnection::read( SocketConnector& s >>)" does not. My exception occurs in the latter >>case. I copied the >>exception code from the one read to the other to >>make them consistent. >> >>2) I added try {} catch(...) statement to the >>onStart() procedures, to trap >>any unhanded exceptions. I'd rather have the >>thread safely terminate than >>for my whole app to end. =20 >> >>If these changes are worthwhile, I'll try to merge >>them in CVS.=20 >> >>-Brian >> >> >> >=20 > ------------------------------------------------------- >=20 >>This SF.net email is sponsored by: SF.net Giveback >>Program. >>SourceForge.net hosts over 70,000 Open Source >>Projects. >>See the people who have HELPED US provide better >>services: >>Click here: http://sourceforge.net/supporters.php >>_______________________________________________ >>Quickfix-developers mailing list >>Qui...@li... >> >=20 > https://lists.sourceforge.net/lists/listinfo/quickfix-developers >=20 >> >> > ------------------------------------------------------- >=20 >>This SF.net email is sponsored by: SF.net Giveback >>Program. >>Does SourceForge.net help you be more productive?=20 >>Does it >>help you create better code? SHARE THE LOVE, and >>help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Quickfix-developers mailing list >>Qui...@li... >> >=20 > https://lists.sourceforge.net/lists/listinfo/quickfix-developers >=20 >=20 > __________________________________ > Do you Yahoo!? > Exclusive Video Premiere - Britney Spears > http://launch.yahoo.com/promos/britneyspears/ >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers >=20 --=20 Joerg Thoennes http://macd.com Tel.: +49 (0)241 44597-24 Macdonald Associates GmbH Fax : +49 (0)241 44597-10 Lothringer Str. 52, D-52070 Aachen |