C++11 library providing functionality common to all adapters.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
5.2 KiB

  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #ifndef LIBPEPADAPTER_TEST_PEPSQLITE_HH
  4. #define LIBPEPADAPTER_TEST_PEPSQLITE_HH
  5. #include <string>
  6. #include "../src/pEpSQLite.hh"
  7. // ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
  8. //
  9. // THIS IS TERRIBLE, JUST TERRIBLE, THIS IS A ANTI-PATTERN
  10. // Thats the single most stupid way of writing unit test ever!!!
  11. // DONT EVER DO THIS!
  12. //
  13. // The idea is as follows:
  14. // * Tests start simple and become increasingly complex
  15. // * There are fixtures and tests, as usual
  16. // * You start with basic fixtures to write the first test
  17. // * A test becomes a fixture, if the operation is needed for another test
  18. // * You systematically cover all the states possible in which a test can be executed
  19. //
  20. // THATS JUST TERRIBLE!!!
  21. // I WILL NEVER DO THAT AGAIN!
  22. //
  23. // ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
  24. namespace pEp {
  25. namespace Test {
  26. // FIXTURES
  27. // --------
  28. // filenames
  29. std::string fixture_db_filename_new();
  30. std::string fixture_db_filename_existing_and_verified();
  31. std::string fixture_db_filename_bad();
  32. std::string fixture_db_filename_corrupt();
  33. // prepared db's
  34. std::string fixture_init_db_new();
  35. std::string fixture_init_db_existing_and_verified();
  36. std::string fixture_init_db_corrupt();
  37. // instance
  38. pEpSQLite fixture_instance_of_new();
  39. pEpSQLite fixture_instance_of_existing_and_verified();
  40. pEpSQLite fixture_instance_of_bad();
  41. pEpSQLite fixture_instance_of_corrupt();
  42. // open
  43. pEpSQLite fixture_db_open_of_new();
  44. pEpSQLite fixture_db_open_of_existing_and_verified();
  45. pEpSQLite fixture_db_open_of_bad();
  46. pEpSQLite fixture_db_open_of_corrupt();
  47. pEpSQLite fixture_db_open_after_close();
  48. // tables
  49. pEpSQLite fixture_db_open_with_tables_of_new();
  50. // content
  51. pEpSQLite fixture_db_open_with_tables_and_content();
  52. // delete
  53. pEpSQLite fixture_db_open_after_delete();
  54. pEpSQLite fixture_db_open_after_close_after_delete();
  55. // TESTS
  56. // -----
  57. // instance creation
  58. pEpSQLite test_create_instance_on_new(); // OK
  59. pEpSQLite test_create_instance_on_existing(); // OK
  60. pEpSQLite test_create_instance_on_path_bad(); // OK
  61. pEpSQLite test_create_instance_on_path_corrupt(); // OK
  62. // db create_open (create_or_open())
  63. pEpSQLite test_createopen_db_new(); // OK, new db
  64. pEpSQLite test_createopen_db_existing(); // OK, open db
  65. pEpSQLite test_createopen_db_bad(); // ERR, cant create
  66. pEpSQLite test_createopen_db_corrupt(); // OK (cant detect corruption)
  67. // close()
  68. pEpSQLite test_close_before_open(); // OK
  69. pEpSQLite test_close_after_open(); // OK
  70. pEpSQLite test_close_idempotent(); // OK
  71. // create tables (execute())
  72. pEpSQLite test_db_create_tables_on_open_new(); // OK
  73. pEpSQLite test_db_create_tables_open_existing(); // ERR, Tables already exist
  74. pEpSQLite test_db_create_tables_on_open_bad(); // ERR, db closed
  75. pEpSQLite test_db_create_tables_on_open_corrupt(); // ERR, db corrupt
  76. // insert (execute())
  77. pEpSQLite test_db_insert_on_tables_exist(); // OK
  78. pEpSQLite test_db_insert_on_tables_dont_exist(); // ERR, Tables missing
  79. pEpSQLite test_db_insert_before_open(); // ERR, Tables missing
  80. pEpSQLite test_db_insert_after_close(); // ERR, Tables missing
  81. // verify contents (execute())
  82. pEpSQLite test_db_verify_content_existing_open_db(); // OK
  83. pEpSQLite test_db_verify_content_after_insert_on_tables_exist(); // OK
  84. pEpSQLite test_db_verify_content_no_tables(); // ERR - no tables
  85. pEpSQLite test_db_verify_content_after_create_tables(); // ERR - err no data
  86. // get_path()
  87. pEpSQLite test_get_path_on_instance_good(); // OK
  88. pEpSQLite test_get_path_on_instance_bad(); // OK
  89. // delete_db()
  90. pEpSQLite test_delete_file_gone_before_open_new(); // OK?
  91. pEpSQLite test_delete_file_gone_before_open_existing(); // OK
  92. pEpSQLite test_delete_file_gone_after_close_new(); // OK
  93. pEpSQLite test_delete_file_gone_after_open_existing(); // OK
  94. pEpSQLite test_delete_file_gone_after_open_corrupt(); // OK
  95. pEpSQLite test_delete_file_gone_after_open_bad(); // ERR
  96. // is_open()
  97. pEpSQLite test_is_open_before_open_new(); // false
  98. pEpSQLite test_is_open_after_open_new(); // true
  99. pEpSQLite test_is_open_after_open_existing(); // true
  100. pEpSQLite test_is_open_after_open_bad(); // false
  101. pEpSQLite test_is_open_after_open_corrupt(); // true (cant detect corruption)
  102. pEpSQLite test_is_open_after_close(); // false
  103. pEpSQLite test_is_open_after_delete_on_open(); // false
  104. pEpSQLite test_is_open_after_delete_on_closed(); // false
  105. } // namespace Test
  106. } // end of namespace pEp
  107. #endif // LIBPEPADAPTER_TEST_PEPSQLITE_HH