I have written a c program, which works, it works on the terminal. And I wanted to run a shell script to test my code. The issue is I can't seem to figure out how to get the output of my q1_sequence to match with my expected value.
#!/bin/sh
OUTPUT="$(./q1_sequence 5 1 3 2 1)"
echo $OUTPUT
EXPECTED="5 1 3 2 1 : returns a value of 99 and 15 iterations"
if [ "$OUTPUT" == "$EXPECTED" ]
then
echo "Test was true"
else
echo "Test was not true"
fi
I expected this to be true, and for the console to state that this was true. however I don't get that at all.
What I get is:
sh testing.sh
5 1 3 2 1 : returns a value of 99 and 15 iterations
testing.sh: 8: [: 5 1 3 2 1 : returns a value of 99 and 15 iterations: unexpected operator
Test was not true
I'm not sure what I'm doing wrong, or what the unexpected operator is or was. I've tried a lot of different things, and I think I'm missing something but I can't for the life of me figure it out. I've done OUTPUT == "5 1 3 2 1 : returns a value of 99 and 15 iterations"
I've tried a lot of different sort of combinations, but I can't just figure it out so any help would be helpful.