Changeset 1368
- Timestamp:
- 08/09/08 08:23:58 (5 months ago)
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/test/test000.cxx (modified) (3 diffs)
- trunk/test/test002.cxx (modified) (3 diffs)
- trunk/test/test004.cxx (modified) (2 diffs)
- trunk/test/test007.cxx (modified) (1 diff)
- trunk/test/test085.cxx (modified) (5 diffs)
- trunk/test/test090.cxx (modified) (1 diff)
- trunk/test/test092.cxx (modified) (2 diffs)
- trunk/test/test_helpers.hxx (modified) (1 diff)
- trunk/test/unit/test_float.cxx (modified) (1 diff)
- trunk/test/unit/test_pipeline.cxx (modified) (3 diffs)
- trunk/test/unit/test_sql_cursor.cxx (modified) (14 diffs)
- trunk/test/unit/test_stateless_cursor.cxx (modified) (5 diffs)
- trunk/test/unit/test_test_helpers.cxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1367 r1368 1 2008-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 1 12 2008-08-09 Jeroen T. Vermeulen <jtv@xs4all.nl> 2 13 configure.ac.in: trunk/test/test000.cxx
r1354 r1368 27 27 template<typename T> void testitems(const T &I, typename T::size_type s) 28 28 { 29 PQXX_CHECK_EQUAL(I.size(), s, "Wrong size in items class.") 29 PQXX_CHECK_EQUAL(I.size(), s, "Wrong size in items class."); 30 30 31 31 for ( ; s; --s) 32 32 { 33 33 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."); 35 35 } 36 36 } … … 38 38 void check(string ref, string val, string vdesc) 39 39 { 40 PQXX_CHECK_EQUAL(val, ref, "String mismatch for " + vdesc) 40 PQXX_CHECK_EQUAL(val, ref, "String mismatch for " + vdesc); 41 41 } 42 42 … … 85 85 { 86 86 PQXX_CHECK_EQUAL(oid_none, 87 0 ,87 0u, 88 88 "InvalidIod is not zero as it used to be. This may conceivably " 89 "cause problems in libpqxx.") 89 "cause problems in libpqxx."); 90 90 91 91 if (cursor_base::prior() >= 0 || cursor_base::backward_all() >= 0) trunk/test/test002.cxx
r1360 r1368 35 35 bad_connect(), 36 36 exception, 37 "Invalid connection string did not cause exception.") 37 "Invalid connection string did not cause exception."); 38 38 39 39 // Set up connection to database … … 64 64 rtable, 65 65 R.column_table(result::tuple::size_type(0)), 66 "Inconsistent answers from column_table()") 66 "Inconsistent answers from column_table()"); 67 67 68 68 const string rcol = R.column_name(0); … … 71 71 crtable, 72 72 rtable, 73 "Field looked up by name gives different origin.") 73 "Field looked up by name gives different origin."); 74 74 #endif 75 75 trunk/test/test004.cxx
r1361 r1368 89 89 for (int i=0; (i < 20) && !L.Done(); ++i) 90 90 { 91 PQXX_CHECK_EQUAL(notifs, 0, "Got unexpected notifications.") 91 PQXX_CHECK_EQUAL(notifs, 0, "Got unexpected notifications."); 92 92 93 93 // Sleep one second using a libpqxx-internal function. Kids, don't try … … 100 100 cout << endl; 101 101 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."); 104 104 } 105 105 trunk/test/test007.cxx
r1361 r1368 62 62 R.column_type(result::tuple::size_type(0)), 63 63 rctype, 64 "Inconsistent result::column_type().") 64 "Inconsistent result::column_type()."); 65 65 66 66 const string rct = to_string(rctype); trunk/test/test085.cxx
r1363 r1368 18 18 rhs, \ 19 19 lhs, \ 20 "Executing " name " as prepared statement yields different results.") \20 "Executing " name " as prepared statement yields different results."); \ 21 21 PQXX_CHECK_EQUAL(lhs.empty(), false, "Result for " name " is empty.") 22 22 … … 111 111 C.prepare_now("ReadPGTables"), 112 112 exception, 113 "prepare_now() succeeded on dropped statement.") 113 "prepare_now() succeeded on dropped statement."); 114 114 115 115 // Just to try and confuse things, "unprepare" twice … … 122 122 T.prepared("ReadPGTables").exec(), 123 123 exception, 124 "Execute unprepared statement didn't fail.") 124 "Execute unprepared statement didn't fail."); 125 125 126 126 // Re-prepare the same statement and test again … … 141 141 C.prepare("ReadPGTables", Q_readpgtables + " ORDER BY tablename"), 142 142 exception, 143 "Bad redefinition of statement went unnoticed.") 143 "Bad redefinition of statement went unnoticed."); 144 144 145 145 cout << "Testing prepared statement with parameter..." << endl; … … 187 187 T.prepared("SeeTables")()()("hi mom!").exec(), 188 188 exception, 189 "No error for too many parameters.") 189 "No error for too many parameters."); 190 190 191 191 PQXX_CHECK_THROWS( 192 192 T.prepared("SeeTables")("who, me?").exec(), 193 193 exception, 194 "No error for too few parameters.") 194 "No error for too few parameters."); 195 195 } 196 196 catch (const feature_not_supported &e) trunk/test/test090.cxx
r1356 r1368 67 67 PQXX_CHECK_NOT_EQUAL(C.adorn_name(nametest), 68 68 C.adorn_name(nametest), 69 "\"Unique\" names are not unique.") 69 "\"Unique\" names are not unique."); 70 70 71 71 dotests(N); trunk/test/test092.cxx
r1357 r1368 39 39 PQXX_CHECK_EQUAL(L[0][0].as<size_t>(), 40 40 data.size(), 41 "Length of field in database does not match original length.") 41 "Length of field in database does not match original length."); 42 42 43 43 const result R( T.exec("SELECT " + Field + " FROM " + Table) ); … … 45 45 const binarystring roundtrip(R[0][0]); 46 46 47 PQXX_CHECK_EQUAL(string(roundtrip.str()), data, "Data came back different.") 47 PQXX_CHECK_EQUAL(string(roundtrip.str()), data, "Data came back different."); 48 48 49 49 PQXX_CHECK_EQUAL(roundtrip.size(), 50 50 data.size(), 51 "Binary string reports wrong size.") 51 "Binary string reports wrong size."); 52 52 53 53 // People seem to like the multi-line invocation style, where you get your trunk/test/test_helpers.hxx
r1363 r1368 144 144 // Unconditional test failure. 145 145 #define PQXX_CHECK_NOTREACHED(desc) \ 146 throw pqxx::test::test_failure(__FILE__, __LINE__, desc) 146 pqxx::test::check_notreached(__FILE__, __LINE__, (desc)) 147 void check_notreached(const char file[], int line, PGSTD::string desc) 148 { 149 throw test_failure(file, line, desc); 150 } 147 151 148 152 // Verify that a condition is met, similar to assert() 149 153 #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)) 155 void 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 } 156 165 157 166 // Verify that variable has the expected value. 158 167 #define PQXX_CHECK_EQUAL(actual, expected, desc) \ 159 if (!((expected) == (actual))) throw pqxx::test::test_failure( \168 pqxx::test::check_equal( \ 160 169 __FILE__, \ 161 170 __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)) 176 template<typename ACTUAL, typename EXPECTED> 177 inline 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 } 166 193 167 194 // Verify that two values are not equal. 168 195 #define PQXX_CHECK_NOT_EQUAL(value1, value2, desc) \ 169 if (!((value1) != (value2))) throw pqxx::test::test_failure( \196 pqxx::test::check_not_equal( \ 170 197 __FILE__, \ 171 198 __LINE__, \ 172 PGSTD::string(desc) + " " \ 173 "(" #value1 " == " #value2 ": " \ 174 "both are " + to_string(value2) + ")"); 199 (value1), \ 200 #value1, \ 201 (value2), \ 202 #value2, \ 203 (desc)) 204 template<typename VALUE1, typename VALUE2> 205 inline 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 } 175 220 176 221 // Verify that "action" throws "exception_type." 177 222 #define PQXX_CHECK_THROWS(action, exception_type, desc) \ 178 { \ 179 bool pqxx_check_throws_failed = true; \ 223 do { \ 180 224 try \ 181 225 { \ 182 226 action ; \ 183 pqxx_check_throws_failed = false; \ 227 PQXX_CHECK_NOTREACHED( \ 228 PGSTD::string(desc) + \ 229 " (\"" #action "\" did not throw " #exception_type ")"); \ 184 230 } \ 185 catch (const PGSTD::exception&e) {} \231 catch (const exception_type &e) {} \ 186 232 catch (...) \ 187 233 { \ 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 ")"); \ 193 238 } \ 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) 202 240 203 241 } // namespace test trunk/test/unit/test_float.cxx
r1328 r1368 19 19 { 20 20 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"); 23 23 } 24 24 } trunk/test/unit/test_pipeline.cxx
r1341 r1368 18 18 pipe.flush(); 19 19 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."); 21 21 PQXX_CHECK_EQUAL( 22 22 r[0][0].as<int>(), … … 34 34 pipe.complete(); 35 35 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()."); 37 37 PQXX_CHECK_EQUAL( 38 38 r[0][0].as<int>(), … … 42 42 // The complete() also received any pending query results from the backend. 43 43 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."); 45 45 PQXX_CHECK_EQUAL( 46 46 r[0][0].as<int>(), trunk/test/unit/test_sql_cursor.cxx
r1349 r1368 22 22 23 23 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"); 25 25 26 26 cursor_base::difference_type displacement = 0; 27 27 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"); 29 29 PQXX_CHECK_EQUAL(one[0][0].as<string>(), "1", "Unexpected result"); 30 30 PQXX_CHECK_EQUAL(displacement, 1, "Wrong displacement"); … … 34 34 PQXX_CHECK_EQUAL(offset, 1, "Unexpected offset from move()"); 35 35 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()"); 37 37 PQXX_CHECK_EQUAL(forward.endpos(), -1, "endpos() unexpectedly set"); 38 38 39 39 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"); 41 41 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()"); 43 43 44 44 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()"); 48 48 49 49 offset = forward.move(1); … … 52 52 53 53 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()"); 56 56 PQXX_CHECK_EQUAL(row[0][0].as<string>(), "4", "pos() is lying"); 57 57 58 58 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"); 61 61 PQXX_CHECK_EQUAL(forward.endpos(), 5, "Failed to notice end position"); 62 62 PQXX_CHECK_EQUAL(displacement, 1, "Wrong displacement at end position"); … … 64 64 offset = forward.move(5, displacement); 65 65 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"); 67 67 PQXX_CHECK_EQUAL(forward.endpos(), 5, "endpos() changed after end position"); 68 68 PQXX_CHECK_EQUAL(displacement, 0, "Wrong displacement after end position"); … … 96 96 // Fetch entire result set at once. 97 97 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"); 99 99 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"); 101 101 PQXX_CHECK_EQUAL(forward3.endpos(), 5, "Bad endpos() after fetching"); 102 102 … … 111 111 112 112 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"); 114 114 PQXX_CHECK_EQUAL(forward_empty.endpos(), 1, "Bad endpos() in empty result"); 115 115 PQXX_CHECK_EQUAL(displacement, 1, "Bad displacement in empty result"); … … 128 128 false); 129 129 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"); 131 131 PQXX_CHECK_EQUAL(scroll.endpos(), -1, "New scroll cursor has endpos() set"); 132 132 133 133 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"); 136 136 PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set prematurely"); 137 137 … … 141 141 rows = scroll.fetch(cursor_base::prior()); 142 142 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"); 144 144 PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set on wrong side of result"); 145 145 … … 150 150 PQXX_CHECK_EQUAL(offset, 0, "Rows found before beginning"); 151 151 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"); 153 153 PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set on left-side bounce"); 154 154 … … 158 158 PQXX_CHECK_EQUAL(offset, 4, "Offset mismatch"); 159 159 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"); 161 161 PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set at weird time"); 162 162 … … 164 164 PQXX_CHECK_EQUAL(offset, 3, "Offset mismatch"); 165 165 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"); 167 167 PQXX_CHECK_EQUAL(scroll.endpos(), -1, "endpos() set during hard bounce"); 168 168 169 169 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"); 172 172 PQXX_CHECK_EQUAL(rows[2][0].as<int>(), 3, "pos() does not match data"); 173 173 rows = scroll.fetch(-1); 174 PQXX_CHECK_EQUAL(scroll.pos(), 2 , "Bad pos()");174 PQXX_CHECK_EQUAL(scroll.pos(), 2u, "Bad pos()"); 175 175 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 2, "pos() does not match data"); 176 176 177 177 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"); 179 179 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 3, "Data position mismatch"); 180 180 } … … 191 191 cursor_base::difference_type displacement = 0; 192 192 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"); 194 194 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 1, "Wrong result data"); 195 195 PQXX_CHECK_EQUAL(rows[2][0].as<int>(), 3, "Wrong result data"); … … 199 199 200 200 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"); 202 202 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 3, "Wrong result data"); 203 203 PQXX_CHECK_EQUAL(rows[2][0].as<int>(), 1, "Wrong result data"); 204 204 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"); 206 206 PQXX_CHECK_EQUAL(adopted.endpos(), -1, "endpos() set too early"); 207 207 208 208 cursor_base::difference_type offset = adopted.move(cursor_base::all()); 209 209 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"); 211 211 PQXX_CHECK_EQUAL(adopted.endpos(), 4, "endpos() not set properly"); 212 212 … … 263 263 work trans2(conn, "trans2"); 264 264 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"); 266 266 267 267 // Cursor without hold is closed on commit. trunk/test/unit/test_stateless_cursor.cxx
r1317 r1368 17 17 PQXX_CHECK_EQUAL(rows.empty(), true, "Empty result not empty"); 18 18 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"); 20 20 21 PQXX_CHECK_EQUAL(empty.size(), 0 , "Empty cursor not empty");21 PQXX_CHECK_EQUAL(empty.size(), 0u, "Empty cursor not empty"); 22 22 23 23 PQXX_CHECK_THROWS( … … 32 32 false); 33 33 34 PQXX_CHECK_EQUAL(stateless.size(), 10 , "stateless_cursor::size() mismatch");34 PQXX_CHECK_EQUAL(stateless.size(), 10u, "stateless_cursor::size() mismatch"); 35 35 36 36 // Retrieve nothing. 37 37 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"); 39 39 40 40 // Retrieve two rows. 41 41 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"); 43 43 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 1, "Data/position mismatch"); 44 44 PQXX_CHECK_EQUAL(rows[1][0].as<int>(), 2, "Data/position mismatch"); … … 46 46 // Retrieve same rows in reverse. 47 47 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"); 49 49 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 2, "Data/position mismatch"); 50 50 PQXX_CHECK_EQUAL(rows[1][0].as<int>(), 1, "Data/position mismatch"); … … 52 52 // Retrieve beyond end. 53 53 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"); 55 55 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 9, "Data/pos mismatch at end"); 56 56 57 57 // Retrieve beyond beginning. 58 58 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"); 60 60 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 0, "Data/pos mismatch at beginning"); 61 61 62 62 // Retrieve entire result set backwards. 63 63 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"); 65 65 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 9, "Data mismatch"); 66 66 PQXX_CHECK_EQUAL(rows[9][0].as<int>(), 0, "Data mismatch"); … … 68 68 // Normal usage pattern: step through result set, 4 rows at a time. 69 69 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"); 71 71 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 0, "Batch in wrong place"); 72 72 PQXX_CHECK_EQUAL(rows[3][0].as<int>(), 3, "Batch in wrong place"); 73 73 74 74 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"); 76 76 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 4, "Batch in wrong place"); 77 77 PQXX_CHECK_EQUAL(rows[3][0].as<int>(), 7, "Batch in wrong place"); 78 78 79 79 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"); 81 81 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 8, "Batch in wrong place"); 82 82 PQXX_CHECK_EQUAL(rows[1][0].as<int>(), 9, "Batch in wrong place"); trunk/test/unit/test_test_helpers.cxx
r1358 r1368 13 13 throw exception(), 14 14 exception, 15 "Plain exception not handled properly by PQXX_CHECK_THROWS.") 15 "Plain exception not handled properly by PQXX_CHECK_THROWS."); 16 16 } 17 17
