/* Copyright (C) 2008-2013 Børre Gaup This file is part of the program wordlist2hunspell. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #define private public // dirty trick to make private functions available for testing :D // place includes for classes that should be test below this line #include "../stringparser.h" TEST(GetStemNoDivisor) { StringParser sp = StringParser("baadth\tGpBO"); CHECK_EQUAL(sp.getStem(), "baadth"); } TEST(GetStemOneDivisor) { StringParser sp = StringParser("baadt>h\tGpBO"); CHECK_EQUAL(sp.getStem(), "baadt"); } TEST(GetStemTwoDivisors) { StringParser sp = StringParser("baath>egåat>a\tGpBO"); CHECK_EQUAL(sp.getStem(), "baath"); } TEST(GetSuffixNoDivisor) { StringParser sp = StringParser("baadth\tGpBO"); CHECK_EQUAL(sp.getSuffix(), "0"); } TEST(GetSuffixOneDivisor) { StringParser sp = StringParser("baadt>h\tGpBO"); CHECK_EQUAL(sp.getSuffix(), "h"); } TEST(GetSuffixTwoDivisors) { StringParser sp = StringParser("baath>egåat>a\tGpBO"); CHECK_EQUAL(sp.getSuffix(), "egåata"); } TEST(GetPlxClassesOnePlxclass) { StringParser sp = StringParser("baadtasovv>egåat>a\tGpBO"); CHECK_EQUAL(sp.getPlxPart(), "GpBO"); } TEST(GetPlxClassesTwoPlxclasses) { StringParser sp = StringParser("baadtasovv>egåat>a\tNAIX,NePABX"); CHECK_EQUAL(sp.getPlxPart(), "NAIX,NePABX"); } TEST(GetPlxClassesThreePlxclasses) { StringParser sp = StringParser("baadtasovv>egåat>a\tNAIX,NePABX,NBX"); CHECK_EQUAL(sp.getPlxPart(), "NAIX,NePABX,NBX"); } // TEST(CheckResult1) // { // StringParser sp = StringParser("baadtasovv>egåat>a\tGpBO"); // std::set want, got; // want.insert("egåata\tGpBO"); // got = sp.getSuffixes(); // // CHECK_EQUAL("baadtasovv", sp.getStem()); // CHECK_EQUAL(got.size(), want.size()); // // CHECK(equal(got.begin(), got.end(), want.begin())); // } // // TEST(CheckResult2) // { // StringParser sp = StringParser("baadt>h\tGpBO"); // std::set want, got; // want.insert("h\tGpBO"); // got = sp.getSuffixes(); // // CHECK_EQUAL("baadt", sp.getStem()); // CHECK_EQUAL(got.size(), want.size()); // CHECK(equal(got.begin(), got.end(), want.begin())); // } TEST(CheckDirty) { StringParser sp = StringParser("A-dåvre>>tje>>m\tGpBO"); std::string result = sp.cleanCruft("A-dåvre>>tje>>m\tGpBO"); CHECK_EQUAL("A-dåvre>tje>m\tGpBO", result); result = sp.cleanCruft("A-dåvre>>tje>>m>\tGpBO"); CHECK_EQUAL("A-dåvre>tje>m>\tGpBO", result); result = sp.cleanCruft("A-dåvre>>tje>>m>>\tGpBO"); CHECK_EQUAL("A-dåvre>tje>m>\tGpBO", result); result = sp.cleanCruft(">tje>m>>\tGpBO"); CHECK_EQUAL("tje>m>\tGpBO", result); } TEST(Rinse) { StringParser sp = StringParser("A-dåvre>>tje>>m\tGpBO"); CHECK_EQUAL("A-dåvre", sp.getStem()); CHECK_EQUAL("A-dåvre", sp.rinse("A-dåvre>")); CHECK_EQUAL("tje", sp.rinse("tje>")); } TEST(parseStringCharWithDivisorStem) { StringParser sp = StringParser("b>\tNI"); std::string want = "b"; std::string got = sp.getStem(); CHECK_EQUAL(got, want); } // TEST(parseStringCharWithDivisorSuffix) // { // StringParser sp = StringParser("b>\tNI"); // // std::set want; // want.insert("0\tNI"); // // std::set got = sp.getSuffixes(); // CHECK_EQUAL(got.size(), want.size()); // CHECK(equal(got.begin(), got.end(), want.begin())); // }