#!/bin/bash # Copyright 2014 (c) Anna Schumaker . $(dirname $0)/_functions function test_add { test_equal "./src/filter.run -a $1" "$2" } function test_lowercase { test_equal "./src/filter.run -l $1" "$2" } function test_text { test_add "$1" "$2" test_lowercase "$1" "$2" } function test_search { num=$(cat -b $DATA_DIR/filter.txt | tail -n 1 | awk '{print $1}') let num=$num-1 test_equal "./src/filter.run -s $num $1" "$2" } new_test "Filter Add and Lowercase Test" test_text " " "" test_text " test text" "test text" test_text "test text" "test text" test_text "Test Text" "test text" test_text "Test? Text!" "test text" test_text "Test?123 Text!456" "test123 text456" test_text "Test?123 Text!456" "test123 text456" test_text "Test(text);123-456" "test text 123 456" test_text "Test((text));;123--456" "test text 123 456" echo new_test "Filter Search Test" file=$DATA_DIR/filter.txt mkdir -p $DATA_DIR echo "0" > $file echo "It's dangerous to go alone! Take this..." >> $file echo "DODONGO DISLIKES SMOKE." >> $file echo "I am Error." >> $file echo "Error knows a secret." >> $file echo "Hey, you pay, then you can open the chests!" >> $file echo "And the Master Sword sleeps again... FOREVER!" >> $file echo "Link checked the chest. Wow! This is a nice chest!" >> $file echo "Hey! Listen! Hey! Listen! Watch out!" >> $file echo "You killed the Deku Tree? How could you?!" >> $file echo "You've met with a terrible fate, haven't you?" >> $file echo "Believe in your strengths... Believe..." >> $file echo "Tingle! Tingle! Kooloo-Limpah!" >> $file echo "Well excuse me, Princess!" >> $file test_search "error" "2 3" test_search "the" "4 5 6 8" test_search "the ch" "4 6" test_search "the CH" "4 6" test_search "the ch y" "4"