test01.cxx 721 B

123456789101112131415161718192021222324252627282930313233
  1. #include <iostream>
  2. #include <pqxx/transaction>
  3. #include "test_helpers.hxx"
  4. using namespace pqxx;
  5. namespace
  6. {
  7. // Simple test program for libpqxx. Open connection to database, start
  8. // a transaction, and perform a query inside it.
  9. void test_001()
  10. {
  11. connection conn;
  12. // Begin a transaction acting on our current connection. Give it a human-
  13. // readable name so the library can include it in error messages.
  14. work tx{conn, "test1"};
  15. // Perform a query on the database, storing result rows in R.
  16. result r(tx.exec("SELECT * FROM pg_tables"));
  17. // We're expecting to find some tables...
  18. PQXX_CHECK(not std::empty(r), "No tables found.");
  19. tx.commit();
  20. }
  21. PQXX_REGISTER_TEST(test_001);
  22. } // namespace