| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_fmtcheck.c,v 1.5 2017/12/13 06:47:04 rin Exp $ */ | | 1 | /* $NetBSD: t_fmtcheck.c,v 1.6 2024/04/13 14:02:51 rillig Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code was contributed to The NetBSD Foundation by Allen Briggs. | | 7 | * This code was contributed to The NetBSD Foundation by Allen Briggs. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -65,26 +65,30 @@ struct test_fmt { | | | @@ -65,26 +65,30 @@ struct test_fmt { |
65 | { "%-3", "%d", 2 }, | | 65 | { "%-3", "%d", 2 }, |
66 | { "%d %s", "%d", 2 }, | | 66 | { "%d %s", "%d", 2 }, |
67 | { "%*.*.*d", "%*.*.*d", 2 }, | | 67 | { "%*.*.*d", "%*.*.*d", 2 }, |
68 | { "%d", "%d %s", 1 }, | | 68 | { "%d", "%d %s", 1 }, |
69 | { "%40s", "%20s", 1 }, | | 69 | { "%40s", "%20s", 1 }, |
70 | { "%x %x %x", "%o %u %d", 1 }, | | 70 | { "%x %x %x", "%o %u %d", 1 }, |
71 | { "%o %u %d", "%x %x %X", 1 }, | | 71 | { "%o %u %d", "%x %x %X", 1 }, |
72 | { "%#o %u %#-d", "%x %#x %X", 1 }, | | 72 | { "%#o %u %#-d", "%x %#x %X", 1 }, |
73 | { "%qd", "%llx", 1 }, | | 73 | { "%qd", "%llx", 1 }, |
74 | { "%%", "%llx", 1 }, | | 74 | { "%%", "%llx", 1 }, |
75 | { "%ld %30s %#llx %-10.*e", "This number %lu%% and string %s has %qd numbers and %.*g floats", 1 }, | | 75 | { "%ld %30s %#llx %-10.*e", "This number %lu%% and string %s has %qd numbers and %.*g floats", 1 }, |
76 | { "%o", "%lx", 2 }, | | 76 | { "%o", "%lx", 2 }, |
77 | { "%p", "%lu", 2 }, | | 77 | { "%p", "%lu", 2 }, |
| | | 78 | // When fmtcheck supports '$', it could be used in dcngettext. |
| | | 79 | { "%1$s", "%s", 2 }, |
| | | 80 | { "%1$s %2$s", "%s %s", 2 }, |
| | | 81 | { "%2$d %1$s", "%s %d", 2 }, |
78 | }; | | 82 | }; |
79 | | | 83 | |
80 | ATF_TC(fmtcheck_basic); | | 84 | ATF_TC(fmtcheck_basic); |
81 | ATF_TC_HEAD(fmtcheck_basic, tc) | | 85 | ATF_TC_HEAD(fmtcheck_basic, tc) |
82 | { | | 86 | { |
83 | | | 87 | |
84 | atf_tc_set_md_var(tc, "descr", "Test fmtcheck(3)"); | | 88 | atf_tc_set_md_var(tc, "descr", "Test fmtcheck(3)"); |
85 | } | | 89 | } |
86 | | | 90 | |
87 | ATF_TC_BODY(fmtcheck_basic, tc) | | 91 | ATF_TC_BODY(fmtcheck_basic, tc) |
88 | { | | 92 | { |
89 | unsigned int i, r; | | 93 | unsigned int i, r; |
90 | const char *f, *cf, *f1, *f2; | | 94 | const char *f, *cf, *f1, *f2; |