Skip to content

Commit ca8ba4d

Browse files
committed
Added tests for all the network_http_ C code added recently
1 parent e476444 commit ca8ba4d

11 files changed

+309
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Feature: library test - network_http_add_header
2+
3+
This tests fujinet-network atari network_http_add_header
4+
5+
Scenario: execute _network_http_add_header
6+
Given atari-fn-nw application test setup
7+
And I add common src file "network_http_add_header.c"
8+
And I add file for compiling "features/test-setup/test-apps/test_ww.s"
9+
And I add file for compiling "features/atari/stubs/stub_network_write.s"
10+
And I create and load atari application
11+
And I write string "N:foo" as ascii to memory address $a012
12+
And I write word at t_w1 with hex $a012
13+
And I write string "header" as ascii to memory address $a123
14+
And I write word at t_w2 with hex $a123
15+
And I write word at t_fn with address _network_http_add_header
16+
And I write memory at t_return with $96
17+
18+
When I execute the procedure at _init for no more than 200 instructions
19+
20+
# return values
21+
Then I expect register A equal $96
22+
And I expect register X equal $00
23+
24+
# check parameters set correctly
25+
And I expect to see t_ds equal lo($a012)
26+
And I expect to see t_ds+1 equal hi($a012)
27+
And I expect to see t_buf equal lo($a123)
28+
And I expect to see t_buf+1 equal hi($a123)
29+
# length of "header"
30+
And I expect to see t_len equal lo($06)
31+
And I expect to see t_len+1 equal hi($06)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Feature: library test - network_http_delete
2+
3+
This tests fujinet-network atari network_http_delete
4+
5+
Scenario: execute _network_http_delete
6+
Given atari-fn-nw application test setup
7+
And I add common src file "network_http_delete.c"
8+
And I add file for compiling "features/test-setup/test-apps/test_wb.s"
9+
And I add file for compiling "features/atari/stubs/stub_network_open.s"
10+
And I create and load atari application
11+
And I write string "N:foo" as ascii to memory address $a012
12+
And I write word at t_w1 with hex $a012
13+
And I write memory at t_b2 with $ef
14+
And I write word at t_fn with address _network_http_delete
15+
And I write memory at t_return with $96
16+
17+
When I execute the procedure at _init for no more than 150 instructions
18+
19+
# return values
20+
Then I expect register A equal $96
21+
And I expect register X equal $00
22+
23+
# check parameters set correctly
24+
And I expect to see t_ds equal lo($a012)
25+
And I expect to see t_ds+1 equal hi($a012)
26+
# OPEN_MODE_HTTP_DELETE_H
27+
And I expect to see t_mode equal $09
28+
And I expect to see t_trans equal $ef
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Feature: library test - network_http_end_add_headers
2+
3+
This tests fujinet-network atari network_http_end_add_headers
4+
5+
Scenario: execute _network_http_end_add_headers
6+
Given atari-fn-nw application test setup
7+
And I add common src file "network_http_end_add_headers.c"
8+
And I add file for compiling "features/test-setup/test-apps/test_w.s"
9+
And I add file for compiling "features/atari/stubs/stub_network_http_set_channel_mode.s"
10+
And I create and load atari application
11+
And I write string "N:foo" as ascii to memory address $a012
12+
And I write word at t_w1 with hex $a012
13+
And I write word at t_fn with address _network_http_end_add_headers
14+
And I write memory at t_return with $96
15+
16+
When I execute the procedure at _init for no more than 100 instructions
17+
18+
# return values
19+
Then I expect register A equal $96
20+
And I expect register X equal $00
21+
22+
# check parameters set correctly
23+
And I expect to see t_ds equal lo($a012)
24+
And I expect to see t_ds+1 equal hi($a012)
25+
# HTTP_CHAN_MODE_BODY
26+
And I expect to see t_mode equal $00
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Feature: library test - network_http_post
2+
3+
This tests fujinet-network atari network_http_post
4+
5+
Scenario: execute _network_http_post
6+
Given atari-fn-nw application test setup
7+
And I add common src file "network_http_post.c"
8+
And I add file for compiling "features/test-setup/test-apps/test_ww.s"
9+
And I add file for compiling "features/atari/stubs/stub_network_write.s"
10+
And I add file for compiling "features/atari/stubs/stub_network_http_set_channel_mode_multi.s"
11+
And I create and load atari application
12+
And I write string "N:foo" as ascii to memory address $a012
13+
And I write word at t_w1 with hex $a012
14+
And I write string "data" as ascii to memory address $a123
15+
And I write word at t_w2 with hex $a123
16+
And I write word at t_fn with address _network_http_post
17+
And I write memory at t_m_return with $00
18+
And I write memory at t_m_return+1 with $96
19+
And I write memory at t_return with $00
20+
21+
When I execute the procedure at _init for no more than 300 instructions
22+
23+
# return values
24+
Then I expect register A equal $96
25+
And I expect register X equal $00
26+
27+
# check parameters set correctly for network_http_set_channel_mode for both calls to it
28+
And I expect to see t_m_ds_l equal lo($a012)
29+
And I expect to see t_m_ds_h equal hi($a012)
30+
And I expect to see t_m_ds_l+1 equal lo($a012)
31+
And I expect to see t_m_ds_h+1 equal hi($a012)
32+
# HTTP_CHAN_MODE_POST_SET_DATA
33+
And I expect to see t_m_mode equal $04
34+
# HTTP_CHAN_MODE_BODY
35+
And I expect to see t_m_mode+1 equal $00
36+
37+
# check params for network_write
38+
And I expect to see t_ds equal lo($a012)
39+
And I expect to see t_ds+1 equal hi($a012)
40+
And I expect to see t_buf equal lo($a123)
41+
And I expect to see t_buf+1 equal hi($a123)
42+
# length of "data"
43+
And I expect to see t_len equal lo($04)
44+
And I expect to see t_len+1 equal hi($04)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Feature: library test - network_http_put
2+
3+
This tests fujinet-network atari network_http_put
4+
5+
Scenario: execute _network_http_put
6+
Given atari-fn-nw application test setup
7+
And I add common src file "network_http_put.c"
8+
And I add file for compiling "features/test-setup/test-apps/test_ww.s"
9+
And I add file for compiling "features/atari/stubs/stub_network_post.s"
10+
And I create and load atari application
11+
And I write string "N:foo" as ascii to memory address $a012
12+
And I write word at t_w1 with hex $a012
13+
And I write string "data" as ascii to memory address $a123
14+
And I write word at t_w2 with hex $a123
15+
And I write word at t_fn with address _network_http_put
16+
And I write memory at t_return with $96
17+
18+
When I execute the procedure at _init for no more than 120 instructions
19+
20+
# return values
21+
Then I expect register A equal $96
22+
And I expect register X equal $00
23+
24+
# check parameters set correctly
25+
And I expect to see t_ds equal lo($a012)
26+
And I expect to see t_ds+1 equal hi($a012)
27+
And I expect to see t_data equal lo($a123)
28+
And I expect to see t_data+1 equal hi($a123)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Feature: library test - network_http_start_add_headers
2+
3+
This tests fujinet-network atari network_http_start_add_headers
4+
5+
Scenario: execute _network_http_start_add_headers
6+
Given atari-fn-nw application test setup
7+
And I add common src file "network_http_start_add_headers.c"
8+
And I add file for compiling "features/test-setup/test-apps/test_w.s"
9+
And I add file for compiling "features/atari/stubs/stub_network_http_set_channel_mode.s"
10+
And I create and load atari application
11+
And I write string "N:foo" as ascii to memory address $a012
12+
And I write word at t_w1 with hex $a012
13+
And I write word at t_fn with address _network_http_start_add_headers
14+
And I write memory at t_return with $96
15+
16+
When I execute the procedure at _init for no more than 100 instructions
17+
18+
# return values
19+
Then I expect register A equal $96
20+
And I expect register X equal $00
21+
22+
# check parameters set correctly
23+
And I expect to see t_ds equal lo($a012)
24+
And I expect to see t_ds+1 equal hi($a012)
25+
# HTTP_CHAN_MODE_SET_HEADERS
26+
And I expect to see t_mode equal $03
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.export _network_http_set_channel_mode
2+
.export t_ds, t_mode, t_return
3+
4+
.import popax
5+
6+
.include "zp.inc"
7+
.include "macros.inc"
8+
9+
; uint8_t network_http_set_channel_mode(char* devicespec, uint8_t mode);
10+
_network_http_set_channel_mode:
11+
sta t_mode
12+
popax t_ds
13+
14+
ldx #$00
15+
lda t_return
16+
rts
17+
18+
19+
t_ds: .res 2
20+
t_mode: .res 1
21+
22+
t_return: .res 1
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.export _network_http_set_channel_mode
2+
.export t_m_ds_l, t_m_ds_h, t_m_mode, t_m_return
3+
4+
.import popax
5+
6+
.include "zp.inc"
7+
.include "macros.inc"
8+
9+
; uint8_t network_http_set_channel_mode(char* devicespec, uint8_t mode);
10+
_network_http_set_channel_mode:
11+
ldy t_round
12+
13+
; save the parameters to the function so we can test they were set correctly
14+
sta t_m_mode, y
15+
16+
jsr popax
17+
ldy t_round
18+
sta t_m_ds_l, y
19+
txa
20+
sta t_m_ds_h, y
21+
22+
23+
inc t_round
24+
ldx #$00
25+
lda t_m_return, y
26+
rts
27+
28+
t_round: .byte 0
29+
30+
t_m_ds_l: .res 2
31+
t_m_ds_h: .res 2
32+
t_m_mode: .res 2
33+
t_m_return: .res 2
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.export _network_open
2+
.export t_ds, t_mode, t_trans, t_return
3+
4+
.import popa
5+
.import popax
6+
7+
.include "zp.inc"
8+
.include "macros.inc"
9+
10+
; uint8_t network_open(char* devicespec, uint8_t mode, uint8_t trans);
11+
_network_open:
12+
sta t_trans
13+
popa t_mode
14+
popax t_ds
15+
16+
ldx #$00
17+
lda t_return
18+
rts
19+
20+
21+
t_ds: .res 2
22+
t_mode: .res 1
23+
t_trans: .res 1
24+
25+
t_return: .res 1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.export _network_http_post
2+
.export t_ds, t_data, t_return
3+
4+
.import popax
5+
6+
.include "zp.inc"
7+
.include "macros.inc"
8+
9+
; uint8_t network_http_post(char* devicespec, char *data)
10+
_network_http_post:
11+
axinto t_data
12+
popax t_ds
13+
14+
ldx #$00
15+
lda t_return
16+
rts
17+
18+
19+
t_ds: .res 2
20+
t_data: .res 2
21+
22+
t_return: .res 1

0 commit comments

Comments
 (0)