test77.cxx 673 B

12345678910111213141516171819202122232425262728
  1. #include <pqxx/nontransaction>
  2. #include "test_helpers.hxx"
  3. // Test program for libpqxx. Test result::swap()
  4. namespace
  5. {
  6. void test_077()
  7. {
  8. pqxx::connection conn;
  9. pqxx::nontransaction tx{conn};
  10. auto RFalse{tx.exec("SELECT 1=0")}, RTrue{tx.exec("SELECT 1=1")};
  11. auto f{pqxx::from_string<bool>(RFalse[0][0])};
  12. auto t{pqxx::from_string<bool>(RTrue[0][0])};
  13. PQXX_CHECK(
  14. not f and t, "Booleans converted incorrectly; can't trust this test.");
  15. RFalse.swap(RTrue);
  16. f = pqxx::from_string<bool>(RFalse[0][0]);
  17. t = pqxx::from_string<bool>(RTrue[0][0]);
  18. PQXX_CHECK(f and not t, "result::swap() is broken.");
  19. }
  20. } // namespace
  21. PQXX_REGISTER_TEST(test_077);