blob: c74029d1711c57185d9f692975a5cd66d183ba14 [file] [log] [blame]
William A. Kennington III6fae14e2021-04-20 00:08:40 -07001#!/bin/bash
2# Copyright 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16source "$(dirname "$0")/lib.sh" || exit
17
18(
19 echo '## Test Pass' >&2
20 test_pass() {
21 return 0
22 }
23 main || exit
24) || exit
25
26(
27 echo '## Test Fail' >&2
28 i=0
29 test_pass1() {
30 (( i++ ))
31 return 0
32 }
33 test_fail() {
34 return 1
35 (( i++ ))
36 return 0
37 }
38 test_pass2() {
39 (( i++ ))
40 return 0
41 }
42 ! main || exit
43 (( i == 2 )) || exit
44) || exit
45
46(
47 echo '## Test Deferred Fail' >&2
48 i=0
49 test_expect_fail() {
50 test_err=1 || return
51 (( i++ ))
52 return 0
53 }
54 test_pass() {
55 (( i++ ))
56 return 0
57 }
58 ! main || exit
59 (( i == 2 )) || exit
60) || exit
61
62(
63 echo '## Test Fail' >&2
64 i=0
65 test_fail() {
66 fail 'Failed' || return
67 (( i++ ))
68 return 0
69 }
70 ! main || exit
71 (( i == 1 )) || exit
72) || exit
73
74(
75 echo '## Test Expect Err' >&2
76 i=0
77 test_expect_err() {
78 expect_err 1 false || return
79 (( i++ ))
80 return 0
81 }
82 main || exit
83 (( i == 1 )) || exit
84) || exit
85
86(
87 echo '## Test Expect Err Error' >&2
88 i=0
89 test_expect_err() {
90 expect_err 0 false || return
91 (( i++ ))
92 return 0
93 }
94 ! main || exit
95 (( i == 1 )) || exit
96) || exit
97
98(
99 echo '## Test Num EQ' >&2
100 i=0
101 test_num_eq() {
102 expect_numeq 15 0xf || return
103 expect_numeq 1 1 || return
104 (( i++ ))
105 return 0
106 }
107 main || exit
108 (( i == 1 )) || exit
109) || exit
110
111(
112 echo '## Test Num EQ Error' >&2
113 i=0
114 test_num_eq() {
115 expect_numeq 15 10 || return
116 (( i++ ))
117 return 0
118 }
119 ! main || exit
120 (( i == 1 )) || exit
121) || exit
122
123(
124 echo '## Test Str EQ' >&2
125 i=0
126 test_str_eq() {
127 expect_streq abz abz || return
128 (( i++ ))
129 return 0
130 }
131 main || exit
132 (( i == 1 )) || exit
133) || exit
134
135(
136 echo '## Test Str EQ Error' >&2
137 i=0
138 test_str_eq() {
139 expect_streq 15 0xf || return
140 (( i++ ))
141 return 0
142 }
143 ! main || exit
144 (( i == 1 )) || exit
145) || exit