# Autotest tests for utils.c Functions
# Tests for standalone utility functions from util.c

AT_BANNER([Utility Functions])

AT_BANNER([convert_lat/lon_l2s/s2l() tests])

AT_SETUP([convert_lat_l2s: convert Xastir lat to high-prec string])
AT_KEYWORDS([util convert_lat_l2s])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lat_l2s_basic], [0], [PASS: convert_lat_l2s: correct
])
AT_CLEANUP

AT_SETUP([convert_lon_l2s: convert Xastir lon to high-prec string])
AT_KEYWORDS([util convert_lon_l2s])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lon_l2s_basic], [0], [PASS: convert_lon_l2s: correct
])
AT_CLEANUP
AT_SETUP([convert_lat_l2s: convert Xastir lat to high-prec string (south lat)])
AT_KEYWORDS([util convert_lat_l2s])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lat_l2s_basic_s], [0], [PASS: convert_lat_l2s: correct
])
AT_CLEANUP

AT_SETUP([convert_lon_l2s: convert Xastir lon to high-prec string (east long)])
AT_KEYWORDS([util convert_lon_l2s])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lon_l2s_basic_e], [0], [PASS: convert_lon_l2s: correct
])
AT_CLEANUP

AT_SETUP([convert_lat_l2s: convert Xastir lat to low-prec string])
AT_KEYWORDS([util convert_lat_l2s])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lat_l2s_lp], [0], [PASS: convert_lat_l2s: correct
])
AT_CLEANUP

AT_SETUP([convert_lon_l2s: convert Xastir lon to low-prec string])
AT_KEYWORDS([util convert_lon_l2s])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lon_l2s_lp], [0], [PASS: convert_lon_l2s: correct
])
AT_CLEANUP

AT_SETUP([convert_lat_l2s: convert Xastir lat from high-prec string])
AT_KEYWORDS([util convert_lat_s2l])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lat_s2l_basic], [0], [PASS: convert_lat_s2l: correct
])
AT_CLEANUP

AT_SETUP([convert_lon_l2s: convert Xastir lon from high-prec string])
AT_KEYWORDS([util convert_lon_s2l])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lon_s2l_basic], [0], [PASS: convert_lon_s2l: correct
])
AT_CLEANUP

AT_SETUP([convert_lat_l2s: convert Xastir lat from high-prec string (south)])
AT_KEYWORDS([util convert_lat_s2l])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lat_s2l_basic_s], [0], [PASS: convert_lat_s2l: correct
])
AT_CLEANUP

AT_SETUP([convert_lon_l2s: convert Xastir lon from high-prec string (east)])
AT_KEYWORDS([util convert_lon_s2l])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_lon_s2l_basic_e], [0], [PASS: convert_lon_s2l: correct
])
AT_CLEANUP

AT_BANNER([tests of round-trip conversion consistency])

AT_SETUP([convert_lat/lon_s2l -> convert_lat/lon_l2s round-trip consistency])
AT_KEYWORDS([util convert_lon_s2l convert_lon_l2s convert_lat_s2l convert_lon_s2l])
AT_CHECK(["$abs_top_builddir/tests/test_util" s2l_l2s_consistency], [0], [PASS: convert_lon_s2l and back: correct
])
AT_CLEANUP

AT_SETUP([convert_lat/lon_l2s -> convert_lat/lon_s2l round-trip consistency])
AT_KEYWORDS([util convert_lon_s2l convert_lon_l2s convert_lat_s2l convert_lon_s2l])
AT_CHECK(["$abs_top_builddir/tests/test_util" l2s_s2l_consistency], [0], [PASS: convert_lon_s2l and back: correct
])
AT_CLEANUP

AT_BANNER([tests of screen coordinate converters])

AT_SETUP([convert_screen_to_xastir: center and corners convert as expected])
AT_KEYWORDS([util convert_screen_to_xastir_coordinates])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_screen_to_xastir_coordinates], [0], [PASS: convert_screen_to_xastir_coordinates: works as expected
])
AT_CLEANUP

AT_SETUP([convert_xastir_to_screen: center and corners convert as expected])
AT_KEYWORDS([util convert_screen_to_xastir_coordinates])
AT_CHECK(["$abs_top_builddir/tests/test_util" convert_xastir_to_screen_coordinates], [0], [PASS: convert_xastir_to_screen_coordinates: works as expected
])
AT_CLEANUP

AT_BANNER([tests of filename shortener for status line])
AT_SETUP([short_filename_for_status: short name not truncated])
AT_KEYWORDS([util short_filename_for_status])
AT_CHECK(["$abs_top_builddir/tests/test_util" short_filename_for_status_notrunc], [0], [PASS: short_filename_for_status
])
AT_CLEANUP

AT_SETUP([short_filename_for_status: long name truncated])
AT_KEYWORDS([util short_filename_for_status])
AT_CHECK(["$abs_top_builddir/tests/test_util" short_filename_for_status_trunc], [0], [PASS: short_filename_for_status
])
AT_CLEANUP
