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 {
00049   ffstring kissa, issa, kissa2;
00050   ffstring koira, APINA, apina;
00051   ffstring tatar;
00052   ffword tatarw, typpi, kuningas;
00053   ffint32 j;
00054   ffchar *perkele, *perkeletta;
00055   
00056   if (ffstring_create("kissa", &kissa)) { return 1; }
00057   printf("pla(%d): %s\n", kissa.len, kissa.str);
00058   
00059   if (ffstring_tail(&kissa, 4, &issa)) { return 1; }
00060   printf("prrrriiii(%d): %s\n", issa.len, issa.str);
00061 
00062   if (ffstring_rfe(&kissa,1,"oissa")) { return 1; }
00063   printf("pla(%d): %s\n", kissa.len, kissa.str);
00064 
00065   if(ffstring_append(&kissa, "an")) { return 1; }
00066   printf("pla(%d): %s\n", kissa.len, kissa.str);
00067 
00068   if(ffstring_dfe(&kissa, 2)) { return 1; }
00069   printf("pla(%d): %s\n", kissa.len, kissa.str);
00070 
00071   if(ffstring_copy(&kissa, &koira)) { return 1; }
00072   if(ffstring_append(&kissa, "abc")) { return 1; }
00073   if(ffstring_append(&koira, "cba")) { return 1; }
00074   printf("pla(%d): %s\n", kissa.len, kissa.str);
00075   printf("pla(%d): %s\n", koira.len, koira.str);
00076   
00077   printf("uga: %d\n", ffstring_compare_ff(&kissa, &koira));
00078   printf("uga: %d\n", ffstring_compare_ff(&koira, &kissa));
00079   
00080   /* for (i = koira.str; i < koira.str + koira.len; ++i)
00081   printf("plagu(%c): %d\n", *i, ff_is_consonant(*i)); */
00082 
00083   if(ffstring_create("APINA", &APINA)) { return 1; }
00084   printf("pör(%d): %s\n", APINA.len, APINA.str);
00085   
00086   if(ffstring_lower(&APINA, &apina)) { return 1; }
00087   printf("pör(%d): %s\n", apina.len, apina.str);
00088 
00089   printf("uga: %d\n", ffstring_compare_ff(&apina, &APINA));
00090   printf("uga: %d\n", ffstring_compare_ff_ci(&apina, &APINA));
00091     
00092   if(ffstring_tolower(&APINA)) { return 1; }
00093   printf("pör(%d): %s\n", APINA.len, APINA.str);   
00094     
00095   ffstring_delete(&kissa);
00096   ffstring_delete(&issa);
00097   ffstring_delete(&koira);
00098   ffstring_delete(&APINA);
00099   ffstring_delete(&apina);
00100   
00101   if (ffstring_create("kevät",&tatar)) { return 1; }
00102   printf("tat(%d): %s\n", tatar.len, tatar.str);
00103   
00104   tatarw.data = tatar;
00105   /**
00106    * @todo ffpriv_genitive_stem is for internal use only
00107    */
00108   
00109   
00110   if (ffpriv_adessive_singular(&tatarw)) { return 1; }
00111   printf("tat(%d): %s\n", tatar.len, tatar.str);
00112   
00113   ffstring_delete(&tatar);
00114   
00115   if(ffstring_create("aaaaakissaaaaaa", &kissa2)) {return 1;}
00116   
00117   printf("burarum(%d): %s\n", kissa2.len, kissa2.str);
00118   
00119   printf("umpah(kissa): %d\n", ffregex_match("kissa", &kissa2));
00120   printf("umpah(sa+): %d\n", ffregex_match("sa+", &kissa2));
00121   printf("umpah_ci(KISSA): %d\n", ffregex_match_ci("KISSA", &kissa2));
00122   
00123   printf("humpa(koira): %d\n", ffregex_match("koira", &kissa2));
00124   printf("humpa(ö+): %d\n", ffregex_match("ö+", &kissa2));
00125   
00126   ffregex_replace("kissa", "koira", &kissa2);
00127   
00128   printf("parum(%d): %s\n", kissa2.len, kissa2.str);
00129   
00130   ffregex_replace("aa(koira)aa", "bb${1}bb", &kissa2);
00131   
00132   printf("paparum(%d): %s\n", kissa2.len, kissa2.str);
00133   
00134   ffstring_delete(&kissa2);
00135   
00136   ffstring_create("typpi", &typpi.data);
00137   ffpriv_ie_partitive(&typpi);
00138   
00139   printf("burarum(%d): %s\n", typpi.data.len, typpi.data.str);
00140   
00141   ffstring_delete(&typpi.data);
00142   
00143   ffstring_create("kuningas", &kuningas.data);
00144   ffpriv_ss_genitive(&kuningas);
00145   printf("burarum(%d): %s\n", kuningas.data.len, kuningas.data.str);
00146   ffstring_delete(&kuningas.data);
00147 
00148   perkele = "perkele";
00149   perkeletta = ff_partitive_singular(perkele);
00150   printf("aargh: %s\n", perkele);
00151   printf("ieaargh: %s\n", perkeletta);
00152   free(perkeletta);
00153 
00154   if ((j = ffstring_instcount()))
00155   {
00156     printf("Unbalanced number of strings: %d\n", j);
00157     return 1;
00158   }
00159 
00160   return EXIT_SUCCESS;
00161 }

Generated on Sun May 15 21:50:47 2005 for FinFlect by  doxygen 1.4.1