#!/bin/sh

# Unit testing

if cargo test
then
  echo Cargo test succeeded.
else
  ( echo Cargo test failed. && exit 1 )
fi


# Functional tests

cd ../tests/functional/

cargo build

# We search for `?`.
../../target/debug/stringsext -q 16 -g 63 -tx -a All-Ctrl -u Common \
    -e UTF-8 -e utf-16le -e utf-16be -- input1  > output

if diff output expected_output1
then
    echo Commandline test 1 succeeded.
else
    ( echo Commandline test 1 failed. && exit 2 )
fi

# We search for `:`.
../../target/debug/stringsext -n 10 -q 32 -g 58 -tx -a All-Ctrl -u Common \
    -e UTF-8 -e utf-16le -e utf-16be -- input1 input2  > output

if diff output expected_output2
then
    echo Commandline test 2 succeeded.
else
    ( echo Commandline test 2 failed. && exit 3 )
fi

# We search for nothing. Do we get nothing?
../../target/debug/stringsext -q 32 -tx -a None -u None \
    -e UTF-8 -e utf-16le -e utf-16be -- input1 input2  > output

if diff output expected_output3
then
    echo Commandline test 3 succeeded.
else
    ( echo Commandline test 3 failed. && exit 4 )
fi

