Changeset 1368

Show
Ignore:
Timestamp:
08/09/08 08:23:58 (5 months ago)
Author:
jtv
Message:

Test helpers cleanup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1367 r1368  
     12008-08-09  Jeroen T. Vermeulen <jtv@xs4all.nl> 
     2 test/test000.cxx, test/test002.cxx, test/test004.cxx, test/test007.cxx, 
     3 test/test085.cxx, test/test090.cxx, test/test092.cxx, test/test_helpers.hxx, 
     4 test/unit/test_float.cxx, test/unit/test_pipeline.cxx, 
     5 test/unit/test_sql_cursor.cxx, test/unit/test_stateless_cursor.cxx, 
     6 test/unit/test_test_helpers.cxx: 
     7  - Fixed PQXX_CHECK_THROWS ignoring std::exception-derived exceptions 
     8  - Made PQXX_CHECK_* macros rely more on functions--less preprocessor magic 
     9  - PQXX_CHECK_* macros consistently require semicolon at end of invocation 
     10  - Fixed some signedness warnings in PQXX_CHECK_[NOT_]EQUAL invocations 
     11  - Reused PQXX_CHECK_NOTREACHED to simplify PQXX_CHECK_THROWS 
    1122008-08-09  Jeroen T. Vermeulen <jtv@xs4all.nl> 
    213 configure.ac.in: 
  • trunk/test/test000.cxx

    r1354 r1368  
    2727template<typename T> void testitems(const T &I, typename T::size_type s) 
    2828{ 
    29   PQXX_CHECK_EQUAL(I.size(), s, "Wrong size in items class.") 
     29  PQXX_CHECK_EQUAL(I.size(), s, "Wrong size in items class."); 
    3030 
    3131  for ( ; s; --s) 
    3232  { 
    3333    const typename T::size_type value(I[s-1]); 
    34     PQXX_CHECK_EQUAL(value, s, "Wrong value in items object.") 
     34    PQXX_CHECK_EQUAL(value, s, "Wrong value in items object."); 
    3535  } 
    3636} 
     
    3838void check(string ref, string val, string vdesc) 
    3939{ 
    40   PQXX_CHECK_EQUAL(val, ref, "String mismatch for " + vdesc) 
     40  PQXX_CHECK_EQUAL(val, ref, "String mismatch for " + vdesc); 
    4141} 
    4242 
     
    8585{ 
    8686  PQXX_CHECK_EQUAL(oid_none, 
    87         0
     87        0u
    8888        "InvalidIod is not zero as it used to be.  This may conceivably " 
    89         "cause problems in libpqxx.") 
     89        "cause problems in libpqxx."); 
    9090 
    9191  if (cursor_base::prior() >= 0 || cursor_base::backward_all() >= 0) 
  • trunk/test/test002.cxx

    r1360 r1368  
    3535        bad_connect(), 
    3636        exception, 
    37         "Invalid connection string did not cause exception.") 
     37        "Invalid connection string did not cause exception."); 
    3838 
    3939  // Set up connection to database 
     
    6464        rtable, 
    6565        R.column_table(result::tuple::size_type(0)), 
    66         "Inconsistent answers from column_table()") 
     66        "Inconsistent answers from column_table()"); 
    6767 
    6868  const string rcol = R.column_name(0); 
     
    7171        crtable, 
    7272        rtable, 
    73         "Field looked up by name gives different origin.") 
     73        "Field looked up by name gives different origin."); 
    7474#endif 
    7575 
  • trunk/test/test004.cxx

    r1361 r1368  
    8989  for (int i=0; (i < 20) && !L.Done(); ++i) 
    9090  { 
    91     PQXX_CHECK_EQUAL(notifs, 0, "Got unexpected notifications.") 
     91    PQXX_CHECK_EQUAL(notifs, 0, "Got unexpected notifications."); 
    9292 
    9393    // Sleep one second using a libpqxx-internal function.  Kids, don't try 
     
    100100  cout << endl; 
    101101 
    102   PQXX_CHECK_NOT_EQUAL(L.Done(), false, "No notification received.") 
    103   PQXX_CHECK_EQUAL(notifs, 1, "Got too many notifications.") 
     102  PQXX_CHECK_NOT_EQUAL(L.Done(), false, "No notification received."); 
     103  PQXX_CHECK_EQUAL(notifs, 1, "Got too many notifications."); 
    104104} 
    105105 
  • trunk/test/test007.cxx

    r1361 r1368  
    6262        R.column_type(result::tuple::size_type(0)), 
    6363        rctype, 
    64         "Inconsistent result::column_type().") 
     64        "Inconsistent result::column_type()."); 
    6565 
    6666    const string rct = to_string(rctype); 
  • trunk/test/test085.cxx

    r1363 r1368  
    1818        rhs,            \ 
    1919        lhs,            \ 
    20         "Executing " name " as prepared statement yields different results.")
     20        "Executing " name " as prepared statement yields different results.");
    2121  PQXX_CHECK_EQUAL(lhs.empty(), false, "Result for " name " is empty.") 
    2222 
     
    111111        C.prepare_now("ReadPGTables"), 
    112112        exception, 
    113         "prepare_now() succeeded on dropped statement.") 
     113        "prepare_now() succeeded on dropped statement."); 
    114114 
    115115    // Just to try and confuse things, "unprepare" twice 
     
    122122        T.prepared("ReadPGTables").exec(), 
    123123        exception, 
    124         "Execute unprepared statement didn't fail.") 
     124        "Execute unprepared statement didn't fail."); 
    125125 
    126126    // Re-prepare the same statement and test again 
     
    141141        C.prepare("ReadPGTables", Q_readpgtables + " ORDER BY tablename"), 
    142142        exception, 
    143         "Bad redefinition of statement went unnoticed.") 
     143        "Bad redefinition of statement went unnoticed."); 
    144144 
    145145    cout << "Testing prepared statement with parameter..." << endl; 
     
    187187        T.prepared("SeeTables")()()("hi mom!").exec(), 
    188188        exception, 
    189         "No error for too many parameters.") 
     189        "No error for too many parameters."); 
    190190 
    191191    PQXX_CHECK_THROWS( 
    192192        T.prepared("SeeTables")("who, me?").exec(), 
    193193        exception, 
    194         "No error for too few parameters.") 
     194        "No error for too few parameters."); 
    195195  } 
    196196  catch (const feature_not_supported &e) 
  • trunk/test/test090.cxx

    r1356 r1368  
    6767  PQXX_CHECK_NOT_EQUAL(C.adorn_name(nametest), 
    6868        C.adorn_name(nametest), 
    69         "\"Unique\" names are not unique.") 
     69        "\"Unique\" names are not unique."); 
    7070 
    7171  dotests(N); 
  • trunk/test/test092.cxx

    r1357 r1368  
    3939  PQXX_CHECK_EQUAL(L[0][0].as<size_t>(), 
    4040        data.size(), 
    41         "Length of field in database does not match original length.") 
     41        "Length of field in database does not match original length."); 
    4242 
    4343  const result R( T.exec("SELECT " + Field + " FROM " + Table) ); 
     
    4545  const binarystring roundtrip(R[0][0]); 
    4646 
    47   PQXX_CHECK_EQUAL(string(roundtrip.str()), data, "Data came back different.") 
     47  PQXX_CHECK_EQUAL(string(roundtrip.str()), data, "Data came back different."); 
    4848 
    4949  PQXX_CHECK_EQUAL(roundtrip.size(), 
    5050        data.size(), 
    51         "Binary string reports wrong size.") 
     51        "Binary string reports wrong size."); 
    5252 
    5353  // People seem to like the multi-line invocation style, where you get your 
  • trunk/test/test_helpers.hxx

    r1363 r1368  
    144144// Unconditional test failure. 
    145145#define PQXX_CHECK_NOTREACHED(desc) \ 
    146         throw pqxx::test::test_failure(__FILE__, __LINE__, desc) 
     146        pqxx::test::check_notreached(__FILE__, __LINE__, (desc)) 
     147void check_notreached(const char file[], int line, PGSTD::string desc) 
     148
     149  throw test_failure(file, line, desc); 
     150
    147151 
    148152// Verify that a condition is met, similar to assert() 
    149153#define PQXX_CHECK(condition, desc) \ 
    150         if (!(condition))       \ 
    151                 throw pqxx::test::test_failure( \ 
    152                         __FILE__,       \ 
    153                         __LINE__,       \ 
    154                         PGSTD::string(desc) + \ 
    155                         " (failed expression: " # condition ")"); 
     154        pqxx::test::check(__FILE__, __LINE__, (condition), #condition, (desc)) 
     155void check( 
     156        const char file[], 
     157        int line, 
     158        bool condition, 
     159        const char text[],  
     160        PGSTD::string desc) 
     161
     162  if (!condition) 
     163    throw test_failure(file, line, desc + " (failed expression: " + text + ")"); 
     164
    156165 
    157166// Verify that variable has the expected value. 
    158167#define PQXX_CHECK_EQUAL(actual, expected, desc) \ 
    159         if (!((expected) == (actual))) throw pqxx::test::test_failure( \ 
     168        pqxx::test::check_equal( \ 
    160169                __FILE__, \ 
    161170                __LINE__, \ 
    162                 PGSTD::string(desc) + " " \ 
    163                 "(" #actual " <> " #expected ": " + \ 
    164                 "expected=" + to_string(expected) + ", " \ 
    165                 "actual=" + to_string(actual) + ")"); 
     171                (actual), \ 
     172                #actual, \ 
     173                (expected), \ 
     174                #expected, \ 
     175                (desc)) 
     176template<typename ACTUAL, typename EXPECTED> 
     177inline void check_equal( 
     178        const char file[], 
     179        int line, 
     180        ACTUAL actual, 
     181        const char actual_text[], 
     182        EXPECTED expected,  
     183        const char expected_text[], 
     184        PGSTD::string desc) 
     185
     186  if (expected == actual) return; 
     187  const PGSTD::string fulldesc = 
     188        desc + " (" + actual_text + " <> " + expected_text + ": " 
     189        "expected=" + to_string(expected) + ", " 
     190        "actual=" + to_string(actual) + ")"; 
     191  throw pqxx::test::test_failure(file, line, fulldesc); 
     192
    166193 
    167194// Verify that two values are not equal. 
    168195#define PQXX_CHECK_NOT_EQUAL(value1, value2, desc) \ 
    169         if (!((value1) != (value2))) throw pqxx::test::test_failure( \ 
     196        pqxx::test::check_not_equal( \ 
    170197                __FILE__, \ 
    171198                __LINE__, \ 
    172                 PGSTD::string(desc) + " " \ 
    173                 "(" #value1 " == " #value2 ": " \ 
    174                 "both are " + to_string(value2) + ")"); 
     199                (value1), \ 
     200                #value1, \ 
     201                (value2), \ 
     202                #value2, \ 
     203                (desc)) 
     204template<typename VALUE1, typename VALUE2> 
     205inline void check_not_equal( 
     206        const char file[], 
     207        int line, 
     208        VALUE1 value1, 
     209        const char text1[], 
     210        VALUE2 value2,  
     211        const char text2[], 
     212        PGSTD::string desc) 
     213
     214  if (value1 != value2) return; 
     215  const PGSTD::string fulldesc = 
     216        desc + " (" + text1 + " == " + text2 + ": " 
     217        "both are " + to_string(value2) + ")"; 
     218  throw pqxx::test::test_failure(file, line, fulldesc); 
     219
    175220 
    176221// Verify that "action" throws "exception_type." 
    177222#define PQXX_CHECK_THROWS(action, exception_type, desc) \ 
    178         { \ 
    179           bool pqxx_check_throws_failed = true; \ 
     223        do { \ 
    180224          try \ 
    181225          { \ 
    182226            action ; \ 
    183             pqxx_check_throws_failed = false; \ 
     227            PQXX_CHECK_NOTREACHED( \ 
     228                PGSTD::string(desc) + \ 
     229                " (\"" #action "\" did not throw " #exception_type ")"); \ 
    184230          } \ 
    185           catch (const PGSTD::exception &e) {} \ 
     231          catch (const exception_type &e) {} \ 
    186232          catch (...) \ 
    187233          { \ 
    188             throw pqxx::test::test_failure( \ 
    189                 __FILE__, \ 
    190                 __LINE__, \ 
    191                 PGSTD::string(desc) + " " \ 
    192                 "(" #action ": " "unexpected exception)"); \ 
     234            PQXX_CHECK_NOTREACHED( \ 
     235                PGSTD::string(desc) + \ 
     236                " (\"" #action "\" " \ 
     237                "threw exception other than " #exception_type ")"); \ 
    193238          } \ 
    194           if (!pqxx_check_throws_failed) throw pqxx::test::test_failure( \ 
    195                 __FILE__, \ 
    196                 __LINE__, \ 
    197                 PGSTD::string(desc) + " " \ 
    198                 "(" #action ": " \ 
    199                 "expected=" #exception_type ", " \ 
    200                 "did not throw)"); \ 
    201         } 
     239        } while (false) 
    202240 
    203241} // namespace test 
  • trunk/test/unit/test_float.cxx

    r1328 r1368  
    1919{ 
    2020  double inf = make_infinity<double>(); 
    21   PQXX_CHECK_EQUAL(to_string(inf), "infinity", "Infinity not as expected") 
    22   PQXX_CHECK_EQUAL(to_string(-inf), "-infinity", "Negative infinity is broken") 
     21  PQXX_CHECK_EQUAL(to_string(inf), "infinity", "Infinity not as expected"); 
     22  PQXX_CHECK_EQUAL(to_string(-inf), "-infinity", "Negative infinity is broken"); 
    2323} 
    2424} 
  • trunk/test/unit/test_pipeline.cxx

    r1341 r1368  
    1818  pipe.flush(); 
    1919  result r = trans.exec("SELECT 2"); 
    20   PQXX_CHECK_EQUAL(r.size(), 1, "Wrong query result after flushing pipeline."); 
     20  PQXX_CHECK_EQUAL(r.size(), 1u, "Wrong query result after flushing pipeline."); 
    2121  PQXX_CHECK_EQUAL( 
    2222    r[0][0].as<int>(), 
     
    3434  pipe.complete(); 
    3535  r = trans.exec("SELECT 4"); 
    36   PQXX_CHECK_EQUAL(r.size(), 1, "Wrong query result after complete()."); 
     36  PQXX_CHECK_EQUAL(r.size(), 1u, "Wrong query result after complete()."); 
    3737  PQXX_CHECK_EQUAL( 
    3838    r[0][0].as<int>(), 
     
    4242  // The complete() also received any pending query results from the backend. 
    4343  r = pipe.retrieve(q); 
    44   PQXX_CHECK_EQUAL(r.size(), 1, "Wrong result from pipeline."); 
     44  PQXX_CHECK_EQUAL(r.size(), 1u, "Wrong result from pipeline."); 
    4545  PQXX_CHECK_EQUAL( 
    4646    r[0][0].as<int>(), 
  • trunk/test/unit/test_sql_cursor.cxx

    r1349 r1368  
    2222 
    2323  result empty_result = forward.empty_result(); 
    24   PQXX_CHECK_EQUAL(empty_result.size(), 0, "Empty result not empty"); 
     24  PQXX_CHECK_EQUAL(empty_result.size(), 0u, "Empty result not empty"); 
    2525 
    2626  cursor_base::difference_type displacement = 0; 
    2727  result one = forward.fetch(1, displacement); 
    28   PQXX_CHECK_EQUAL(one.size(), 1, "Fetched wrong number of rows"); 
     28  PQXX_CHECK_EQUAL(one.size(), 1u, "Fetched wrong number of rows"); 
    2929  PQXX_CHECK_EQUAL(one[0][0].as<string>(), "1", "Unexpected result"); 
    3030  PQXX_CHECK_EQUAL(displacement, 1, "Wrong displacement"); 
     
    3434  PQXX_CHECK_EQUAL(offset, 1, "Unexpected offset from move()"); 
    3535  PQXX_CHECK_EQUAL(displacement, 1, "Unexpected displacement after move()"); 
    36   PQXX_CHECK_EQUAL(forward.pos(), 2, "Wrong position after move()"); 
     36  PQXX_CHECK_EQUAL(forward.pos(), 2u, "Wrong position after move()"); 
    3737  PQXX_CHECK_EQUAL(forward.endpos(), -1, "endpos() unexpectedly set"); 
    3838 
    3939  result row = forward.fetch(0, displacement); 
    40   PQXX_CHECK_EQUAL(row.size(), 0, "fetch(0, displacement) returns rows"); 
     40  PQXX_CHECK_EQUAL(row.size(), 0u, "fetch(0, displacement) returns rows"); 
    4141  PQXX_CHECK_EQUAL(displacement, 0, "Unexpected displacement after fetch(0)"); 
    42   PQXX_CHECK_EQUAL(forward.pos(), 2, "fetch(0, displacement) affected pos()"); 
     42  PQXX_CHECK_EQUAL(forward.pos(), 2u, "fetch(0, displacement) affected pos()"); 
    4343 
    4444  row = forward.fetch(0); 
    45   PQXX_CHECK_EQUAL(row.size(), 0, "fetch(0) fetched wrong number of rows"); 
    46   PQXX_CHECK_EQUAL(forward.pos(), 2, "fetch(0) moved cursor"); 
    47   PQXX_CHECK_EQUAL(forward.pos(), 2, "fetch(0) affected pos()"); 
     45  PQXX_CHECK_EQUAL(row.size(), 0u, "fetch(0) fetched wrong number of rows"); 
     46  PQXX_CHECK_EQUAL(forward.pos(), 2u, "fetch(0) moved cursor"); 
     47  PQXX_CHECK_EQUAL(forward.pos(), 2u, "fetch(0) affected pos()"); 
    4848 
    4949  offset = forward.move(1); 
     
    5252 
    5353  row = forward.fetch(1); 
    54   PQXX_CHECK_EQUAL(row.size(), 1, "fetch(1) returned wrong number of rows"); 
    55   PQXX_CHECK_EQUAL(forward.pos(), 4, "fetch(1) results in bad pos()"); 
     54  PQXX_CHECK_EQUAL(row.size(), 1u, "fetch(1) returned wrong number of rows"); 
     55  PQXX_CHECK_EQUAL(forward.pos(), 4u, "fetch(1) results in bad pos()"); 
    5656  PQXX_CHECK_EQUAL(row[0][0].as<string>(), "4", "pos() is lying"); 
    5757 
    5858  empty_result = forward.fetch(1, displacement); 
    59   PQXX_CHECK_EQUAL(empty_result.size(), 0, "Got rows at end of cursor"); 
    60   PQXX_CHECK_EQUAL(forward.pos(), 5, "Not at one-past-end position"); 
     59  PQXX_CHECK_EQUAL(empty_result.size(), 0u, "Got rows at end of cursor"); 
     60  PQXX_CHECK_EQUAL(forward.pos(), 5u, "Not at one-past-end position"); 
    6161  PQXX_CHECK_EQUAL(forward.endpos(), 5, "Failed to notice end position"); 
    6262  PQXX_CHECK_EQUAL(displacement, 1, "Wrong displacement at end position"); 
     
    6464  offset = forward.move(5, displacement); 
    6565  PQXX_CHECK_EQUAL(offset, 0, "move() lied at end of result set"); 
    66   PQXX_CHECK_EQUAL(forward.pos(), 5, "pos() is beyond end"); 
     66  PQXX_CHECK_EQUAL(forward.pos(), 5u, "pos() is beyond end"); 
    6767  PQXX_CHECK_EQUAL(forward.endpos(), 5, "endpos() changed after end position"); 
    6868  PQXX_CHECK_EQUAL(displacement, 0, "Wrong displacement after end position"); 
     
    9696  // Fetch entire result set at once. 
    9797  result rows = forward3.fetch(cursor_base::all(), displacement); 
    98   PQXX_CHECK_EQUAL(rows.size(), 4, "Unexpected number of rows in result set"); 
     98  PQXX_CHECK_EQUAL(rows.size(), 4u, "Unexpected number of rows in result set"); 
    9999  PQXX_CHECK_EQUAL(displacement, 5, "displacement != rows+1"); 
    100   PQXX_CHECK_EQUAL(forward3.pos(), 5, "Bad pos() after fetching all rows"); 
     100  PQXX_CHECK_EQUAL(forward3.pos(), 5u, "Bad pos() after fetching all rows"); 
    101101  PQXX_CHECK_EQUAL(forward3.endpos(), 5, "Bad endpos() after fetching"); 
    102102 
     
    111111 
    112112  offset = forward_empty.move(3, displacement); 
    113   PQXX_CHECK_EQUAL(forward_empty.pos(), 1, "Bad pos() at end of result"); 
     113  PQXX_CHECK_EQUAL(forward_empty.pos(), 1u, "Bad pos() at end of result"); 
    114114  PQXX_CHECK_EQUAL(forward_empty.endpos(), 1, "Bad endpos() in empty result"); 
    115115  PQXX_CHECK_EQUAL(displacement, 1, "Bad displacement in empty result"); 
     
    128128        false); 
    129129 
    130   PQXX_CHECK_EQUAL(scroll.pos(), 0, "Scroll cursor's initial pos() is wrong"); 
     130  PQXX_CHECK_EQUAL(scroll.pos(), 0u, "Scroll cursor's initial pos() is wrong"); 
    131131  PQXX_CHECK_EQUAL(scroll.endpos(), -1, "New scroll cursor has endpos() set"); 
    132132 
    133133  result rows = scroll.fetch(cursor_base::next()); 
    134   PQXX_CHECK_EQUAL(rows.size(), 1, "Scroll cursor is broken"); 
    135   PQXX_CHECK_EQUAL(scroll.pos(), 1, "Scroll cursor's pos() is broken"); 
     134  PQXX_CHECK_EQUAL(rows.size(), 1u, "Scroll cursor is broken"); 
     135  PQXX_CHECK_EQUAL(scroll.pos(), 1u, "Scroll cursor's pos() is broken"); 
    136136  PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set prematurely"); 
    137137 
     
    141141  rows = scroll.fetch(cursor_base::prior()); 
    142142  PQXX_CHECK_EQUAL(rows.empty(), true, "Turning around on fetch() broke"); 
    143   PQXX_CHECK_EQUAL(scroll.pos(), 0, "pos() is not back at zero"); 
     143  PQXX_CHECK_EQUAL(scroll.pos(), 0u, "pos() is not back at zero"); 
    144144  PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set on wrong side of result"); 
    145145 
     
    150150  PQXX_CHECK_EQUAL(offset, 0, "Rows found before beginning"); 
    151151  PQXX_CHECK_EQUAL(displacement, 0, "Failed to bounce off beginning"); 
    152   PQXX_CHECK_EQUAL(scroll.pos(), 0, "pos() moved back from zero"); 
     152  PQXX_CHECK_EQUAL(scroll.pos(), 0u, "pos() moved back from zero"); 
    153153  PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set on left-side bounce"); 
    154154 
     
    158158  PQXX_CHECK_EQUAL(offset, 4, "Offset mismatch"); 
    159159  PQXX_CHECK_EQUAL(displacement, 4, "Displacement mismatch"); 
    160   PQXX_CHECK_EQUAL(scroll.pos(), 4, "Position mismatch"); 
     160  PQXX_CHECK_EQUAL(scroll.pos(), 4u, "Position mismatch"); 
    161161  PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set at weird time"); 
    162162 
     
    164164  PQXX_CHECK_EQUAL(offset, 3, "Offset mismatch"); 
    165165  PQXX_CHECK_EQUAL(displacement, -4, "Displacement mismatch"); 
    166   PQXX_CHECK_EQUAL(scroll.pos(), 0, "Hard bounce failed"); 
     166  PQXX_CHECK_EQUAL(scroll.pos(), 0u, "Hard bounce failed"); 
    167167  PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set during hard bounce"); 
    168168 
    169169  rows = scroll.fetch(3); 
    170   PQXX_CHECK_EQUAL(scroll.pos(), 3, "Bad pos()"); 
    171   PQXX_CHECK_EQUAL(rows.size(), 3, "Wrong number of rows"); 
     170  PQXX_CHECK_EQUAL(scroll.pos(), 3u, "Bad pos()"); 
     171  PQXX_CHECK_EQUAL(rows.size(), 3u, "Wrong number of rows"); 
    172172  PQXX_CHECK_EQUAL(rows[2][0].as<int>(), 3, "pos() does not match data"); 
    173173  rows = scroll.fetch(-1); 
    174   PQXX_CHECK_EQUAL(scroll.pos(), 2, "Bad pos()"); 
     174  PQXX_CHECK_EQUAL(scroll.pos(), 2u, "Bad pos()"); 
    175175  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 2, "pos() does not match data"); 
    176176 
    177177  rows = scroll.fetch(1); 
    178   PQXX_CHECK_EQUAL(scroll.pos(), 3, "Bad pos() after inverse turnaround"); 
     178  PQXX_CHECK_EQUAL(scroll.pos(), 3u, "Bad pos() after inverse turnaround"); 
    179179  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 3, "Data position mismatch"); 
    180180} 
     
    191191  cursor_base::difference_type displacement = 0; 
    192192  result rows = adopted.fetch(cursor_base::all(), displacement); 
    193   PQXX_CHECK_EQUAL(rows.size(), 3, "Wrong number of rows in result"); 
     193  PQXX_CHECK_EQUAL(rows.size(), 3u, "Wrong number of rows in result"); 
    194194  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 1, "Wrong result data"); 
    195195  PQXX_CHECK_EQUAL(rows[2][0].as<int>(), 3, "Wrong result data"); 
     
    199199 
    200200  rows = adopted.fetch(cursor_base::backward_all(), displacement); 
    201   PQXX_CHECK_EQUAL(rows.size(), 3, "Wrong number of rows in result"); 
     201  PQXX_CHECK_EQUAL(rows.size(), 3u, "Wrong number of rows in result"); 
    202202  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 3, "Wrong result data"); 
    203203  PQXX_CHECK_EQUAL(rows[2][0].as<int>(), 1, "Wrong result data"); 
    204204  PQXX_CHECK_EQUAL(displacement, -4, "Wrong displacement"); 
    205   PQXX_CHECK_EQUAL(adopted.pos(), 0, "Failed to recognize starting position"); 
     205  PQXX_CHECK_EQUAL(adopted.pos(), 0u, "Failed to recognize starting position"); 
    206206  PQXX_CHECK_EQUAL(adopted.endpos(), -1, "endpos() set too early"); 
    207207 
    208208  cursor_base::difference_type offset = adopted.move(cursor_base::all()); 
    209209  PQXX_CHECK_EQUAL(offset, 3, "Unexpected move() offset"); 
    210   PQXX_CHECK_EQUAL(adopted.pos(), 4, "Bad position on adopted cursor"); 
     210  PQXX_CHECK_EQUAL(adopted.pos(), 4u, "Bad position on adopted cursor"); 
    211211  PQXX_CHECK_EQUAL(adopted.endpos(), 4, "endpos() not set properly"); 
    212212 
     
    263263  work trans2(conn, "trans2"); 
    264264  result rows = with_hold.fetch(1); 
    265   PQXX_CHECK_EQUAL(rows.size(), 1, "Did not get 1 row from with-hold cursor"); 
     265  PQXX_CHECK_EQUAL(rows.size(), 1u, "Did not get 1 row from with-hold cursor"); 
    266266 
    267267  // Cursor without hold is closed on commit. 
  • trunk/test/unit/test_stateless_cursor.cxx

    r1317 r1368  
    1717  PQXX_CHECK_EQUAL(rows.empty(), true, "Empty result not empty"); 
    1818  rows = empty.retrieve(0, 1); 
    19   PQXX_CHECK_EQUAL(rows.size(), 0, "Empty result returned rows"); 
     19  PQXX_CHECK_EQUAL(rows.size(), 0u, "Empty result returned rows"); 
    2020 
    21   PQXX_CHECK_EQUAL(empty.size(), 0, "Empty cursor not empty"); 
     21  PQXX_CHECK_EQUAL(empty.size(), 0u, "Empty cursor not empty"); 
    2222 
    2323  PQXX_CHECK_THROWS( 
     
    3232        false); 
    3333 
    34   PQXX_CHECK_EQUAL(stateless.size(), 10, "stateless_cursor::size() mismatch"); 
     34  PQXX_CHECK_EQUAL(stateless.size(), 10u, "stateless_cursor::size() mismatch"); 
    3535 
    3636  // Retrieve nothing. 
    3737  rows = stateless.retrieve(1, 1); 
    38   PQXX_CHECK_EQUAL(rows.size(), 0, "1-to-1 retrieval not empty"); 
     38  PQXX_CHECK_EQUAL(rows.size(), 0u, "1-to-1 retrieval not empty"); 
    3939 
    4040  // Retrieve two rows. 
    4141  rows = stateless.retrieve(1, 3); 
    42   PQXX_CHECK_EQUAL(rows.size(), 2, "Retrieved wrong number of rows"); 
     42  PQXX_CHECK_EQUAL(rows.size(), 2u, "Retrieved wrong number of rows"); 
    4343  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 1, "Data/position mismatch"); 
    4444  PQXX_CHECK_EQUAL(rows[1][0].as<int>(), 2, "Data/position mismatch"); 
     
    4646  // Retrieve same rows in reverse. 
    4747  rows = stateless.retrieve(2, 0); 
    48   PQXX_CHECK_EQUAL(rows.size(), 2, "Retrieved wrong number of rows"); 
     48  PQXX_CHECK_EQUAL(rows.size(), 2u, "Retrieved wrong number of rows"); 
    4949  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 2, "Data/position mismatch"); 
    5050  PQXX_CHECK_EQUAL(rows[1][0].as<int>(), 1, "Data/position mismatch"); 
     
    5252  // Retrieve beyond end. 
    5353  rows = stateless.retrieve(9, 13); 
    54   PQXX_CHECK_EQUAL(rows.size(), 1, "Row count wrong at end"); 
     54  PQXX_CHECK_EQUAL(rows.size(), 1u, "Row count wrong at end"); 
    5555  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 9, "Data/pos mismatch at end"); 
    5656 
    5757  // Retrieve beyond beginning. 
    5858  rows = stateless.retrieve(0, -4); 
    59   PQXX_CHECK_EQUAL(rows.size(), 1, "Row count wrong at beginning"); 
     59  PQXX_CHECK_EQUAL(rows.size(), 1u, "Row count wrong at beginning"); 
    6060  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 0, "Data/pos mismatch at beginning"); 
    6161 
    6262  // Retrieve entire result set backwards. 
    6363  rows = stateless.retrieve(10, -15); 
    64   PQXX_CHECK_EQUAL(rows.size(), 10, "Reverse complete retrieval is broken"); 
     64  PQXX_CHECK_EQUAL(rows.size(), 10u, "Reverse complete retrieval is broken"); 
    6565  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 9, "Data mismatch"); 
    6666  PQXX_CHECK_EQUAL(rows[9][0].as<int>(), 0, "Data mismatch"); 
     
    6868  // Normal usage pattern: step through result set, 4 rows at a time. 
    6969  rows = stateless.retrieve(0, 4); 
    70   PQXX_CHECK_EQUAL(rows.size(), 4, "Wrong batch size"); 
     70  PQXX_CHECK_EQUAL(rows.size(), 4u, "Wrong batch size"); 
    7171  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 0, "Batch in wrong place"); 
    7272  PQXX_CHECK_EQUAL(rows[3][0].as<int>(), 3, "Batch in wrong place"); 
    7373 
    7474  rows = stateless.retrieve(4, 8); 
    75   PQXX_CHECK_EQUAL(rows.size(), 4, "Wrong batch size"); 
     75  PQXX_CHECK_EQUAL(rows.size(), 4u, "Wrong batch size"); 
    7676  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 4, "Batch in wrong place"); 
    7777  PQXX_CHECK_EQUAL(rows[3][0].as<int>(), 7, "Batch in wrong place"); 
    7878 
    7979  rows = stateless.retrieve(8, 12); 
    80   PQXX_CHECK_EQUAL(rows.size(), 2, "Wrong batch size"); 
     80  PQXX_CHECK_EQUAL(rows.size(), 2u, "Wrong batch size"); 
    8181  PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 8, "Batch in wrong place"); 
    8282  PQXX_CHECK_EQUAL(rows[1][0].as<int>(), 9, "Batch in wrong place"); 
  • trunk/test/unit/test_test_helpers.cxx

    r1358 r1368  
    1313        throw exception(), 
    1414        exception, 
    15         "Plain exception not handled properly by PQXX_CHECK_THROWS.") 
     15        "Plain exception not handled properly by PQXX_CHECK_THROWS."); 
    1616} 
    1717