Home | History | Annotate | Line # | Download | only in tests
      1 #! /bin/sh
      2 
      3 # Test C, C++, PO extractors.
      4 
      5 tmpfiles=""
      6 trap 'rm -fr $tmpfiles' 1 2 3 15
      7 
      8 tmpfiles="$tmpfiles xg-po-1.in.po xg-po-1.c xg-po-1.cc"
      9 cat <<EOF > xg-po-1.in.po
     10 #: file1.c:199
     11 #, fuzzy
     12 msgid "extract me"
     13 msgstr "some text to get fuzzy copied to result"
     14 
     15 #: file2.cc:200
     16 msgid "what about me"
     17 msgstr ""
     18 
     19 #: file3.c:10
     20 #, c-format, fuzzy
     21 msgid "hello"
     22 msgstr "Again some text for fuzzy"
     23 EOF
     24 
     25 cat <<EOF > xg-po-1.c
     26 #include <libintl.h>
     27 #include <stdio.h>
     28 int
     29 main (int argc, char *argv[])
     30 {
     31   printf (dcgettext ("hello", "Hello, world."));
     32   return 0;
     33 }
     34 EOF
     35 
     36 cat <<EOF > xg-po-1.cc
     37 #include <iostream.h>
     38 #include <libintl.h>
     39 #include <locale.h>
     40 int
     41 main (int argc, char *argv[])
     42 {
     43   cout << dcgettext ("hello", "Hello world!", LC_MESSAGES) << endl;
     44   return 0;
     45 }
     46 EOF
     47 
     48 tmpfiles="$tmpfiles xg-po-1.po"
     49 : ${XGETTEXT=xgettext}
     50 ${XGETTEXT} --omit-header -n \
     51   -d xg-po-1 xg-po-1.in.po xg-po-1.c xg-po-1.cc
     52 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     53 
     54 tmpfiles="$tmpfiles xg-po-1.ok"
     55 cat <<EOF > xg-po-1.ok
     56 #: file1.c:199
     57 #, fuzzy
     58 msgid "extract me"
     59 msgstr "some text to get fuzzy copied to result"
     60 
     61 #: file2.cc:200
     62 msgid "what about me"
     63 msgstr ""
     64 
     65 #: file3.c:10
     66 #, fuzzy, c-format
     67 msgid "hello"
     68 msgstr "Again some text for fuzzy"
     69 
     70 #: xg-po-1.c:6
     71 #, c-format
     72 msgid "Hello, world."
     73 msgstr ""
     74 
     75 #: xg-po-1.cc:7
     76 msgid "Hello world!"
     77 msgstr ""
     78 EOF
     79 
     80 : ${DIFF=diff}
     81 ${DIFF} xg-po-1.ok xg-po-1.po
     82 result=$?
     83 
     84 rm -fr $tmpfiles
     85 
     86 exit $result
     87