mirror of
https://github.com/tailix/libkernaux.git
synced 2026-08-15 11:00:07 -04:00
Main: examples/printf_fmt.c: improve example
This commit is contained in:
parent
af4a3bcde2
commit
7a06114ab6
1 changed files with 25 additions and 0 deletions
|
|
@ -4,15 +4,40 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const char *format = "s";
|
||||
|
||||
struct KernAux_PrintfFmt_Spec spec = KernAux_PrintfFmt_Spec_create();
|
||||
KernAux_PrintfFmt_Spec_eval_flags(&spec, &format);
|
||||
if (KernAux_PrintfFmt_Spec_eval_width1(&spec, &format)) {
|
||||
// Actually this line won't be executed.
|
||||
KernAux_PrintfFmt_Spec_eval_width2(&spec, 0);
|
||||
}
|
||||
if (KernAux_PrintfFmt_Spec_eval_precision1(&spec, &format)) {
|
||||
// Actually this line won't be executed.
|
||||
KernAux_PrintfFmt_Spec_eval_precision2(&spec, 0);
|
||||
}
|
||||
KernAux_PrintfFmt_Spec_eval_length(&spec, &format);
|
||||
KernAux_PrintfFmt_Spec_eval_type(&spec, &format);
|
||||
|
||||
assert(spec.flags == 0);
|
||||
assert(spec.width == 0);
|
||||
assert(spec.precision == 0);
|
||||
assert(spec.type == KERNAUX_PRINTF_FMT_TYPE_STR);
|
||||
assert(spec.base == 0);
|
||||
}
|
||||
|
||||
{
|
||||
const char *format = "012.34f";
|
||||
|
||||
struct KernAux_PrintfFmt_Spec spec = KernAux_PrintfFmt_Spec_create();
|
||||
KernAux_PrintfFmt_Spec_eval_flags(&spec, &format);
|
||||
if (KernAux_PrintfFmt_Spec_eval_width1(&spec, &format)) {
|
||||
// Actually this line won't be executed.
|
||||
KernAux_PrintfFmt_Spec_eval_width2(&spec, 0);
|
||||
}
|
||||
if (KernAux_PrintfFmt_Spec_eval_precision1(&spec, &format)) {
|
||||
// Actually this line won't be executed.
|
||||
KernAux_PrintfFmt_Spec_eval_precision2(&spec, 0);
|
||||
}
|
||||
KernAux_PrintfFmt_Spec_eval_length(&spec, &format);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue