Changeset 39f84ce4 in mainline for uspace/lib/c/test/stdio/scanf.c
- Timestamp:
- 2018-06-13T17:11:44Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4aa1c8
- Parents:
- 5a6c28d1
- git-author:
- Jiri Svoboda <jiri@…> (2018-06-12 18:11:08)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-06-13 17:11:44)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/test/stdio/scanf.c
r5a6c28d1 r39f84ce4 781 781 } 782 782 783 PCUT_TEST(set_ negated)783 PCUT_TEST(set_inverted) 784 784 { 785 785 int rc; … … 825 825 PCUT_ASSERT_TRUE(chars[1] == 'b'); 826 826 PCUT_ASSERT_TRUE(chars[2] == 'c'); 827 PCUT_ASSERT_TRUE(chars[3] == '\0'); 828 PCUT_ASSERT_TRUE(chars[4] == 'X'); 829 } 830 831 PCUT_TEST(set_with_leading_dash) 832 { 833 int rc; 834 char chars[chars_size]; 835 836 /* Set conversion with leading '-' in scanset */ 837 memset(chars, 'X', chars_size); 838 rc = sscanf("a-bc[", "%[-abc]", chars); 839 PCUT_ASSERT_INT_EQUALS(1, rc); 840 PCUT_ASSERT_TRUE(chars[0] == 'a'); 841 PCUT_ASSERT_TRUE(chars[1] == '-'); 842 PCUT_ASSERT_TRUE(chars[2] == 'b'); 843 PCUT_ASSERT_TRUE(chars[3] == 'c'); 844 PCUT_ASSERT_TRUE(chars[4] == '\0'); 845 PCUT_ASSERT_TRUE(chars[5] == 'X'); 846 } 847 848 PCUT_TEST(set_with_trailing_dash) 849 { 850 int rc; 851 char chars[chars_size]; 852 853 /* Set conversion with trailing '-' in scanset */ 854 memset(chars, 'X', chars_size); 855 rc = sscanf("a-bc]", "%[abc-]", chars); 856 PCUT_ASSERT_INT_EQUALS(1, rc); 857 PCUT_ASSERT_TRUE(chars[0] == 'a'); 858 PCUT_ASSERT_TRUE(chars[1] == '-'); 859 PCUT_ASSERT_TRUE(chars[2] == 'b'); 860 PCUT_ASSERT_TRUE(chars[3] == 'c'); 861 PCUT_ASSERT_TRUE(chars[4] == '\0'); 862 PCUT_ASSERT_TRUE(chars[5] == 'X'); 863 } 864 865 PCUT_TEST(set_inverted_with_leading_dash) 866 { 867 int rc; 868 char chars[chars_size]; 869 870 /* Set conversion with leading '-' in inverted scanset */ 871 memset(chars, 'X', chars_size); 872 rc = sscanf("def-", "%[^-abc]", chars); 873 PCUT_ASSERT_INT_EQUALS(1, rc); 874 PCUT_ASSERT_TRUE(chars[0] == 'd'); 875 PCUT_ASSERT_TRUE(chars[1] == 'e'); 876 PCUT_ASSERT_TRUE(chars[2] == 'f'); 877 PCUT_ASSERT_TRUE(chars[3] == '\0'); 878 PCUT_ASSERT_TRUE(chars[4] == 'X'); 879 } 880 881 PCUT_TEST(set_inverted_with_only_dash) 882 { 883 int rc; 884 char chars[chars_size]; 885 886 /* 887 * ']' after '^' in scanset does not lose meaning of scanset 888 * delimiter 889 */ 890 memset(chars, 'X', chars_size); 891 rc = sscanf("abc-", "%[^-]", chars); 892 PCUT_ASSERT_INT_EQUALS(1, rc); 893 PCUT_ASSERT_TRUE(chars[0] == 'a'); 894 PCUT_ASSERT_TRUE(chars[1] == 'b'); 895 PCUT_ASSERT_TRUE(chars[2] == 'c'); 896 PCUT_ASSERT_TRUE(chars[3] == '\0'); 897 PCUT_ASSERT_TRUE(chars[4] == 'X'); 898 } 899 900 PCUT_TEST(set_inverted_with_dash_caret) 901 { 902 int rc; 903 char chars[chars_size]; 904 905 /* '^' after '-' in scanset does not have special meaning */ 906 memset(chars, 'X', chars_size); 907 rc = sscanf("-^a", "%[-^a]", chars); 908 PCUT_ASSERT_INT_EQUALS(1, rc); 909 PCUT_ASSERT_TRUE(chars[0] == '-'); 910 PCUT_ASSERT_TRUE(chars[1] == '^'); 911 PCUT_ASSERT_TRUE(chars[2] == 'a'); 827 912 PCUT_ASSERT_TRUE(chars[3] == '\0'); 828 913 PCUT_ASSERT_TRUE(chars[4] == 'X');
Note:
See TracChangeset
for help on using the changeset viewer.