test_separated_list.cxx 787 B

123456789101112131415161718192021222324252627282930313233
  1. #include <pqxx/separated_list>
  2. #include "../test_helpers.hxx"
  3. // Test program for separated_list.
  4. namespace
  5. {
  6. void test_separated_list()
  7. {
  8. PQXX_CHECK_EQUAL(
  9. pqxx::separated_list(",", std::vector<int>{}), "",
  10. "Empty list came out wrong.");
  11. PQXX_CHECK_EQUAL(
  12. pqxx::separated_list(",", std::vector<int>{5}), "5",
  13. "Single-element list came out wrong.");
  14. PQXX_CHECK_EQUAL(
  15. pqxx::separated_list(",", std::vector<int>{3, 6}), "3,6",
  16. "Things go wrong once separators come in.");
  17. std::vector<int> const nums{1, 2, 3};
  18. PQXX_CHECK_EQUAL(
  19. pqxx::separated_list(
  20. "+", std::begin(nums), std::end(nums),
  21. [](auto elt) { return *elt * 2; }),
  22. "2+4+6", "Accessors don't seem to work.");
  23. }
  24. PQXX_REGISTER_TEST(test_separated_list);
  25. } // namespace