2015-07-22 09:52:24 +02:00
|
|
|
#!/bin/bash
|
2015-07-22 12:55:39 +02:00
|
|
|
# Script Used by generate_and_run_tests.sh
|
2015-07-22 09:52:24 +02:00
|
|
|
|
2015-07-22 12:31:18 +02:00
|
|
|
set -e
|
|
|
|
|
2015-07-22 13:44:08 +02:00
|
|
|
python tools/extracttests.py --code=test1 $1
|
|
|
|
|
|
|
|
cd test1
|
|
|
|
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 1.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
# (!x) => (x==0)
|
|
|
|
sed -ri 's/([(&][ ]*)\!([a-z]+)([ ]*[&)])/\1\2==0\3/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x==0) => (0==x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*==[ ]*0([ ]*[&)])/\10==\2\3/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (0==x) => (!x)
|
|
|
|
sed -ri 's/([(&][ ]*)0[ ]*==[ ]*([a-z]+)([ ]*[&)])/\1!\2\3/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if (x) => (x!=0)
|
|
|
|
sed -ri 's/(if[ ]*\([ ]*[a-z]+)([ ]*[&)])/\1!=0\2/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# while (x) => (x!=0)
|
|
|
|
sed -ri 's/(while[ ]*\([ ]*[a-z]+)([ ]*[&)])/\1!=0\2/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x!=0) => (0!=x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*!=[ ]*0([ ]*[&)])/\10!=\2\3/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (0!=x) => (x)
|
|
|
|
sed -ri 's/([(&][ ]*)0[ ]*!=[ ]*([a-z]+[ ]*[&)])/\1\2/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
# (x < 0) => (0 > x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x <= 0) => (0 >= x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x > 0) => (0 < x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x >= 0) => (0 <= x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x == 123) => (123 == x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*==[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3==\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (x != 123) => (123 != x)
|
|
|
|
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*\!=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3!=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# (0 < x) => (x > 0)
|
|
|
|
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<[ ]*([a-z]+)([ ]*[&)])/\1\3>\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (0 <= x) => (x >= 0)
|
|
|
|
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (0 > x) => (x < 0)
|
|
|
|
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (0 >= x) => (x <= 0)
|
|
|
|
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (123 == x) => (x == 123)
|
|
|
|
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*==[ ]*([a-z]+)([ ]*[&)])/\1\3==\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
# (123 != x) => (x <= 123)
|
|
|
|
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*\!=[ ]*([a-z]+)([ ]*[&)])/\1\3!=\2\4/' *.cpp
|
2015-07-22 12:55:39 +02:00
|
|
|
../cppcheck -q . 2> 2.txt && diff 1.txt 2.txt
|
2015-07-22 09:52:24 +02:00
|
|
|
|
|
|
|
|
2015-07-22 13:44:08 +02:00
|
|
|
cd ..
|
2015-07-22 09:52:24 +02:00
|
|
|
|
2015-07-22 13:44:08 +02:00
|
|
|
rm -rf test1
|