diff options
Diffstat (limited to 'src/devices/wifi/tests/test-general.c')
| -rw-r--r-- | src/devices/wifi/tests/test-general.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/devices/wifi/tests/test-general.c b/src/devices/wifi/tests/test-general.c index 3e61c5f0..89eebb22 100644 --- a/src/devices/wifi/tests/test-general.c +++ b/src/devices/wifi/tests/test-general.c @@ -44,16 +44,16 @@ \ success = nm_connection_compare (src, expected, NM_SETTING_COMPARE_FLAG_EXACT); \ if (success == FALSE && DEBUG) { \ - g_message ("\n- COMPLETED ---------------------------------\n"); \ + g_print ("\n- COMPLETED ---------------------------------\n"); \ nm_connection_dump (src); \ - g_message ("+ EXPECTED ++++++++++++++++++++++++++++++++++++\n"); \ + g_print ("+ EXPECTED ++++++++++++++++++++++++++++++++++++\n"); \ nm_connection_dump (expected); \ - g_message ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); \ + g_print ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); \ } \ g_assert (success == TRUE); \ } else { \ if (success) { \ - g_message ("\n- COMPLETED ---------------------------------\n"); \ + g_print ("\n- COMPLETED ---------------------------------\n"); \ nm_connection_dump (src); \ } \ g_assert (success == FALSE); \ @@ -1334,6 +1334,28 @@ test_strength_wext (void) g_assert_cmpint (nm_wifi_utils_level_to_quality (215), ==, 99); } +#define _assert_strength_in_range(x) \ + ({ \ + guint32 _x = (x); \ + g_assert_cmpint (_x, >=, 0); \ + g_assert_cmpint (_x, <=, 100); \ + }) + +static void +test_strength_all (void) +{ + int val; + + for (val = -200; val < 300; val++) + _assert_strength_in_range (nm_wifi_utils_level_to_quality (val)); + _assert_strength_in_range (nm_wifi_utils_level_to_quality (G_MININT)); + _assert_strength_in_range (nm_wifi_utils_level_to_quality (G_MAXINT)); + _assert_strength_in_range (nm_wifi_utils_level_to_quality (G_MININT32)); + _assert_strength_in_range (nm_wifi_utils_level_to_quality (G_MAXINT32)); + _assert_strength_in_range (nm_wifi_utils_level_to_quality (G_MININT16)); + _assert_strength_in_range (nm_wifi_utils_level_to_quality (G_MAXINT16)); +} + /*****************************************************************************/ NMTST_DEFINE (); @@ -1497,6 +1519,8 @@ main (int argc, char **argv) test_strength_percent); g_test_add_func ("/wifi/strength/wext", test_strength_wext); + g_test_add_func ("/wifi/strength/all", + test_strength_all); return g_test_run (); } |