Swap arguments of CPPUNIT_ASSERT_EQUAL

Expected value should be passed as a first argument to CPPUNIT_ASSERT_EQUAL and actual value as a second one.
This commit is contained in:
Artur Wieczorek
2017-09-01 08:26:15 +02:00
parent ed638371a7
commit 691f530359

View File

@@ -671,7 +671,7 @@ void TextCtrlTestCase::PositionToXYMultiLine()
m_text->Clear(); m_text->Clear();
const long numChars_0 = 0; const long numChars_0 = 0;
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_0 ); CPPUNIT_ASSERT_EQUAL( numChars_0, m_text->GetLastPosition() );
struct { long x, y; } coords_0[numChars_0+1] = struct { long x, y; } coords_0[numChars_0+1] =
{ { 0, 0 } }; { { 0, 0 } };
@@ -679,19 +679,19 @@ void TextCtrlTestCase::PositionToXYMultiLine()
{ {
long x, y; long x, y;
ok = m_text->PositionToXY(i, &x, &y); ok = m_text->PositionToXY(i, &x, &y);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x, coords_0[i].x ); CPPUNIT_ASSERT_EQUAL( coords_0[i].x, x );
CPPUNIT_ASSERT_EQUAL( y, coords_0[i].y ); CPPUNIT_ASSERT_EQUAL( coords_0[i].y, y );
} }
ok = m_text->PositionToXY(WXSIZEOF(coords_0), NULL, NULL); ok = m_text->PositionToXY(WXSIZEOF(coords_0), NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
// one line // one line
text = wxS("1234"); text = wxS("1234");
m_text->SetValue(text); m_text->SetValue(text);
const long numChars_1 = 4; const long numChars_1 = 4;
wxASSERT( numChars_1 == text.Length() ); wxASSERT( numChars_1 == text.Length() );
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_1 ); CPPUNIT_ASSERT_EQUAL( numChars_1, m_text->GetLastPosition() );
struct { long x, y; } coords_1[numChars_1+1] = struct { long x, y; } coords_1[numChars_1+1] =
{ { 0, 0 }, { 1, 0 }, { 2, 0}, { 3, 0 }, { 4, 0 } }; { { 0, 0 }, { 1, 0 }, { 2, 0}, { 3, 0 }, { 4, 0 } };
@@ -699,12 +699,12 @@ void TextCtrlTestCase::PositionToXYMultiLine()
{ {
long x, y; long x, y;
ok = m_text->PositionToXY(i, &x, &y); ok = m_text->PositionToXY(i, &x, &y);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x, coords_1[i].x ); CPPUNIT_ASSERT_EQUAL( coords_1[i].x, x );
CPPUNIT_ASSERT_EQUAL( y, coords_1[i].y ); CPPUNIT_ASSERT_EQUAL( coords_1[i].y, y );
} }
ok = m_text->PositionToXY(WXSIZEOF(coords_1), NULL, NULL); ok = m_text->PositionToXY(WXSIZEOF(coords_1), NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
// few lines // few lines
text = wxS("123\nab\nX"); text = wxS("123\nab\nX");
@@ -716,7 +716,7 @@ void TextCtrlTestCase::PositionToXYMultiLine()
#else #else
const long numChars_2 = 8; const long numChars_2 = 8;
#endif // WXMSW/!WXMSW #endif // WXMSW/!WXMSW
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_2 ); CPPUNIT_ASSERT_EQUAL( numChars_2, m_text->GetLastPosition() );
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Note: Two new line characters refer to the same X-Y position. // Note: Two new line characters refer to the same X-Y position.
struct { long x, y; } coords_2[numChars_2 + 1] = struct { long x, y; } coords_2[numChars_2 + 1] =
@@ -734,12 +734,12 @@ void TextCtrlTestCase::PositionToXYMultiLine()
{ {
long x, y; long x, y;
ok = m_text->PositionToXY(i, &x, &y); ok = m_text->PositionToXY(i, &x, &y);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x, coords_2[i].x ); CPPUNIT_ASSERT_EQUAL( coords_2[i].x, x );
CPPUNIT_ASSERT_EQUAL( y, coords_2[i].y ); CPPUNIT_ASSERT_EQUAL( coords_2[i].y, y );
} }
ok = m_text->PositionToXY(WXSIZEOF(coords_2), NULL, NULL); ok = m_text->PositionToXY(WXSIZEOF(coords_2), NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
// only empty lines // only empty lines
text = wxS("\n\n\n"); text = wxS("\n\n\n");
@@ -751,7 +751,7 @@ void TextCtrlTestCase::PositionToXYMultiLine()
#else #else
const long numChars_3 = 3; const long numChars_3 = 3;
#endif // WXMSW/!WXMSW #endif // WXMSW/!WXMSW
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_3 ); CPPUNIT_ASSERT_EQUAL( numChars_3, m_text->GetLastPosition() );
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Note: Two new line characters refer to the same X-Y position. // Note: Two new line characters refer to the same X-Y position.
struct { long x, y; } coords_3[numChars_3 + 1] = struct { long x, y; } coords_3[numChars_3 + 1] =
@@ -771,12 +771,12 @@ void TextCtrlTestCase::PositionToXYMultiLine()
{ {
long x, y; long x, y;
ok = m_text->PositionToXY(i, &x, &y); ok = m_text->PositionToXY(i, &x, &y);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x, coords_3[i].x ); CPPUNIT_ASSERT_EQUAL( coords_3[i].x, x );
CPPUNIT_ASSERT_EQUAL( y, coords_3[i].y ); CPPUNIT_ASSERT_EQUAL( coords_3[i].y, y );
} }
ok = m_text->PositionToXY(WXSIZEOF(coords_3), NULL, NULL); ok = m_text->PositionToXY(WXSIZEOF(coords_3), NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
// mixed empty/non-empty lines // mixed empty/non-empty lines
text = wxS("123\na\n\nX\n\n"); text = wxS("123\na\n\nX\n\n");
@@ -788,7 +788,7 @@ void TextCtrlTestCase::PositionToXYMultiLine()
#else #else
const long numChars_4 = 10; const long numChars_4 = 10;
#endif // WXMSW/!WXMSW #endif // WXMSW/!WXMSW
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_4 ); CPPUNIT_ASSERT_EQUAL( numChars_4, m_text->GetLastPosition() );
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Note: Two new line characters refer to the same X-Y position. // Note: Two new line characters refer to the same X-Y position.
struct { long x, y; } coords_4[numChars_4 + 1] = struct { long x, y; } coords_4[numChars_4 + 1] =
@@ -812,12 +812,12 @@ void TextCtrlTestCase::PositionToXYMultiLine()
{ {
long x, y; long x, y;
ok = m_text->PositionToXY(i, &x, &y); ok = m_text->PositionToXY(i, &x, &y);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x, coords_4[i].x ); CPPUNIT_ASSERT_EQUAL( coords_4[i].x, x );
CPPUNIT_ASSERT_EQUAL( y, coords_4[i].y ); CPPUNIT_ASSERT_EQUAL( coords_4[i].y, y );
} }
ok = m_text->PositionToXY(WXSIZEOF(coords_4), NULL, NULL); ok = m_text->PositionToXY(WXSIZEOF(coords_4), NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
} }
void TextCtrlTestCase::XYToPositionMultiLine() void TextCtrlTestCase::XYToPositionMultiLine()
@@ -830,7 +830,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
m_text->Clear(); m_text->Clear();
const long maxLineLength_0 = 0+1; const long maxLineLength_0 = 0+1;
const long numLines_0 = 1; const long numLines_0 = 1;
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), numLines_0 ); CPPUNIT_ASSERT_EQUAL( numLines_0, m_text->GetNumberOfLines() );
long pos_0[numLines_0+1][maxLineLength_0+1] = long pos_0[numLines_0+1][maxLineLength_0+1] =
{ { 0, -1 }, { { 0, -1 },
{ -1, -1 } }; { -1, -1 } };
@@ -838,7 +838,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
for( long x = 0; x < maxLineLength_0+1; x++ ) for( long x = 0; x < maxLineLength_0+1; x++ )
{ {
long p = m_text->XYToPosition(x, y); long p = m_text->XYToPosition(x, y);
CPPUNIT_ASSERT_EQUAL( p, pos_0[y][x] ); CPPUNIT_ASSERT_EQUAL( pos_0[y][x], p );
} }
// one line // one line
@@ -846,7 +846,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
m_text->SetValue(text); m_text->SetValue(text);
const long maxLineLength_1 = 4+1; const long maxLineLength_1 = 4+1;
const long numLines_1 = 1; const long numLines_1 = 1;
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), numLines_1 ); CPPUNIT_ASSERT_EQUAL( numLines_1, m_text->GetNumberOfLines() );
long pos_1[numLines_1+1][maxLineLength_1+1] = long pos_1[numLines_1+1][maxLineLength_1+1] =
{ { 0, 1, 2, 3, 4, -1 }, { { 0, 1, 2, 3, 4, -1 },
{ -1, -1, -1, -1, -1, -1 } }; { -1, -1, -1, -1, -1, -1 } };
@@ -854,7 +854,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
for( long x = 0; x < maxLineLength_1+1; x++ ) for( long x = 0; x < maxLineLength_1+1; x++ )
{ {
long p = m_text->XYToPosition(x, y); long p = m_text->XYToPosition(x, y);
CPPUNIT_ASSERT_EQUAL( p, pos_1[y][x] ); CPPUNIT_ASSERT_EQUAL( pos_1[y][x], p );
} }
// few lines // few lines
@@ -862,7 +862,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
m_text->SetValue(text); m_text->SetValue(text);
const long maxLineLength_2 = 4; const long maxLineLength_2 = 4;
const long numLines_2 = 3; const long numLines_2 = 3;
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), numLines_2 ); CPPUNIT_ASSERT_EQUAL( numLines_2, m_text->GetNumberOfLines() );
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Note: New lines are occupied by two characters. // Note: New lines are occupied by two characters.
long pos_2[numLines_2 + 1][maxLineLength_2 + 1] = long pos_2[numLines_2 + 1][maxLineLength_2 + 1] =
@@ -882,7 +882,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
for( long x = 0; x < maxLineLength_2+1; x++ ) for( long x = 0; x < maxLineLength_2+1; x++ )
{ {
long p = m_text->XYToPosition(x, y); long p = m_text->XYToPosition(x, y);
CPPUNIT_ASSERT_EQUAL( p, pos_2[y][x] ); CPPUNIT_ASSERT_EQUAL( pos_2[y][x], p );
} }
// only empty lines // only empty lines
@@ -890,7 +890,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
m_text->SetValue(text); m_text->SetValue(text);
const long maxLineLength_3 = 1; const long maxLineLength_3 = 1;
const long numLines_3 = 4; const long numLines_3 = 4;
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), numLines_3 ); CPPUNIT_ASSERT_EQUAL( numLines_3, m_text->GetNumberOfLines() );
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Note: New lines are occupied by two characters. // Note: New lines are occupied by two characters.
long pos_3[numLines_3 + 1][maxLineLength_3 + 1] = long pos_3[numLines_3 + 1][maxLineLength_3 + 1] =
@@ -912,7 +912,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
for( long x = 0; x < maxLineLength_3+1; x++ ) for( long x = 0; x < maxLineLength_3+1; x++ )
{ {
long p = m_text->XYToPosition(x, y); long p = m_text->XYToPosition(x, y);
CPPUNIT_ASSERT_EQUAL( p, pos_3[y][x] ); CPPUNIT_ASSERT_EQUAL( pos_3[y][x], p );
} }
// mixed empty/non-empty lines // mixed empty/non-empty lines
@@ -920,7 +920,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
m_text->SetValue(text); m_text->SetValue(text);
const long maxLineLength_4 = 4; const long maxLineLength_4 = 4;
const long numLines_4 = 6; const long numLines_4 = 6;
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), numLines_4 ); CPPUNIT_ASSERT_EQUAL( numLines_4, m_text->GetNumberOfLines() );
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Note: New lines are occupied by two characters. // Note: New lines are occupied by two characters.
long pos_4[numLines_4 + 1][maxLineLength_4 + 1] = long pos_4[numLines_4 + 1][maxLineLength_4 + 1] =
@@ -946,7 +946,7 @@ void TextCtrlTestCase::XYToPositionMultiLine()
for( long x = 0; x < maxLineLength_4+1; x++ ) for( long x = 0; x < maxLineLength_4+1; x++ )
{ {
long p = m_text->XYToPosition(x, y); long p = m_text->XYToPosition(x, y);
CPPUNIT_ASSERT_EQUAL( p, pos_4[y][x] ); CPPUNIT_ASSERT_EQUAL( pos_4[y][x], p );
} }
} }
@@ -960,49 +960,49 @@ void TextCtrlTestCase::PositionToXYSingleLine()
// empty field // empty field
m_text->Clear(); m_text->Clear();
const long numChars_0 = 0; const long numChars_0 = 0;
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_0 ); CPPUNIT_ASSERT_EQUAL( numChars_0, m_text->GetLastPosition() );
for ( long i = 0; i <= numChars_0; i++ ) for ( long i = 0; i <= numChars_0; i++ )
{ {
long x0, y0; long x0, y0;
ok = m_text->PositionToXY(i, &x0, &y0); ok = m_text->PositionToXY(i, &x0, &y0);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x0, i ); CPPUNIT_ASSERT_EQUAL( i, x0 );
CPPUNIT_ASSERT_EQUAL( y0, 0 ); CPPUNIT_ASSERT_EQUAL( 0, y0 );
} }
ok = m_text->PositionToXY(numChars_0+1, NULL, NULL); ok = m_text->PositionToXY(numChars_0+1, NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
// pure one line // pure one line
text = wxS("1234"); text = wxS("1234");
m_text->SetValue(text); m_text->SetValue(text);
const long numChars_1 = text.Length(); const long numChars_1 = text.Length();
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_1 ); CPPUNIT_ASSERT_EQUAL( numChars_1, m_text->GetLastPosition() );
for ( long i = 0; i <= numChars_1; i++ ) for ( long i = 0; i <= numChars_1; i++ )
{ {
long x1, y1; long x1, y1;
ok = m_text->PositionToXY(i, &x1, &y1); ok = m_text->PositionToXY(i, &x1, &y1);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x1, i ); CPPUNIT_ASSERT_EQUAL( i, x1 );
CPPUNIT_ASSERT_EQUAL( y1, 0 ); CPPUNIT_ASSERT_EQUAL( 0, y1 );
} }
ok = m_text->PositionToXY(numChars_1+1, NULL, NULL); ok = m_text->PositionToXY(numChars_1+1, NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
// with new line characters // with new line characters
text = wxS("123\nab\nX"); text = wxS("123\nab\nX");
m_text->SetValue(text); m_text->SetValue(text);
const long numChars_2 = text.Length(); const long numChars_2 = text.Length();
CPPUNIT_ASSERT_EQUAL( m_text->GetLastPosition(), numChars_2 ); CPPUNIT_ASSERT_EQUAL( numChars_2, m_text->GetLastPosition() );
for ( long i = 0; i <= numChars_2; i++ ) for ( long i = 0; i <= numChars_2; i++ )
{ {
long x2, y2; long x2, y2;
ok = m_text->PositionToXY(i, &x2, &y2); ok = m_text->PositionToXY(i, &x2, &y2);
CPPUNIT_ASSERT_EQUAL( ok, true ); CPPUNIT_ASSERT_EQUAL( true, ok );
CPPUNIT_ASSERT_EQUAL( x2, i ); CPPUNIT_ASSERT_EQUAL( i, x2 );
CPPUNIT_ASSERT_EQUAL( y2, 0 ); CPPUNIT_ASSERT_EQUAL( 0, y2 );
} }
ok = m_text->PositionToXY(numChars_2+1, NULL, NULL); ok = m_text->PositionToXY(numChars_2+1, NULL, NULL);
CPPUNIT_ASSERT_EQUAL( ok, false ); CPPUNIT_ASSERT_EQUAL( false, ok );
} }
void TextCtrlTestCase::XYToPositionSingleLine() void TextCtrlTestCase::XYToPositionSingleLine()
@@ -1013,49 +1013,49 @@ void TextCtrlTestCase::XYToPositionSingleLine()
wxString text; wxString text;
// empty field // empty field
m_text->Clear(); m_text->Clear();
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), 1 ); CPPUNIT_ASSERT_EQUAL( 1, m_text->GetNumberOfLines() );
for( long x = 0; x < m_text->GetLastPosition()+2; x++ ) for( long x = 0; x < m_text->GetLastPosition()+2; x++ )
{ {
long p0 = m_text->XYToPosition(x, 0); long p0 = m_text->XYToPosition(x, 0);
if ( x <= m_text->GetLastPosition() ) if ( x <= m_text->GetLastPosition() )
CPPUNIT_ASSERT_EQUAL( p0, x ); CPPUNIT_ASSERT_EQUAL( x, p0 );
else else
CPPUNIT_ASSERT_EQUAL( p0, -1 ); CPPUNIT_ASSERT_EQUAL( -1, p0 );
p0 = m_text->XYToPosition(x, 1); p0 = m_text->XYToPosition(x, 1);
CPPUNIT_ASSERT_EQUAL( p0, -1 ); CPPUNIT_ASSERT_EQUAL( -1, p0 );
} }
// pure one line // pure one line
text = wxS("1234"); text = wxS("1234");
m_text->SetValue(text); m_text->SetValue(text);
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), 1 ); CPPUNIT_ASSERT_EQUAL( 1, m_text->GetNumberOfLines() );
for( long x = 0; x < m_text->GetLastPosition()+2; x++ ) for( long x = 0; x < m_text->GetLastPosition()+2; x++ )
{ {
long p1 = m_text->XYToPosition(x, 0); long p1 = m_text->XYToPosition(x, 0);
if ( x <= m_text->GetLastPosition() ) if ( x <= m_text->GetLastPosition() )
CPPUNIT_ASSERT_EQUAL( p1, x ); CPPUNIT_ASSERT_EQUAL( x, p1 );
else else
CPPUNIT_ASSERT_EQUAL( p1, -1 ); CPPUNIT_ASSERT_EQUAL( -1, p1 );
p1 = m_text->XYToPosition(x, 1); p1 = m_text->XYToPosition(x, 1);
CPPUNIT_ASSERT_EQUAL( p1, -1 ); CPPUNIT_ASSERT_EQUAL( -1, p1 );
} }
// with new line characters // with new line characters
text = wxS("123\nab\nX"); text = wxS("123\nab\nX");
m_text->SetValue(text); m_text->SetValue(text);
CPPUNIT_ASSERT_EQUAL( m_text->GetNumberOfLines(), 1 ); CPPUNIT_ASSERT_EQUAL( 1, m_text->GetNumberOfLines() );
for( long x = 0; x < m_text->GetLastPosition()+2; x++ ) for( long x = 0; x < m_text->GetLastPosition()+2; x++ )
{ {
long p2 = m_text->XYToPosition(x, 0); long p2 = m_text->XYToPosition(x, 0);
if ( x <= m_text->GetLastPosition() ) if ( x <= m_text->GetLastPosition() )
CPPUNIT_ASSERT_EQUAL( p2, x ); CPPUNIT_ASSERT_EQUAL( x, p2 );
else else
CPPUNIT_ASSERT_EQUAL( p2, -1 ); CPPUNIT_ASSERT_EQUAL( -1, p2 );
p2 = m_text->XYToPosition(x, 1); p2 = m_text->XYToPosition(x, 1);
CPPUNIT_ASSERT_EQUAL( p2, -1 ); CPPUNIT_ASSERT_EQUAL( -1, p2 );
} }
} }