#!/bin/bash

export APERTIUM_TRANSFUSE=no
set -e -u

cd "$(dirname "$0")"

declare -a input expected

input[0]='a "Hello, World" app
<code>update"</code>
<img src="hi"/>NULL>
<script>a=">";</script>
<img other="1" alt="ONE">
<img other="1">
<img alt="TWO" other="x"/>
<a href="hi">EINS<br/>ZWEI
<img/>DREI 𝜊
<img alt="THREE">FIER
<img alt="FOUR"/>'
expected[0]='a "Hello, World" app[
<code>]update"[<\/code>
<img src="hi"\/>]NULL[>
<script>a=">";<\/script>
<img other="1" alt="]ONE[">
<img other="1">
<img alt="]TWO[" other="x"\/>
<a href="hi">]EINS[<br\/>]ZWEI[
<img\/>]DREI 𝜊[
<img alt="]THREE[">]FIER[
<img alt="]FOUR.[]["\/>
]'


input[1]='<apertium-notrans>«</apertium-notrans>'
expected[1]='.[][<apertium-notrans>«<\/apertium-notrans>
]'


for i in "${!input[@]}"; do
    result=$(../../apertium/apertium-deshtml-alt <<< "${input[$i]}")
    diff <(echo "${expected[$i]}") <(echo "${result}")
done
