tests/data-source-request.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #undef G_DISABLE_ASSERT | ||
| 2 | |||
| 3 | #include <gtk/gtk.h> | ||
| 4 | #include <shumate/shumate.h> | ||
| 5 | |||
| 6 | static void | ||
| 7 | 2 | test_data_source_request_data (void) | |
| 8 | { | ||
| 9 | 2 | g_autoptr(ShumateDataSourceRequest) req = shumate_data_source_request_new (1, 2, 3); | |
| 10 | 2 | const char *data1 = "Hello, world!"; | |
| 11 | 2 | const char *data2 = "Goodbye!"; | |
| 12 |
1/2✓ Branch 42 → 43 taken 2 times.
✗ Branch 42 → 44 not taken.
|
4 | g_autoptr(GBytes) bytes1 = g_bytes_new_static (data1, strlen (data1)); |
| 13 |
1/2✓ Branch 40 → 41 taken 2 times.
✗ Branch 40 → 42 not taken.
|
4 | g_autoptr(GBytes) bytes2 = g_bytes_new_static (data2, strlen (data2)); |
| 14 | |||
| 15 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_cmpint (shumate_data_source_request_get_x (req), ==, 1); |
| 16 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_cmpint (shumate_data_source_request_get_y (req), ==, 2); |
| 17 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_cmpint (shumate_data_source_request_get_zoom_level (req), ==, 3); |
| 18 | |||
| 19 | 2 | shumate_data_source_request_emit_data (req, bytes1, FALSE); | |
| 20 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_true (g_bytes_equal (bytes1, shumate_data_source_request_get_data (req))); |
| 21 |
1/2✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 2 times.
|
2 | g_assert_false (shumate_data_source_request_is_completed (req)); |
| 22 | |||
| 23 | 2 | shumate_data_source_request_emit_data (req, bytes2, FALSE); | |
| 24 |
1/2✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 2 times.
|
2 | g_assert_true (g_bytes_equal (bytes2, shumate_data_source_request_get_data (req))); |
| 25 |
1/2✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 2 times.
|
2 | g_assert_false (shumate_data_source_request_is_completed (req)); |
| 26 | |||
| 27 | 2 | shumate_data_source_request_emit_data (req, bytes1, TRUE); | |
| 28 |
1/2✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 2 times.
|
2 | g_assert_true (g_bytes_equal (bytes1, shumate_data_source_request_get_data (req))); |
| 29 |
2/4✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 2 times.
✓ Branch 38 → 39 taken 2 times.
✗ Branch 38 → 40 not taken.
|
2 | g_assert_true (shumate_data_source_request_is_completed (req)); |
| 30 | 2 | } | |
| 31 | |||
| 32 | static void | ||
| 33 | 2 | test_data_source_request_error (void) | |
| 34 | { | ||
| 35 | 2 | g_autoptr(ShumateDataSourceRequest) req = shumate_data_source_request_new (1, 2, 3); | |
| 36 | 2 | const char *data1 = "Hello, world!"; | |
| 37 |
1/2✓ Branch 32 → 33 taken 2 times.
✗ Branch 32 → 34 not taken.
|
4 | g_autoptr(GBytes) bytes1 = g_bytes_new_static (data1, strlen (data1)); |
| 38 |
1/2✓ Branch 30 → 31 taken 2 times.
✗ Branch 30 → 32 not taken.
|
4 | g_autoptr(GError) error = g_error_new (G_IO_ERROR, G_IO_ERROR_EXISTS, "Error!"); |
| 39 | |||
| 40 |
1/2✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 2 times.
|
2 | g_assert_false (shumate_data_source_request_is_completed (req)); |
| 41 | |||
| 42 | 2 | shumate_data_source_request_emit_data (req, bytes1, FALSE); | |
| 43 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_true (g_bytes_equal (bytes1, shumate_data_source_request_get_data (req))); |
| 44 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 2 times.
|
2 | g_assert_false (shumate_data_source_request_is_completed (req)); |
| 45 | |||
| 46 | 2 | shumate_data_source_request_emit_error (req, error); | |
| 47 |
1/2✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 2 times.
|
2 | g_assert_true (shumate_data_source_request_is_completed (req)); |
| 48 |
1/2✗ Branch 22 → 23 not taken.
✓ Branch 22 → 24 taken 2 times.
|
2 | g_assert_null (shumate_data_source_request_get_data (req)); |
| 49 |
2/4✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 2 times.
✓ Branch 28 → 29 taken 2 times.
✗ Branch 28 → 30 not taken.
|
2 | g_assert_cmpstr (shumate_data_source_request_get_error (req)->message, ==, "Error!"); |
| 50 | 2 | } | |
| 51 | |||
| 52 | int | ||
| 53 | 2 | main (int argc, char *argv[]) | |
| 54 | { | ||
| 55 | 2 | g_test_init (&argc, &argv, NULL); | |
| 56 | |||
| 57 | 2 | g_test_add_func ("/data-source-request/data", test_data_source_request_data); | |
| 58 | 2 | g_test_add_func ("/data-source-request/error", test_data_source_request_error); | |
| 59 | |||
| 60 | 2 | return g_test_run (); | |
| 61 | } | ||
| 62 |