OLD | NEW |
1 /* libnih | 1 /* libnih |
2 * | 2 * |
3 * test_string.c - test suite for nih/string.c | 3 * test_string.c - test suite for nih/string.c |
4 * | 4 * |
5 * Copyright © 2009 Scott James Remnant <scott@netsplit.com>. | 5 * Copyright © 2009 Scott James Remnant <scott@netsplit.com>. |
6 * Copyright © 2009 Canonical Ltd. | 6 * Copyright © 2009 Canonical Ltd. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License version 2, as | 9 * it under the terms of the GNU General Public License version 2, as |
10 * published by the Free Software Foundation. | 10 * published by the Free Software Foundation. |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 if (test_alloc_failed) { | 656 if (test_alloc_failed) { |
657 TEST_EQ_P (array, NULL); | 657 TEST_EQ_P (array, NULL); |
658 continue; | 658 continue; |
659 } | 659 } |
660 | 660 |
661 TEST_ALLOC_SIZE (array, sizeof (char *)); | 661 TEST_ALLOC_SIZE (array, sizeof (char *)); |
662 TEST_EQ_P (array[0], NULL); | 662 TEST_EQ_P (array[0], NULL); |
663 | 663 |
664 nih_free (array); | 664 nih_free (array); |
665 } | 665 } |
| 666 |
| 667 /* Check that we can give a string with only repeating |
| 668 * delimiters, enable repeat, and we end up with a one-element |
| 669 * array that only contains a NULL pointer. |
| 670 */ |
| 671 TEST_FEATURE ("with empty string except for delimiters"); |
| 672 TEST_ALLOC_FAIL { |
| 673 array = nih_str_split (NULL, " ", " ", TRUE); |
| 674 |
| 675 if (test_alloc_failed) { |
| 676 TEST_EQ_P (array, NULL); |
| 677 continue; |
| 678 } |
| 679 |
| 680 TEST_ALLOC_SIZE (array, sizeof (char *)); |
| 681 TEST_EQ_P (array[0], NULL); |
| 682 |
| 683 nih_free (array); |
| 684 } |
666 } | 685 } |
667 | 686 |
668 void | 687 void |
669 test_array_new (void) | 688 test_array_new (void) |
670 { | 689 { |
671 char **array; | 690 char **array; |
672 | 691 |
673 /* Check that we can allocate a NULL-terminated array of strings using | 692 /* Check that we can allocate a NULL-terminated array of strings using |
674 * nih_alloc(). | 693 * nih_alloc(). |
675 */ | 694 */ |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 test_array_addn (); | 1528 test_array_addn (); |
1510 test_array_addp (); | 1529 test_array_addp (); |
1511 test_array_copy (); | 1530 test_array_copy (); |
1512 test_array_append (); | 1531 test_array_append (); |
1513 test_str_wrap (); | 1532 test_str_wrap (); |
1514 test_str_screen_width (); | 1533 test_str_screen_width (); |
1515 test_str_screen_wrap (); | 1534 test_str_screen_wrap (); |
1516 | 1535 |
1517 return 0; | 1536 return 0; |
1518 } | 1537 } |
OLD | NEW |