Ian Wienand | 9b0ebc4 | 2015-04-17 13:06:47 +1000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Tests for DevStack meta-config functions |
| 4 | |
| 5 | TOP=$(cd $(dirname "$0")/.. && pwd) |
| 6 | |
| 7 | # Import common functions |
| 8 | source $TOP/functions |
| 9 | source $TOP/tests/unittest.sh |
| 10 | |
Mahito OGURA | 98f59aa | 2015-05-11 18:02:34 +0900 | [diff] [blame] | 11 | function test_trueorfalse { |
Ian Wienand | 9b0ebc4 | 2015-04-17 13:06:47 +1000 | [diff] [blame] | 12 | local one=1 |
| 13 | local captrue=True |
| 14 | local lowtrue=true |
Mahito OGURA | 98f59aa | 2015-05-11 18:02:34 +0900 | [diff] [blame] | 15 | local uppertrue=TRUE |
| 16 | local capyes=Yes |
| 17 | local lowyes=yes |
| 18 | local upperyes=YES |
| 19 | |
| 20 | for default in True False; do |
| 21 | for name in one captrue lowtrue uppertrue capyes lowyes upperyes; do |
Ian Wienand | 165afa2 | 2015-05-25 11:29:48 +1000 | [diff] [blame] | 22 | local msg="trueorfalse($default $name)" |
| 23 | assert_equal "True" $(trueorfalse $default $name) "$msg" |
Mahito OGURA | 98f59aa | 2015-05-11 18:02:34 +0900 | [diff] [blame] | 24 | done |
| 25 | done |
| 26 | |
Ian Wienand | 9b0ebc4 | 2015-04-17 13:06:47 +1000 | [diff] [blame] | 27 | local zero=0 |
| 28 | local capfalse=False |
| 29 | local lowfalse=false |
Mahito OGURA | 98f59aa | 2015-05-11 18:02:34 +0900 | [diff] [blame] | 30 | local upperfalse=FALSE |
| 31 | local capno=No |
| 32 | local lowno=no |
| 33 | local upperno=NO |
| 34 | |
| 35 | for default in True False; do |
| 36 | for name in zero capfalse lowfalse upperfalse capno lowno upperno; do |
Ian Wienand | 165afa2 | 2015-05-25 11:29:48 +1000 | [diff] [blame] | 37 | local msg="trueorfalse($default $name)" |
| 38 | assert_equal "False" $(trueorfalse $default $name) "$msg" |
Ian Wienand | 9b0ebc4 | 2015-04-17 13:06:47 +1000 | [diff] [blame] | 39 | done |
| 40 | done |
| 41 | } |
| 42 | |
Mahito OGURA | 98f59aa | 2015-05-11 18:02:34 +0900 | [diff] [blame] | 43 | test_trueorfalse |
Ian Wienand | 9b0ebc4 | 2015-04-17 13:06:47 +1000 | [diff] [blame] | 44 | |
| 45 | report_results |