#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test general operation and line wrapping.

cat <<EOF > mm-test1.in1
# first
#. this should be discarded
msgid "1"
msgstr "1x"
# second
#: bogus:1
msgid "2"
msgstr	"this is a really long msgstr "
	"used to test the wrapping to "
	"make sure it works after all "
	"what is a test for if not to test things?"
# third
msgid "3"
msgstr "3z"
EOF

cat <<EOF > mm-test1.in2
#. this is the first
#: snark.c:345
msgid "1"
msgstr ""
#. this is the second
#: hunt.c:759
msgid "2"
msgstr ""
#. this is the third
#: boojum.c:300
msgid "3"
msgstr ""
EOF

: ${MSGMERGE=msgmerge}
${MSGMERGE} -q -o mm-test1.tmp mm-test1.in1 mm-test1.in2 || Exit 1
LC_ALL=C tr -d '\r' < mm-test1.tmp > mm-test1.out || Exit 1

cat << EOF > mm-test1.ok
# first
#. this is the first
#: snark.c:345
msgid "1"
msgstr "1x"

# second
#. this is the second
#: hunt.c:759
msgid "2"
msgstr ""
"this is a really long msgstr used to test the wrapping to make sure it works "
"after all what is a test for if not to test things?"

# third
#. this is the third
#: boojum.c:300
msgid "3"
msgstr "3z"
EOF

: ${DIFF=diff}
${DIFF} mm-test1.ok mm-test1.out
result=$?

exit $result
