OSDN Git Service

Kaizen test.
[bashutil/bashutil.git] / test / bumsgTest.sh
1 #!/bin/sh
2 # @(#) bumsgTest.sh ver20140131
3 #
4 # Description:
5 #   Test for bumsg.fnc
6 #
7 # @author Toshiki IGA <tosiki.iga@nifty.ne.jp>
8 # @version 1.0 2014-01-31 created newly.
9 ##############################################################################
10
11 . ../main/bumsg.fnc
12 . ../main/buassert.fnc
13
14 ##############################################################################
15 # Inplace message area: begin
16 MSG_M001='Hello [%s] world!'
17 MSG_M001_sysout=false
18 MSG_M001_syserr=true
19 MSG_M001_logger=true
20 MSG_M001_level=info
21 MSG_M001_embedid=true
22
23 # Test for 9 parameters
24 MSG_M002='[%s][%s][%s][%s][%s][%s][%s][%s][%s]'
25
26 # Test for 10 parameters
27 MSG_M003='[%s][%s][%s][%s][%s][%s][%s][%s][%s][%s]'
28
29 # Inplace message area: end
30 ##############################################################################
31
32 ########################################
33 # Test for getmsg
34 result=`getmsg 'M001' 'Bash'`
35 assertEquals '[bumsgTest.sh#getmsg]basic message printf.' '[M001]Hello [Bash] world!' "${result}"
36
37 result=`getmsg 'M002' '1' '2' '3' '4' '5' '6' '7' '8' '9'`
38 assertEquals '[bumsgTest.sh#getmsg]Test for 9 parameters' '[1][2][3][4][5][6][7][8][9]' "${result}"
39
40 result=`getmsg 'M003' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10'`
41 assertEquals '[bumsgTest.sh#getmsg]Test for 10 parameters' '[1][2][3][4][5][6][7][8][9][10]' "${result}"
42
43 ########################################
44 # Test for getmsgIdEnvKey
45 result=`getmsgIdEnvKey 'M001'`
46 assertEquals '[bumsgTest.sh#getmsgIdEnvKey]message key test.' '${MSG_M001}' "${result}"
47
48 ########################################
49 # Test for getmsgEnvValue
50 result=`getmsgEnvValue '${MSG_M001}'`
51 assertEquals '[bumsgTest.sh#getmsgEnvValue]message value test.' 'Hello [%s] world!' "${result}"
52
53 result=`getmsgEnvValue '${MSG_MISS}'`
54 assertEquals '[bumsgTest.sh#getmsgEnvValue]message value test for non defined key.' '' "${result}"
55
56 ########################################
57 # Test for getmsgEnvBooleanValue
58 `getmsgEnvBooleanValue '${MSG_M001_embedid}'`
59 result=$?
60 assertEquals '[bumsgTest.sh#getmsgEnvBooleanValue]message boolean value test.' '0' "${result}"
61
62 ########################################
63 # Test for ismsgEnvSysout
64 `ismsgEnvSysout 'M001'`
65 result=$?
66 assertEquals '[bumsgTest.sh#ismsgEnvSysout]sysout value test.' '1' "${result}"
67
68 `ismsgEnvSysout 'MISS'`
69 result=$?
70 assertEquals '[bumsgTest.sh#ismsgEnvSysout]sysout value test.' '1' "${result}"
71
72 ########################################
73 # Test for ismsgEnvSyserr
74 `ismsgEnvSyserr 'M001'`
75 result=$?
76 assertEquals '[bumsgTest.sh#ismsgEnvSyserr]syserr value test.' '0' "${result}"
77
78 `ismsgEnvSyserr 'MISS'`
79 result=$?
80 assertEquals '[bumsgTest.sh#ismsgEnvSyserr]syserr value test.' '0' "${result}"
81
82 ########################################
83 # Test for ismsgEnvLogger
84 `ismsgEnvLogger 'M001'`
85 result=$?
86 assertEquals '[bumsgTest.sh#ismsgEnvLogger]logger value test.' '0' "${result}"
87
88 `ismsgEnvLogger 'MISS'`
89 result=$?
90 assertEquals '[bumsgTest.sh#ismsgEnvLogger]logger value test.' '1' "${result}"
91
92 ########################################
93 # Test for ismsgEnvEmbedid
94 `ismsgEnvEmbedid 'M001'`
95 result=$?
96 assertEquals '[bumsgTest.sh#ismsgEnvEmbedid]embedid value test.' '0' "${result}"
97
98 `ismsgEnvEmbedid 'MISS'`
99 result=$?
100 assertEquals '[bumsgTest.sh#ismsgEnvEmbedid]embedid value test.' '1' "${result}"