mxe/src/hunspell-test.cpp

39 lines
959 B
C++
Raw Normal View History

/*
* This file is part of MXE. See LICENSE.md for licensing information.
*/
2012-04-14 13:13:59 +01:00
#include <iostream>
#include <fstream>
2017-04-30 21:01:09 +01:00
#include <string>
#include <vector>
2012-04-14 13:13:59 +01:00
#include <hunspell.hxx>
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
std::ofstream dic ("hunspell-test.dic");
dic << "2\nHello\nWorld";
dic.close();
std::ofstream aff ("hunspell-test.aff");
aff << "SET UTF-8\nTRY loredWH\nMAXDIFF 1";
2012-04-16 14:25:27 +01:00
aff.close();
Hunspell h("hunspell-test.aff", "hunspell-test.dic");
2017-04-30 21:01:09 +01:00
if (h.spell(std::string("Hello")) == 0)
2012-04-14 13:13:59 +01:00
{
std::cerr << "Error: hunspell marked correct word as wrong" << std::endl;
}
2017-04-30 21:01:09 +01:00
if (h.spell(std::string("wrld")) != 0)
2012-04-14 13:13:59 +01:00
{
std::cerr << "Error: hunspell marked wrong word as correct" << std::endl;
}
2012-04-16 14:25:27 +01:00
2017-04-30 21:01:09 +01:00
std::vector<std::string> result;
result = h.suggest(std::string("ell"));
for (unsigned int i = 0; i < result.size(); i++) std::cout << result[i];
2012-04-16 14:25:27 +01:00
2012-04-14 13:13:59 +01:00
return 0;
}