Changeset 1383
- Timestamp:
- 08/19/08 01:21:01 (5 months ago)
- Files:
-
- trunk/test/unit/test_sql_cursor.cxx (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/unit/test_sql_cursor.cxx
r1382 r1383 40 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 u, "fetch(0, displacement) affected pos()");42 PQXX_CHECK_EQUAL(forward.pos(), 2, "fetch(0, displacement) affected pos()"); 43 43 44 44 row = forward.fetch(0); 45 45 PQXX_CHECK_EQUAL(row.size(), 0u, "fetch(0) fetched wrong number of rows"); 46 PQXX_CHECK_EQUAL(forward.pos(), 2 u, "fetch(0) moved cursor");47 PQXX_CHECK_EQUAL(forward.pos(), 2 u, "fetch(0) affected pos()");46 PQXX_CHECK_EQUAL(forward.pos(), 2, "fetch(0) moved cursor"); 47 PQXX_CHECK_EQUAL(forward.pos(), 2, "fetch(0) affected pos()"); 48 48 49 49 offset = forward.move(1); … … 53 53 row = forward.fetch(1); 54 54 PQXX_CHECK_EQUAL(row.size(), 1u, "fetch(1) returned wrong number of rows"); 55 PQXX_CHECK_EQUAL(forward.pos(), 4 u, "fetch(1) results in bad pos()");55 PQXX_CHECK_EQUAL(forward.pos(), 4, "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 59 PQXX_CHECK_EQUAL(empty_result.size(), 0u, "Got rows at end of cursor"); 60 PQXX_CHECK_EQUAL(forward.pos(), 5 u, "Not at one-past-end position");60 PQXX_CHECK_EQUAL(forward.pos(), 5, "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 u, "pos() is beyond end");66 PQXX_CHECK_EQUAL(forward.pos(), 5, "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"); … … 98 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 u, "Bad pos() after fetching all rows");100 PQXX_CHECK_EQUAL(forward3.pos(), 5, "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 u, "Bad pos() at end of result");113 PQXX_CHECK_EQUAL(forward_empty.pos(), 1, "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 u, "Scroll cursor's initial pos() is wrong");130 PQXX_CHECK_EQUAL(scroll.pos(), 0, "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 134 PQXX_CHECK_EQUAL(rows.size(), 1u, "Scroll cursor is broken"); 135 PQXX_CHECK_EQUAL(scroll.pos(), 1 u, "Scroll cursor's pos() is broken");135 PQXX_CHECK_EQUAL(scroll.pos(), 1, "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 u, "pos() is not back at zero");143 PQXX_CHECK_EQUAL(scroll.pos(), 0, "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 u, "pos() moved back from zero");152 PQXX_CHECK_EQUAL(scroll.pos(), 0, "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 u, "Position mismatch");160 PQXX_CHECK_EQUAL(scroll.pos(), 4, "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 u, "Hard bounce failed");166 PQXX_CHECK_EQUAL(scroll.pos(), 0, "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 u, "Bad pos()");170 PQXX_CHECK_EQUAL(scroll.pos(), 3, "Bad pos()"); 171 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 u, "Bad pos()");174 PQXX_CHECK_EQUAL(scroll.pos(), 2, "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 u, "Bad pos() after inverse turnaround");178 PQXX_CHECK_EQUAL(scroll.pos(), 3, "Bad pos() after inverse turnaround"); 179 179 PQXX_CHECK_EQUAL(rows[0][0].as<int>(), 3, "Data position mismatch"); 180 180 } … … 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 u, "Failed to recognize starting position");205 PQXX_CHECK_EQUAL(adopted.pos(), 0, "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 u, "Bad position on adopted cursor");210 PQXX_CHECK_EQUAL(adopted.pos(), 4, "Bad position on adopted cursor"); 211 211 PQXX_CHECK_EQUAL(adopted.endpos(), 4, "endpos() not set properly"); 212 212
