Extend the pow_format spec parser beyond alignment so configs can shape the
rendered number, not just pad it. A forced scale (#, k, M, G, T, P) pins the SI
prefix instead of auto-selecting it and, since the author then knows both scale
and unit, hides the prefix and unit by default; U brings the unit back, u hides
it in auto mode, and i forces integer display. b and B override the decimal or
binary base independently of the call site, and a trailing width now fixes the
coefficient field when a scale is forced, overflowing to '#' when it does not
fit.
The old '>' and '<' branches rendered via fmt::format("{}", s), which discarded
every new field on the recursive call; they now build from a single render path
that reads the current formatter, so modifiers survive alignment. The auto path
is byte-identical to before, verified against the previous implementation.
Adds a Catch2 suite covering each modifier alone and combined, plus the
backward-compatible alignment cases, and documents the modifiers in the network
and disk man pages.
42 lines
747 B
Meson
42 lines
747 B
Meson
test_inc = include_directories('../../include')
|
|
|
|
test_dep = [
|
|
catch2,
|
|
fmt,
|
|
gtkmm,
|
|
jsoncpp,
|
|
spdlog,
|
|
]
|
|
test_src = files(
|
|
'../main.cpp',
|
|
'../config.cpp',
|
|
'../../src/config.cpp',
|
|
'JsonParser.cpp',
|
|
'SafeSignal.cpp',
|
|
'format.cpp',
|
|
'sleeper_thread.cpp',
|
|
'command.cpp',
|
|
'command_line_stream.cpp',
|
|
'css_reload_helper.cpp',
|
|
'../../src/util/css_reload_helper.cpp',
|
|
'../../src/util/command_line_stream.cpp',
|
|
)
|
|
|
|
if tz_dep.found()
|
|
test_dep += tz_dep
|
|
test_src += files('date.cpp')
|
|
endif
|
|
|
|
utils_test = executable(
|
|
'utils_test',
|
|
test_src,
|
|
dependencies: test_dep,
|
|
include_directories: test_inc,
|
|
)
|
|
|
|
test(
|
|
'utils',
|
|
utils_test,
|
|
workdir: meson.project_source_root(),
|
|
)
|