Fortran · 1039 bytes Raw Blame History
1 program state_version_demo
2 use fgof_state, only : FGOF_STATE_ERR_VERSION, clear_state_options, load_state_text, remove_state_document, save_state_text
3 use fgof_state_types, only : state_document, state_options, state_text_result
4 implicit none
5
6 type(state_options) :: options
7 type(state_document) :: document
8 type(state_text_result) :: load_result
9
10 options = clear_state_options()
11 options%root_dir = "build/example-state-version"
12 options%namespace = "demo-app"
13
14 document = save_state_text("state.json", "hello", options, version=3)
15 if (document%error_code /= 0) error stop "save failed in version demo"
16
17 load_result = load_state_text("state.json", options, expected_version=2)
18 if (load_result%error_code /= FGOF_STATE_ERR_VERSION) error stop "version demo should surface mismatch"
19
20 print "(a,i0)", "stored_version=", load_result%document%version
21
22 document = remove_state_document("state.json", options)
23 if (document%error_code /= 0) error stop "cleanup failed in version demo"
24 end program state_version_demo
25