| 123456789101112131415161718192021222324252627282930313233343536 |
- #include <iostream>
- #include "levenshtein.hpp"
- #define FAILED { std::cerr << "test failed at " << __LINE__ << std::endl; exit(EXIT_FAILURE); }
- int main()
- {
- if (levenshtein("abcdef", "abcdef", 6, 6) != 0)
- FAILED;
- if (levenshtein("abcdef", "abcdf", 6, 5) != 1)
- FAILED;
- if (levenshtein("abcdf", "abcdef", 5, 6) != 1)
- FAILED;
- if (levenshtein("abcdf", "abcef", 5, 5) != 1)
- FAILED;
- if (levenshtein("abcf", "abdcf", 4, 5) != 1)
- FAILED;
- if (levenshtein("lorem", "liroem", 5, 6) != 2)
- FAILED;
- if (levenshtein<std::string, int>("abcdef", "abcdef", 6, 6) != 0)
- FAILED;
- if (levenshtein<std::string, int>("abcdef", "abcdf", 6, 5) != 1)
- FAILED;
- if (levenshtein<std::string, int>("abcdf", "abcdef", 5, 6) != 1)
- FAILED;
- if (levenshtein<std::string, int>("abcdf", "abcef", 5, 5) != 1)
- FAILED;
- if (levenshtein<std::string, int>("abcf", "abdcf", 4, 5) != 1)
- FAILED;
- if (levenshtein<std::string, int>("lorem", "liroem", 5, 6) != 2)
- FAILED;
- std::cout << "success" << std::endl;
- }
|