[libcamera-devel,1/2] test: object-invoke: Test invocation of method taking a reference argument

Message ID 20200102235311.12009-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 7141ac74fd282cfe62de1a61a1f0edaee3c14d8e
Headers show
Series
  • [libcamera-devel,1/2] test: object-invoke: Test invocation of method taking a reference argument
Related show

Commit Message

Laurent Pinchart Jan. 2, 2020, 11:53 p.m. UTC
Object::invokeMethod() fails with a compilation error when the invoked
method takes a reference argument. Add a test case for this issue.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/object-invoke.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Paul Elder Jan. 3, 2020, 5:18 a.m. UTC | #1
Hi Laurent,

Thank you for the patch.

On Fri, Jan 03, 2020 at 01:53:10AM +0200, Laurent Pinchart wrote:
> Object::invokeMethod() fails with a compilation error when the invoked
> method takes a reference argument. Add a test case for this issue.

I'm still not sure I agree with adding a test that introduces a compile
error... but it only fails compiling tests so maybe it's fine?

In any case the goal is achieved.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  test/object-invoke.cpp | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
> index 560adee14e3a..f9a8bea9dce2 100644
> --- a/test/object-invoke.cpp
> +++ b/test/object-invoke.cpp
> @@ -49,6 +49,10 @@ public:
>  		value_ = value;
>  	}
>  
> +	void methodWithReference(const int &value)
> +	{
> +	}
> +
>  private:
>  	Status status_;
>  	int value_;
> @@ -119,6 +123,14 @@ protected:
>  			return TestFail;
>  		}
>  
> +		/*
> +		 * Test invoking a method that takes reference arguments. This
> +		 * targets compilation, there's no need to check runtime
> +		 * results.
> +		 */
> +		object_.invokeMethod(&InvokedObject::methodWithReference,
> +				     ConnectionTypeBlocking, 42);
> +
>  		return TestPass;
>  	}
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Jan. 3, 2020, 11:31 a.m. UTC | #2
Hi Paul,

On Fri, Jan 03, 2020 at 12:18:20AM -0500, Paul Elder wrote:
> On Fri, Jan 03, 2020 at 01:53:10AM +0200, Laurent Pinchart wrote:
> > Object::invokeMethod() fails with a compilation error when the invoked
> > method takes a reference argument. Add a test case for this issue.
> 
> I'm still not sure I agree with adding a test that introduces a compile
> error... but it only fails compiling tests so maybe it's fine?

If the test came second, there would be no guarantee that the test
catches the right issue, and that the fix fixes the right problem.
That's why we add tests first and then fix issues on top.

> In any case the goal is achieved.
> 
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  test/object-invoke.cpp | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
> > index 560adee14e3a..f9a8bea9dce2 100644
> > --- a/test/object-invoke.cpp
> > +++ b/test/object-invoke.cpp
> > @@ -49,6 +49,10 @@ public:
> >  		value_ = value;
> >  	}
> >  
> > +	void methodWithReference(const int &value)
> > +	{
> > +	}
> > +
> >  private:
> >  	Status status_;
> >  	int value_;
> > @@ -119,6 +123,14 @@ protected:
> >  			return TestFail;
> >  		}
> >  
> > +		/*
> > +		 * Test invoking a method that takes reference arguments. This
> > +		 * targets compilation, there's no need to check runtime
> > +		 * results.
> > +		 */
> > +		object_.invokeMethod(&InvokedObject::methodWithReference,
> > +				     ConnectionTypeBlocking, 42);
> > +
> >  		return TestPass;
> >  	}
> >

Patch

diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
index 560adee14e3a..f9a8bea9dce2 100644
--- a/test/object-invoke.cpp
+++ b/test/object-invoke.cpp
@@ -49,6 +49,10 @@  public:
 		value_ = value;
 	}
 
+	void methodWithReference(const int &value)
+	{
+	}
+
 private:
 	Status status_;
 	int value_;
@@ -119,6 +123,14 @@  protected:
 			return TestFail;
 		}
 
+		/*
+		 * Test invoking a method that takes reference arguments. This
+		 * targets compilation, there's no need to check runtime
+		 * results.
+		 */
+		object_.invokeMethod(&InvokedObject::methodWithReference,
+				     ConnectionTypeBlocking, 42);
+
 		return TestPass;
 	}