test_nonblocking_connect.cxx 521 B

123456789101112131415161718192021222324252627
  1. #include <pqxx/transaction>
  2. #include <pqxx/internal/wait.hxx>
  3. #include "../test_helpers.hxx"
  4. namespace
  5. {
  6. void test_nonblocking_connect()
  7. {
  8. pqxx::connecting nbc;
  9. while (not nbc.done())
  10. {
  11. pqxx::internal::wait_fd(
  12. nbc.sock(), nbc.wait_to_read(), nbc.wait_to_write());
  13. nbc.process();
  14. }
  15. pqxx::connection conn{std::move(nbc).produce()};
  16. pqxx::work tx{conn};
  17. PQXX_CHECK_EQUAL(tx.query_value<int>("SELECT 10"), 10, "Bad value!?");
  18. }
  19. PQXX_REGISTER_TEST(test_nonblocking_connect);
  20. } // namespace