From 222a354b0a24c614caa3aaf360d82aa9331afd09 Mon Sep 17 00:00:00 2001 From: Francois Carouge Date: Thu, 11 Aug 2022 18:07:12 -0700 Subject: [PATCH] [format] add 1x1x0 filter support --- include/fcarouge/internal/format.hpp | 29 ++++++++++++++++++++++++++++ test/format.cpp | 10 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/fcarouge/internal/format.hpp b/include/fcarouge/internal/format.hpp index 2e4492d4f..820385acb 100644 --- a/include/fcarouge/internal/format.hpp +++ b/include/fcarouge/internal/format.hpp @@ -80,4 +80,33 @@ struct std::formatter< } }; +template +struct std::formatter< + fcarouge::kalman, + Char> { + //! @todo Support parsing arguments. + constexpr auto parse(std::basic_format_parse_context &parse_context) + { + return parse_context.begin(); + } + + template + auto format(const fcarouge::kalman &filter, + std::basic_format_context &format_context) + -> OutputIt + { + return format_to(format_context.out(), + "{{f:{},h:{},k:{},p:{},q:{},r:{},s:{},x:{},y:{},z:{}}}", + filter.f(), filter.h(), filter.k(), filter.p(), filter.q(), + filter.r(), filter.s(), filter.x(), filter.y(), + filter.z()); + } +}; + #endif // FCAROUGE_INTERNAL_FORMAT_HPP diff --git a/test/format.cpp b/test/format.cpp index 825f3419c..b47ffecec 100644 --- a/test/format.cpp +++ b/test/format.cpp @@ -48,6 +48,16 @@ namespace fcarouge::test namespace { +//! @test Verifies formatting filters for single-dimension filters without input +//! control. +[[maybe_unused]] auto format110{ [] { + kalman k; + + assert(std::format("{}", k) == "{f:1,h:1,k:1,p:1,q:0,r:0,s:1,x:0,y:0,z:0}"); + + return 0; +}() }; + //! @test Verifies formatting filters for single-dimension filters with input //! control. [[maybe_unused]] auto format111{ [] {