From: Kent B. <ke...@th...> - 2002-11-19 17:17:11
|
You're absolutely right that the current solution isn't it. Fixed-sized (even preference-based) regions offend my aesthetics. If we can't do better than that, okay, but we should at least try. Kent > -----Original Message----- > From: jun...@li... > [mailto:jun...@li...] On Behalf Of > Erik Mattsson > Sent: Monday, November 18, 2002 1:55 PM > To: jun...@li... > Subject: [Junit-devel] Patch suggestion for ComparsionFailure > > > > Hi > > The new ComparsionFailuer class to handle string comparsions > is great but I thought it could be improved a little bit. Im > thinking about the "..." handling, it is annoying that the > comparsion is only displaying the difference between the > expected and the actual string. This makes it hard to check > why some assertEquals fails such as the examples below. > My patch displays some common strings before and after the > difference, > either by going back/forward 15 chars or to the nearest > space. This would > make it easier to spot the difference and perhaps find out > why the testcase > failed before looking in the code. > It is not a big improvement but it might avoid some confusion > when comparing strings or objects (by toString()). Any > feedback or suggestions?? > > // > // EXAMPLES > // assertion > assertEquals("abcdef", "abdef" ) > // old result, which shows no help at all > expected:<...c...> but was:<......> > // with patch it could be: > expected:<abcdef> but was:<bcdef> > > > //assertion > assertEquals( "b=16, c=15, d=15, e=5", "b=16, c=16, d=15, > e=5" ); // old output - which 5 is wrong? expected:<...5...> > but was:<...6...> // with patch expected:<... c=15, ...> but > was:<... c=16, ...> > > > //assertion > assertEquals( > "IPTC=[caption='caption';contact='contact';]", > "IPTC=[caption='caption';city='gbg';contact='contact';]" > ); //old output expected:<......> but was:<...ity='gbg';c...> > //with patch expected:<...ion='caption';contact='contact...> but was: > <...ion='caption';city='gbg';contact='contact...> > > > // stupid short example to show the problem with comparing > // floats in a toString() method. > assertEquals( Float.toString( 0.124235f), Float.toString( > 0.124435f ) ); // old result - which one of the 2's are > wrong? expected:<...2...> but was:<...4...> // with patch: > expected:<0.124235> but was:<0.124435> > > > Please look through my patch suggestion and give me some > feedback on it... > > > Here is my patch suggestion: (dunno if I got the diff correct) 9d8 > < public final static int COMMON_FIX_LENGTH = 15; > 55,79d53 > < int pos = fExpected.lastIndexOf( ' ', i ); > < if ( ( pos == -1 ) || ( ( i - pos ) > > COMMON_FIX_LENGTH ) ) { > < i -= COMMON_FIX_LENGTH; > < } else { > < i = pos; > < } > < > < pos = fExpected.indexOf( ' ', j ); > < if ( ( pos == -1 ) || ( ( pos - j ) > > COMMON_FIX_LENGTH ) ) { > < j += COMMON_FIX_LENGTH; > < } else { > < j = pos; > < } > < > < pos = fActual.indexOf( ' ', k ); > < if ( ( pos == -1 ) || ( ( pos - k ) > > COMMON_FIX_LENGTH ) ) { > < k += COMMON_FIX_LENGTH; > < } else { > < k = pos; > < } > < > < i = ( i < 0 ? 0 : i ); > < j = ( j >= fExpected.length() ? > fExpected.length() - 1 : j ); > < k = ( k >= fActual.length() ? > fActual.length() > - 1 : k ); > < > > > Regards Erik Mattsson > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > Junit-devel mailing list > Jun...@li... > https://lists.sourceforge.net/lists/listinfo/j> unit-devel > |