-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest_delete.f90
55 lines (46 loc) · 1.87 KB
/
test_delete.f90
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
program test_delete
use iso_fortran_env, only: stderr => error_unit
use http, only: request, pair_type, HTTP_DELETE, response_type
implicit none
type(response_type) :: res
character(:), allocatable :: original_content, msg
logical :: ok = .true.
original_content = '{"id":1,"title":"iPhone 9","description":"An apple mobile which is nothing like &
apple","price":549,"discountPercentage":12.96,"rating":4.69,"stock":94,"brand":"Apple","category":&
"smartphones","thumbnail":"https://i.dummyjson.com/data/products/1/thumbnail.jpg","images":&
["https://i.dummyjson.com/data/products/1/1.jpg","https://i.dummyjson.com/data/products/1/2.jpg",&
"https://i.dummyjson.com/data/products/1/3.jpg","https://i.dummyjson.com/data/products/1/4.jpg",&
"https://i.dummyjson.com/data/products/1/thumbnail.jpg"],"isDeleted":true'
res = request(url='https://dummyjson.com/products/1', method=HTTP_DELETE)
msg = 'test_delete: '
if (.not. res%ok) then
ok = .false.
msg = msg // res%err_msg
write(stderr, '(a)') msg
error stop 1
end if
! Status Code Validation
if (res%status_code /= 200) then
ok = .false.
print '(a)', 'Failed : Status Code Validation'
end if
! Content Length Validation
if (res%content_length /= (len(original_content)+40) .or. &
len(res%content) /= (len(original_content)+40)) then
ok = .false.
print '(a)', 'Failed : Content Length Validation'
end if
! Content Validation
if (res%content(1:535) /= original_content) then
ok = .false.
print '(a)', 'Failed : Content Validation'
end if
if (.not. ok) then
msg = msg // 'Test Case Failed'
write(stderr, '(a)'), msg
error stop 1
else
msg = msg // 'All tests passed.'
print '(a)', msg
end if
end program test_delete