aboutsummaryrefslogtreecommitdiff
path: root/shunit2-2.0.3/src/test/testFailures
blob: 9410510c110424150560be5aef44fef33389eacc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /bin/sh
# $Id$
# vim: expandtab
# author: Kate Ward <kate.ward@forestent.com>
#
# Self-testing unit tests for shUnit2 failures
#

MSG='This is a test message'

#-----------------------------------------------------------------------------
# suite tests
#

commonNotEqualsSame()
{
  fn=$1

  msg='same, with message'
  rslt=`${fn} "${MSG}" 'x' 'x' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='same'
  rslt=`${fn} 'x' 'x' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='not same'
  rslt=`${fn} 'x' 'y' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='null values'
  rslt=`${fn} '' '' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='too few arguments'
  rslt=`${fn} 2>&1`
  assertNotSame "${msg}" '' "${rslt}"
}

testFail()
{
  msg='with message'
  rslt=`fail "${MSG}" 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='without message'
  rslt=`fail 2>&1`
  assertNotSame "${msg}" '' "${rslt}"
}

testFailNotEquals()
{
  commonNotEqualsSame 'failNotEquals'
}

testFailSame()
{
  msg='same, with message'
  rslt=`failSame "${MSG}" 'x' 'x' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='same'
  rslt=`failSame 'x' 'x' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='not same'
  rslt=`failSame 'x' 'y' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='null values'
  rslt=`failSame '' '' 2>&1`
  assertNotSame "${msg}" '' "${rslt}"

  msg='too few arguments'
  rslt=`failSame 2>&1`
  assertNotSame "${msg}" '' "${rslt}"
}

testFailNotSame()
{
  commonNotEqualsSame 'failNotSame'
}

#-----------------------------------------------------------------------------
# suite functions
#

# load and run shUnit2
. ./shunit2