-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpYac-simple-assertions.http
186 lines (148 loc) · 3.34 KB
/
httpYac-simple-assertions.http
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#
# This test uses httpYac Simple Assertions
#
# See: https://httpyac.github.io/guide/assert.html
#
### Change for 1 cent
POST /api/change
Content-Type: application/json
{
"coins": [1, 5, 10, 25],
"target": 1
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [1]
### Single coin change
POST /api/change
Content-Type: application/json
{
"coins": [1, 5, 10, 25, 100],
"target": 25
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [25]
### Multiple coin change
POST /api/change
Content-Type: application/json
{
"coins": [1, 5, 10, 25, 100],
"target": 15
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [5, 10]
### Change with Lilliputian Coins
POST /api/change
Content-Type: application/json
{
"coins": [1, 4, 15, 20, 50],
"target": 23
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [4, 4, 15]
### Change with Lower Elbonia Coins
POST /api/change
Content-Type: application/json
{
"coins": [1, 5, 10, 21, 25],
"target": 63
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [21, 21, 21]
### Large target values
POST /api/change
Content-Type: application/json
{
"coins": [1, 2, 5, 10, 20, 50, 100],
"target": 999
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100]
### Possible change without unit coins available
POST /api/change
Content-Type: application/json
{
"coins": [2, 5, 10, 20, 50],
"target": 21
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [2, 2, 2, 5, 10]
### Another possible change without unit coins available
POST /api/change
Content-Type: application/json
{
"coins": [4, 5],
"target": 27
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [4, 4, 4, 5, 5, 5]
### A greedy approach is not optimal
POST /api/change
Content-Type: application/json
{
"coins": [1, 10, 11],
"target": 20
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == [10, 10]
### No coins make 0 change
POST /api/change
Content-Type: application/json
{
"coins": [1, 5, 10, 21, 25],
"target": 0
}
?? status == 200
?? header content-type includes json
?? body fewestCoins exists
?? body fewestCoins == []
### Error testing for change smaller than the smallest of coins
POST /api/change
Content-Type: application/json
{
"coins": [5, 10],
"target": 3
}
?? status == 400
?? header content-type includes json
?? body error exists
?? body error == can't make target with given coins
### Error if no combination can add up to target
POST /api/change
Content-Type: application/json
{
"coins": [5, 10],
"target": 94
}
?? status == 400
?? header content-type includes json
?? body error exists
?? body error == can't make target with given coins
### Cannot find negative change values
POST /api/change
Content-Type: application/json
{
"coins": [1, 2, 5],
"target": -5
}
?? status == 400
?? header content-type includes json
?? body error exists
?? body error == Negative change not allowed