Fortran · 1757 bytes Raw Blame History
1 program test_watch_literal_paths
2 use fgof_watch, only : init_watch, poll_watch, reset_watch
3 use fgof_watch_types, only : FGOF_WATCH_EVT_CREATED, watch_event, watch_session
4 use watch_test_support, only : ensure_clean_dir, expect_single_event, remove_tree, write_text
5 implicit none
6
7 call test_tab_name()
8 call test_newline_name()
9
10 contains
11
12 subroutine test_tab_name()
13 character(len=*), parameter :: root = "build/watch-tests-tab-name"
14 character(len=:), allocatable :: tab_path
15 type(watch_event), allocatable :: events(:)
16 type(watch_session) :: session
17
18 call ensure_clean_dir(root)
19 call init_watch(session, root)
20
21 tab_path = root // "/tab" // achar(9) // "name.txt"
22 call write_text(tab_path, "alpha")
23 events = poll_watch(session)
24 call expect_single_event(events, FGOF_WATCH_EVT_CREATED, tab_path, "", .false., "tab characters in paths should round-trip through watch events")
25
26 call reset_watch(session)
27 call remove_tree(root)
28 end subroutine test_tab_name
29
30 subroutine test_newline_name()
31 character(len=*), parameter :: root = "build/watch-tests-newline-name"
32 character(len=:), allocatable :: newline_path
33 type(watch_event), allocatable :: events(:)
34 type(watch_session) :: session
35
36 call ensure_clean_dir(root)
37 call init_watch(session, root)
38
39 newline_path = root // "/line" // new_line("a") // "break.txt"
40 call write_text(newline_path, "alpha")
41 events = poll_watch(session)
42 call expect_single_event(events, FGOF_WATCH_EVT_CREATED, newline_path, "", .false., "newline characters in paths should round-trip through watch events")
43
44 call reset_watch(session)
45 call remove_tree(root)
46 end subroutine test_newline_name
47 end program test_watch_literal_paths
48