levenshtein_test.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <iostream>
  2. #include "levenshtein.hpp"
  3. #define FAILED(got, op, expt) {std::cout << __FILE__ << ":" << __LINE__ << ": failed asserting " << got << " " << op << " expected " << expt << std::endl; return false; }
  4. /*
  5. size_t levenshteinShortestPath(const std::string &a, const std::string &b)
  6. {
  7. std::list<ePath> r;
  8. return levenshteinShortestPath(r, a, b);
  9. }
  10. */
  11. bool doTest()
  12. {
  13. /*
  14. float pc;
  15. unsigned int lev;
  16. if ((lev = levenshteinShortestPath("coucou", "coucou")) != 0)
  17. FAILED(lev, "!=", 0);
  18. if ((pc = levenshteinShortestPath("coucou", "coucou")) != 1)
  19. FAILED(pc, "!=", 1);
  20. if ((lev = levenshteinShortestPath("coocou", "coucou")) != 1)
  21. FAILED(lev, "!=", 1);
  22. if ((lev = levenshteinShortestPath("abcdefghijk", "zabcdefghijk")) != 1)
  23. FAILED(lev, "!=", 1);
  24. if ((lev = levenshteinShortestPath("zabcdefghijk", "abcdefghijk")) != 1)
  25. FAILED(lev, "!=", 1);
  26. if ((lev = levenshteinShortestPath("zabcdefghijk", "zabcdkfghijk")) != 1)
  27. FAILED(lev, "!=", 1);
  28. if ((lev = levenshteinShortestPath("a", "zabcdkfghijk")) != 11)
  29. FAILED(lev, "!=", 11);
  30. */
  31. return true;
  32. }
  33. int main()
  34. {
  35. if (!doTest())
  36. exit(EXIT_FAILURE);
  37. exit(EXIT_SUCCESS);
  38. }