Skip to content

Commit

Permalink
test some invalid cli options
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendes committed May 29, 2024
1 parent 1c13fd5 commit df5f352
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/0505_CLIOptions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 0505_CLIOptions

tests various invalid command line options

## tests

- 1D, network, transport
- appropriate warning for an empty network file
- appropriate warning for a network file without edges
- appropriate warning for test a network file with repeated edges
- ensure that repeated edges are added exactly once to model
- appropriate warning for a network file with non-numeric nodes
115 changes: 115 additions & 0 deletions tests/0505_CLIOptions/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/bin/bash

# work out our folder name
test=${PWD##*/} # to assign to a variable
test=${test:-/} # to correct for the case where PWD=/

fail=0

# test negative number of units
../../sbmodelr -t G ../sources/GeneExpressionUnit.cps -2 > output 2>&1

# check that the correct warning is issued
if ! grep -q "sbmodelr: error: argument rows: -2 is an invalid negative value" output; then
printf 'FAIL %s\n' "${test}"
let "fail = 1"
fi

# test one unit only
../../sbmodelr -t G ../sources/GeneExpressionUnit.cps 1 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: Nothing to do, one copy only is the same as the original model!" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 2"
fi

# test one unit per dimension
../../sbmodelr -t G ../sources/GeneExpressionUnit.cps 1 1 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: Nothing to do, one copy only is the same as the original model!" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 4"
fi

# test one unit per dimension
../../sbmodelr -t G ../sources/GeneExpressionUnit.cps 1 1 1 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: Nothing to do, one copy only is the same as the original model!" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 8"
fi

# test negative kinetic constant value
../../sbmodelr -t G -k -0.2 ../sources/GeneExpressionUnit.cps 2 > output 2>&1

# check that the correct warning is issued
if ! grep -q "sbmodelr: error: argument -k/--transport-k: -0.2 is an invalid negative value" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 16"
fi

# test negative noise level
../../sbmodelr -t G --cn -0.3 uni ../sources/GeneExpressionUnit.cps 2 2 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: 'level' must be a positive floating point number" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 32"
fi

# test integer noise level
../../sbmodelr -t G --cn 3 uni ../sources/GeneExpressionUnit.cps 2 2 > output 2>&1

# check that no warning is issued
if grep -q "ERROR: 'level' must be a positive floating point number" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 64"
fi

# test invalid noise distribution
../../sbmodelr -t G --cn 0.1 foo ../sources/GeneExpressionUnit.cps 2 2 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: dist must be 'uni' or 'norm'" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 128"
fi

# we repeat error values matching those of--cn because we're testing more than 8 conditions

# test negative noise level for --pn
../../sbmodelr -t G --pn G -0.3 uni ../sources/GeneExpressionUnit.cps 2 2 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: 'level' must be a positive floating point number" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 32"
fi

# test integer noise level
../../sbmodelr -t G --pn G 3 uni ../sources/GeneExpressionUnit.cps 2 2 > output 2>&1

# check that no warning is issued
if grep -q "ERROR: 'level' must be a positive floating point number" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 64"
fi

# test invalid noise distribution
../../sbmodelr -t G --pn G 0.1 foo ../sources/GeneExpressionUnit.cps 2 2 > output 2>&1

# check that the correct warning is issued
if ! grep -q "ERROR: dist must be 'uni' or 'norm'" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 128"
fi

if [ "$fail" = 0 ] ; then
printf 'PASS %s\n' "${test}"
rm output *.cps > /dev/null 2>&1
fi

exit $fail

0 comments on commit df5f352

Please sign in to comment.