Home | History | Annotate | Line # | Download | only in tests
      1  1.1  christos #! /bin/sh
      2  1.1  christos 
      3  1.1  christos # Test C++ support: test boost-format.
      4  1.1  christos 
      5  1.1  christos tmpfiles=""
      6  1.1  christos trap 'rm -fr $tmpfiles' 1 2 3 15
      7  1.1  christos 
      8  1.1  christos tmpfiles="$tmpfiles xg-c-14.cc"
      9  1.1  christos cat <<\EOF > xg-c-14.cc
     10  1.1  christos // These are recognized as boost-format because of the keyword 'format'.
     11  1.1  christos format(gettext("%s on, %s off"));
     12  1.1  christos format(gettext("%1$d on, %2$d off"));
     13  1.1  christos format(gettext("%|1$| on, %|2$| off"));
     14  1.1  christos format(gettext("%1% on, %2% off"));
     15  1.1  christos // These are recognized as boost-format only through the heuristics.
     16  1.1  christos gettext("heuristic %s on, %s off");
     17  1.1  christos gettext("heuristic %1$d on, %2$d off");
     18  1.1  christos gettext("heuristic %|1$| on, %|2$| off");
     19  1.1  christos gettext("heuristic %1% on, %2% off");
     20  1.1  christos EOF
     21  1.1  christos 
     22  1.1  christos tmpfiles="$tmpfiles xg-c-14.po"
     23  1.1  christos : ${XGETTEXT=xgettext}
     24  1.1  christos ${XGETTEXT} --omit-header --no-location -d xg-c-14 --boost xg-c-14.cc
     25  1.1  christos test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     26  1.1  christos 
     27  1.1  christos # The first 4 are not marked as c-format, because they are known as
     28  1.1  christos # boost-format. The last 4 are governed by the heuristic. The first two
     29  1.1  christos # among them are valid c-format strings. The last one is a valid but unlikely
     30  1.1  christos # c-format string, therefore the heuristic doesn't mark it.
     31  1.1  christos tmpfiles="$tmpfiles xg-c-14.ok"
     32  1.1  christos cat <<\EOF > xg-c-14.ok
     33  1.1  christos #, boost-format
     34  1.1  christos msgid "%s on, %s off"
     35  1.1  christos msgstr ""
     36  1.1  christos 
     37  1.1  christos #, boost-format
     38  1.1  christos msgid "%1$d on, %2$d off"
     39  1.1  christos msgstr ""
     40  1.1  christos 
     41  1.1  christos #, boost-format
     42  1.1  christos msgid "%|1$| on, %|2$| off"
     43  1.1  christos msgstr ""
     44  1.1  christos 
     45  1.1  christos #, boost-format
     46  1.1  christos msgid "%1% on, %2% off"
     47  1.1  christos msgstr ""
     48  1.1  christos 
     49  1.1  christos #, c-format, boost-format
     50  1.1  christos msgid "heuristic %s on, %s off"
     51  1.1  christos msgstr ""
     52  1.1  christos 
     53  1.1  christos #, c-format, boost-format
     54  1.1  christos msgid "heuristic %1$d on, %2$d off"
     55  1.1  christos msgstr ""
     56  1.1  christos 
     57  1.1  christos #, boost-format
     58  1.1  christos msgid "heuristic %|1$| on, %|2$| off"
     59  1.1  christos msgstr ""
     60  1.1  christos 
     61  1.1  christos #, boost-format
     62  1.1  christos msgid "heuristic %1% on, %2% off"
     63  1.1  christos msgstr ""
     64  1.1  christos EOF
     65  1.1  christos 
     66  1.1  christos : ${DIFF=diff}
     67  1.1  christos ${DIFF} xg-c-14.ok xg-c-14.po
     68  1.1  christos result=$?
     69  1.1  christos 
     70  1.1  christos rm -fr $tmpfiles
     71  1.1  christos 
     72  1.1  christos exit $result
     73