Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

test.c

Go to the documentation of this file.
00001 /*
00002  * finflect - Algorithms and tools for inflecting Finnish nouns
00003  * Copyright (C) 2004, 2005  The FinFlect Team
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  *
00020  * For the complete legal text of the GNU Lesser General Public License,
00021  * see the file LICENSE. For a complete list of authors and copyright
00022  * holders, see the file AUTHORS.
00023  */
00024 
00025 /**
00026  * @file test.c Some random tests
00027  * @todo Remove me
00028  */
00029 
00030 #include <stdlib.h>
00031 #include <stdio.h>
00032 
00033 #include "ffstring.h"
00034 #include "ffword.h"
00035 #include "ffutil.h"
00036 #include "ffregex.h"
00037 #include "finflect.h"
00038 /**
00039  * ffpriv_genitive.h is for internal use only
00040  */
00041 #include "ffpriv_basic_cases.h"
00042 #include "ffpriv_exterior_local_cases.h"
00043 #include "ffpriv_genitive_stem.h"
00044 #include "ffpriv_ie_vowel_change.h"
00045 #include "ffpriv_ss_abnormal.h"
00046 
00047 int main(int argv, char** args) {
00048   ffstring kissa, issa, kissa2;
00049   ffstring koira, APINA, apina;
00050   ffstring tatar;
00051   ffword tatarw, typpi, kuningas;
00052   ffint32 j;
00053   ffchar *perkele, *perkeletta;
00054 
00055   if (ffstring_create("kissa", &kissa)) {
00056     return 1;
00057   }
00058   printf("pla(%d): %s\n", kissa.len, kissa.str);
00059 
00060   if (ffstring_tail(&kissa, 4, &issa)) {
00061     return 1;
00062   }
00063   printf("prrrriiii(%d): %s\n", issa.len, issa.str);
00064 
00065   if (ffstring_rfe(&kissa,1,"oissa")) {
00066     return 1;
00067   }
00068   printf("pla(%d): %s\n", kissa.len, kissa.str);
00069 
00070   if(ffstring_append(&kissa, "an")) {
00071     return 1;
00072   }
00073   printf("pla(%d): %s\n", kissa.len, kissa.str);
00074 
00075   if(ffstring_dfe(&kissa, 2)) {
00076     return 1;
00077   }
00078   printf("pla(%d): %s\n", kissa.len, kissa.str);
00079 
00080   if(ffstring_copy(&kissa, &koira)) {
00081     return 1;
00082   }
00083   if(ffstring_append(&kissa, "abc")) {
00084     return 1;
00085   }
00086   if(ffstring_append(&koira, "cba")) {
00087     return 1;
00088   }
00089   printf("pla(%d): %s\n", kissa.len, kissa.str);
00090   printf("pla(%d): %s\n", koira.len, koira.str);
00091 
00092   printf("uga: %d\n", ffstring_compare_ff(&kissa, &koira));
00093   printf("uga: %d\n", ffstring_compare_ff(&koira, &kissa));
00094 
00095   /* for (i = koira.str; i < koira.str + koira.len; ++i)
00096   printf("plagu(%c): %d\n", *i, ff_is_consonant(*i)); */
00097 
00098   if(ffstring_create("APINA", &APINA)) {
00099     return 1;
00100   }
00101   printf("pör(%d): %s\n", APINA.len, APINA.str);
00102 
00103   if(ffstring_lower(&APINA, &apina)) {
00104     return 1;
00105   }
00106   printf("pör(%d): %s\n", apina.len, apina.str);
00107 
00108   printf("uga: %d\n", ffstring_compare_ff(&apina, &APINA));
00109   printf("uga: %d\n", ffstring_compare_ff_ci(&apina, &APINA));
00110 
00111   if(ffstring_tolower(&APINA)) {
00112     return 1;
00113   }
00114   printf("pör(%d): %s\n", APINA.len, APINA.str);
00115 
00116   ffstring_delete(&kissa);
00117   ffstring_delete(&issa);
00118   ffstring_delete(&koira);
00119   ffstring_delete(&APINA);
00120   ffstring_delete(&apina);
00121 
00122   if (ffstring_create("kevät",&tatar)) {
00123     return 1;
00124   }
00125   printf("tat(%d): %s\n", tatar.len, tatar.str);
00126 
00127   tatarw.data = tatar;
00128   /**
00129    * @todo ffpriv_genitive_stem is for internal use only
00130    */
00131 
00132 
00133   if (ffpriv_adessive_singular(&tatarw)) {
00134     return 1;
00135   }
00136   printf("tat(%d): %s\n", tatar.len, tatar.str);
00137 
00138   ffstring_delete(&tatar);
00139 
00140   if(ffstring_create("aaaaakissaaaaaa", &kissa2)) {
00141     return 1;
00142   }
00143 
00144   printf("burarum(%d): %s\n", kissa2.len, kissa2.str);
00145 
00146   printf("umpah(kissa): %d\n", ffregex_match("kissa", &kissa2));
00147   printf("umpah(sa+): %d\n", ffregex_match("sa+", &kissa2));
00148   printf("umpah_ci(KISSA): %d\n", ffregex_match_ci("KISSA", &kissa2));
00149 
00150   printf("humpa(koira): %d\n", ffregex_match("koira", &kissa2));
00151   printf("humpa(ö+): %d\n", ffregex_match("ö+", &kissa2));
00152 
00153   ffregex_replace("kissa", "koira", &kissa2);
00154 
00155   printf("parum(%d): %s\n", kissa2.len, kissa2.str);
00156 
00157   ffregex_replace("aa(koira)aa", "bb${1}bb", &kissa2);
00158 
00159   printf("paparum(%d): %s\n", kissa2.len, kissa2.str);
00160 
00161   ffstring_delete(&kissa2);
00162 
00163   ffstring_create("typpi", &typpi.data);
00164   ffpriv_ie_partitive(&typpi);
00165 
00166   printf("burarum(%d): %s\n", typpi.data.len, typpi.data.str);
00167 
00168   ffstring_delete(&typpi.data);
00169 
00170   ffstring_create("kuningas", &kuningas.data);
00171   ffpriv_ss_genitive(&kuningas);
00172   printf("burarum(%d): %s\n", kuningas.data.len, kuningas.data.str);
00173   ffstring_delete(&kuningas.data);
00174 
00175   perkele = "perkele";
00176   perkeletta = ff_partitive_singular(perkele);
00177   printf("aargh: %s\n", perkele);
00178   printf("ieaargh: %s\n", perkeletta);
00179   free(perkeletta);
00180 
00181   if ((j = ffstring_instcount())) {
00182     printf("Unbalanced number of strings: %d\n", j);
00183     return 1;
00184   }
00185 
00186   return EXIT_SUCCESS;
00187 }

Generated on Thu Jun 2 23:16:59 2005 for FinFlect by  doxygen 1.4.2