Re: [libgpiod v2][PATCH v2] bindings: cxx: tests: use the builder pattern for the GPIO simulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 15, 2022 at 10:47:23AM +0200, Bartosz Golaszewski wrote:
> In order to make the interface more elegant use the Rust-like builder
> pattern for the GPIO simulator class.
> 
> Signed-off-by: Bartosz Golaszewski <brgl@xxxxxxxx>
> ---

Was there a v1 for this patch?

[snip]

> diff --git a/bindings/cxx/tests/tests-chip-info.cpp b/bindings/cxx/tests/tests-chip-info.cpp
> index a6bb123..717c387 100644
> --- a/bindings/cxx/tests/tests-chip-info.cpp
> +++ b/bindings/cxx/tests/tests-chip-info.cpp
> @@ -8,13 +8,17 @@
>  #include "gpiosim.hpp"
>  #include "helpers.hpp"
>  
> -using property = ::gpiosim::chip::property;
> +using ::gpiosim::make_sim;
>  
>  namespace {
>  
>  TEST_CASE("chip_info properties can be read", "[chip-info][chip]")
>  {
> -	::gpiosim::chip sim({{ property::NUM_LINES, 8 }, { property::LABEL, "foobar" }});
> +	auto sim = make_sim()
> +		.set_num_lines(8)
> +		.set_label("foobar")
> +		.build();
> +

You do this a few times, so perhaps add a helper to create a simple
simulator with a given a number of lines?

(I called the equivalent in my tests a Simpleton, borrowing LinusW's
practice of naming things after yourself.
Not that I'm suggesting you use that name.)

And rename make_sim() to make_sim_builder(), as it the build() that
returns the sim?

Cheers,
Kent.




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux