All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	linux-gpio@vger.kernel.org
Subject: Re: [libgpiod v2][PATCH v2] bindings: cxx: tests: use the builder pattern for the GPIO simulator
Date: Thu, 15 Sep 2022 18:01:39 +0800	[thread overview]
Message-ID: <YyL4AwaJIO9kim9s@sol> (raw)
In-Reply-To: <20220915084723.19910-1-brgl@bgdev.pl>

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@bgdev.pl>
> ---

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.


  reply	other threads:[~2022-09-15 10:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  8:47 [libgpiod v2][PATCH v2] bindings: cxx: tests: use the builder pattern for the GPIO simulator Bartosz Golaszewski
2022-09-15 10:01 ` Kent Gibson [this message]
2022-09-15 11:01   ` Kent Gibson
2022-09-16  7:10     ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YyL4AwaJIO9kim9s@sol \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.