@@ -113,3 +113,88 @@ extern "C" fn health_monitor_destroy(handle: FFIHandle) {
113113 let _ = Box :: from_raw ( handle as * mut HealthMonitor ) ;
114114 }
115115}
116+
117+ #[ cfg( test) ]
118+ mod tests {
119+ use crate :: deadline:: ffi:: deadline_monitor_builder_create;
120+ use crate :: ffi:: {
121+ health_monitor_builder_add_deadline_monitor, health_monitor_builder_build, health_monitor_builder_create,
122+ health_monitor_builder_destroy, health_monitor_destroy, health_monitor_get_deadline_monitor,
123+ health_monitor_start,
124+ } ;
125+ use crate :: IdentTag ;
126+
127+ #[ test]
128+ fn test_health_monitor_builder_create_ok ( ) {
129+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
130+ assert ! ( !health_monitor_builder_handle. is_null( ) ) ;
131+ }
132+
133+ #[ test]
134+ fn test_health_monitor_builder_destroy_ok ( ) {
135+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
136+ health_monitor_builder_destroy ( health_monitor_builder_handle) ;
137+ }
138+
139+ #[ test]
140+ fn test_health_monitor_builder_add_deadline_monitor_ok ( ) {
141+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
142+ let deadline_monitor_tag = IdentTag :: new ( "deadline_monitor" ) ;
143+ let deadline_monitor_builder_handle = deadline_monitor_builder_create ( ) ;
144+ health_monitor_builder_add_deadline_monitor (
145+ health_monitor_builder_handle,
146+ & deadline_monitor_tag as * const IdentTag ,
147+ deadline_monitor_builder_handle,
148+ ) ;
149+ }
150+
151+ #[ test]
152+ fn test_health_monitor_builder_build_ok ( ) {
153+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
154+ let health_monitor_handle = health_monitor_builder_build ( health_monitor_builder_handle, 200 , 100 ) ;
155+ assert ! ( !health_monitor_handle. is_null( ) ) ;
156+ }
157+
158+ #[ test]
159+ fn test_health_monitor_get_deadline_monitor_ok ( ) {
160+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
161+ let deadline_monitor_tag = IdentTag :: new ( "deadline_monitor" ) ;
162+ let deadline_monitor_builder_handle = deadline_monitor_builder_create ( ) ;
163+ health_monitor_builder_add_deadline_monitor (
164+ health_monitor_builder_handle,
165+ & deadline_monitor_tag as * const IdentTag ,
166+ deadline_monitor_builder_handle,
167+ ) ;
168+ let health_monitor_handle = health_monitor_builder_build ( health_monitor_builder_handle, 200 , 100 ) ;
169+
170+ let deadline_monitor_handle =
171+ health_monitor_get_deadline_monitor ( health_monitor_handle, & deadline_monitor_tag as * const IdentTag ) ;
172+ assert ! ( !deadline_monitor_handle. is_null( ) ) ;
173+ }
174+
175+ #[ test]
176+ fn test_health_monitor_start_ok ( ) {
177+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
178+ let deadline_monitor_tag = IdentTag :: new ( "deadline_monitor" ) ;
179+ let deadline_monitor_builder_handle = deadline_monitor_builder_create ( ) ;
180+ health_monitor_builder_add_deadline_monitor (
181+ health_monitor_builder_handle,
182+ & deadline_monitor_tag as * const IdentTag ,
183+ deadline_monitor_builder_handle,
184+ ) ;
185+ let health_monitor_handle = health_monitor_builder_build ( health_monitor_builder_handle, 200 , 100 ) ;
186+
187+ let deadline_monitor_handle =
188+ health_monitor_get_deadline_monitor ( health_monitor_handle, & deadline_monitor_tag as * const IdentTag ) ;
189+ assert ! ( !deadline_monitor_handle. is_null( ) ) ;
190+
191+ health_monitor_start ( health_monitor_handle) ;
192+ }
193+
194+ #[ test]
195+ fn test_health_monitor_destroy_ok ( ) {
196+ let health_monitor_builder_handle = health_monitor_builder_create ( ) ;
197+ let health_monitor_handle = health_monitor_builder_build ( health_monitor_builder_handle, 200 , 100 ) ;
198+ health_monitor_destroy ( health_monitor_handle) ;
199+ }
200+ }
0 commit comments