|
1 | 1 | #include "capture.h" |
| 2 | +#include "config.h" |
2 | 3 | #include <mpd/connection.h> |
3 | 4 | #include <mpd/response.h> |
4 | 5 | #include <mpd/capabilities.h> |
|
15 | 16 | #include <limits.h> |
16 | 17 | #include <time.h> |
17 | 18 |
|
| 19 | +#ifdef HAVE_SETLOCALE |
| 20 | +#include <locale.h> |
| 21 | +#endif |
| 22 | + |
18 | 23 | static void |
19 | 24 | abort_command(struct test_capture *capture, |
20 | 25 | struct mpd_connection *connection) |
@@ -360,6 +365,31 @@ START_TEST(test_mount_commands) |
360 | 365 | } |
361 | 366 | END_TEST |
362 | 367 |
|
| 368 | +#ifdef HAVE_SETLOCALE |
| 369 | + |
| 370 | +START_TEST(test_locale) |
| 371 | +{ |
| 372 | + /* choosing a locale that uses the comma instead of the dot as |
| 373 | + the decimal separator to see if this affects libmpdclient |
| 374 | + (it should not because MPD expects the dot) */ |
| 375 | + setlocale(LC_ALL, "de_DE@UTF-8"); |
| 376 | + |
| 377 | + struct test_capture capture; |
| 378 | + struct mpd_connection *c = test_capture_init(&capture); |
| 379 | + |
| 380 | + ck_assert(mpd_send_seek_current(c, -42.5, false)); |
| 381 | + ck_assert_str_eq(test_capture_receive(&capture), "seekcur \"-42.500\"\n"); |
| 382 | + abort_command(&capture, c); |
| 383 | + |
| 384 | + mpd_connection_free(c); |
| 385 | + test_capture_deinit(&capture); |
| 386 | + |
| 387 | + setlocale(LC_ALL, "C"); |
| 388 | +} |
| 389 | +END_TEST |
| 390 | + |
| 391 | +#endif // HAVE_SETLOCALE |
| 392 | + |
363 | 393 | static Suite * |
364 | 394 | create_suite(void) |
365 | 395 | { |
@@ -396,6 +426,12 @@ create_suite(void) |
396 | 426 | tcase_add_test(tc_mount, test_mount_commands); |
397 | 427 | suite_add_tcase(s, tc_mount); |
398 | 428 |
|
| 429 | +#ifdef HAVE_SETLOCALE |
| 430 | + TCase *tc_locale = tcase_create("locale"); |
| 431 | + tcase_add_test(tc_locale, test_locale); |
| 432 | + suite_add_tcase(s, tc_locale); |
| 433 | +#endif // HAVE_SETLOCALE |
| 434 | + |
399 | 435 | return s; |
400 | 436 | } |
401 | 437 |
|
|
0 commit comments