Changeset ab936440 in mainline for uspace/lib/c/test/string.c
- Timestamp:
- 2019-02-12T20:42:42Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f31ca47
- Parents:
- 7f7817a9 (diff), 4805495 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-02-12 20:26:18)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-02-12 20:42:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/test/string.c
r7f7817a9 rab936440 722 722 } 723 723 724 /** strlen function with empty string and non-zero limit */ 725 PCUT_TEST(strnlen_empty_short) 726 { 727 PCUT_ASSERT_INT_EQUALS(0, strnlen("", 1)); 728 } 729 730 /** strlen function with empty string and zero limit */ 731 PCUT_TEST(strnlen_empty_eq) 732 { 733 PCUT_ASSERT_INT_EQUALS(0, strnlen("", 0)); 734 } 735 736 /** strlen function with non empty string below limit */ 737 PCUT_TEST(strnlen_nonempty_short) 738 { 739 PCUT_ASSERT_INT_EQUALS(3, strnlen("abc", 5)); 740 } 741 742 /** strlen function with non empty string just below limit */ 743 PCUT_TEST(strnlen_nonempty_just_short) 744 { 745 PCUT_ASSERT_INT_EQUALS(3, strnlen("abc", 4)); 746 } 747 748 /** strlen function with non empty string of length equal to limit */ 749 PCUT_TEST(strnlen_nonempty_eq) 750 { 751 PCUT_ASSERT_INT_EQUALS(3, strnlen("abc", 3)); 752 } 753 754 /** strlen function with non empty string of length above limit */ 755 PCUT_TEST(strnlen_nonempty_long) 756 { 757 PCUT_ASSERT_INT_EQUALS(2, strnlen("abc", 2)); 758 } 759 760 /** strdup function with empty string */ 761 PCUT_TEST(strdup_empty) 762 { 763 char *d = strdup(""); 764 PCUT_ASSERT_NOT_NULL(d); 765 PCUT_ASSERT_TRUE(d[0] == '\0'); 766 free(d); 767 } 768 769 /** strdup function with non-empty string */ 770 PCUT_TEST(strdup_nonempty) 771 { 772 char *d = strdup("abc"); 773 PCUT_ASSERT_NOT_NULL(d); 774 PCUT_ASSERT_TRUE(d[0] == 'a'); 775 PCUT_ASSERT_TRUE(d[1] == 'b'); 776 PCUT_ASSERT_TRUE(d[2] == 'c'); 777 PCUT_ASSERT_TRUE(d[3] == '\0'); 778 free(d); 779 } 780 781 /** strndup function with empty string and non-zero limit */ 782 PCUT_TEST(strndup_empty_short) 783 { 784 char *d = strndup("", 1); 785 PCUT_ASSERT_NOT_NULL(d); 786 PCUT_ASSERT_TRUE(d[0] == '\0'); 787 free(d); 788 } 789 790 /** strndup function with empty string and zero limit */ 791 PCUT_TEST(strndup_empty_eq) 792 { 793 char *d = strndup("", 0); 794 PCUT_ASSERT_NOT_NULL(d); 795 PCUT_ASSERT_TRUE(d[0] == '\0'); 796 free(d); 797 } 798 799 /** strndup function with non-empty string of length below limit */ 800 PCUT_TEST(strndup_nonempty_short) 801 { 802 char *d = strndup("abc", 5); 803 PCUT_ASSERT_NOT_NULL(d); 804 PCUT_ASSERT_TRUE(d[0] == 'a'); 805 PCUT_ASSERT_TRUE(d[1] == 'b'); 806 PCUT_ASSERT_TRUE(d[2] == 'c'); 807 PCUT_ASSERT_TRUE(d[3] == '\0'); 808 free(d); 809 } 810 811 /** strndup function with non-empty string of length equal to limit */ 812 PCUT_TEST(strndup_nonempty_eq) 813 { 814 char *d = strndup("abc", 3); 815 PCUT_ASSERT_NOT_NULL(d); 816 PCUT_ASSERT_TRUE(d[0] == 'a'); 817 PCUT_ASSERT_TRUE(d[1] == 'b'); 818 PCUT_ASSERT_TRUE(d[2] == 'c'); 819 PCUT_ASSERT_TRUE(d[3] == '\0'); 820 free(d); 821 } 822 823 /** strndup function with non-empty string of length above limit */ 824 PCUT_TEST(strndup_nonempty_long) 825 { 826 char *d = strndup("abc", 2); 827 PCUT_ASSERT_NOT_NULL(d); 828 PCUT_ASSERT_TRUE(d[0] == 'a'); 829 PCUT_ASSERT_TRUE(d[1] == 'b'); 830 PCUT_ASSERT_TRUE(d[2] == '\0'); 831 free(d); 832 } 833 724 834 PCUT_EXPORT(string);
Note:
See TracChangeset
for help on using the changeset viewer.