test: utils: Add endlines
diff mbox series

Message ID 20250825114409.569050-1-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • test: utils: Add endlines
Related show

Commit Message

Paul Elder Aug. 25, 2025, 11:44 a.m. UTC
Most of the error messages from the utils test had no endlines. Add them
so that the output is nicer.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 test/utils.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Kieran Bingham Sept. 1, 2025, 11:38 a.m. UTC | #1
Quoting Paul Elder (2025-08-25 12:44:09)
> Most of the error messages from the utils test had no endlines. Add them
> so that the output is nicer.

'and standardise on using endl; as we are already using the std
namespace.'

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

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  test/utils.cpp | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/test/utils.cpp b/test/utils.cpp
> index 195fddc97d97..ae5b01746722 100644
> --- a/test/utils.cpp
> +++ b/test/utils.cpp
> @@ -85,7 +85,7 @@ protected:
>                         if (index != i || value != i + 1) {
>                                 cerr << "utils::enumerate(<vector>) test failed: i=" << i
>                                      << ", index=" << index << ", value=" << value
> -                                    << std::endl;
> +                                    << endl;
>                                 return TestFail;
>                         }
>  
> @@ -106,7 +106,7 @@ protected:
>                         if (index != i || value != i) {
>                                 cerr << "utils::enumerate(<span>) test failed: i=" << i
>                                      << ", index=" << index << ", value=" << value
> -                                    << std::endl;
> +                                    << endl;
>                                 return TestFail;
>                         }
>  
> @@ -120,7 +120,7 @@ protected:
>                         if (index != i || value != i * 2) {
>                                 cerr << "utils::enumerate(<array>) test failed: i=" << i
>                                      << ", index=" << index << ", value=" << value
> -                                    << std::endl;
> +                                    << endl;
>                                 return TestFail;
>                         }
>  
> @@ -138,32 +138,32 @@ protected:
>  
>                 exposure = 25ms + 25ms;
>                 if (exposure.get<std::micro>() != 50000.0) {
> -                       cerr << "utils::Duration failed to return microsecond count";
> +                       cerr << "utils::Duration failed to return microsecond count" << endl;
>                         return TestFail;
>                 }
>  
>                 exposure = 1.0s / 4;
>                 if (exposure != 250ms) {
> -                       cerr << "utils::Duration failed scalar divide test";
> +                       cerr << "utils::Duration failed scalar divide test" << endl;
>                         return TestFail;
>                 }
>  
>                 exposure = 5000.5us;
>                 if (!exposure) {
> -                       cerr << "utils::Duration failed boolean test";
> +                       cerr << "utils::Duration failed boolean test" << endl;
>                         return TestFail;
>                 }
>  
>                 os << exposure;
>                 if (os.str() != "5000.50us") {
> -                       cerr << "utils::Duration operator << failed";
> +                       cerr << "utils::Duration operator << failed" << endl;
>                         return TestFail;
>                 }
>  
>                 exposure = 100ms;
>                 ratio = exposure / 25ms;
>                 if (ratio != 4.0) {
> -                       cerr << "utils::Duration failed ratio test";
> +                       cerr << "utils::Duration failed ratio test" << endl;
>                         return TestFail;
>                 }
>  
> @@ -219,7 +219,7 @@ protected:
>                 std::string s = os.str();
>                 if (s != ref) {
>                         cerr << "utils::hex() test failed, expected '" << ref
> -                            << "', got '" << s << "'";
> +                            << "', got '" << s << "'" << endl;
>                         return TestFail;
>                 }
>  
> -- 
> 2.47.2
>
Laurent Pinchart Sept. 1, 2025, 3:21 p.m. UTC | #2
On Mon, Sep 01, 2025 at 12:38:47PM +0100, Kieran Bingham wrote:
> Quoting Paul Elder (2025-08-25 12:44:09)
> > Most of the error messages from the utils test had no endlines. Add them
> > so that the output is nicer.
> 
> 'and standardise on using endl; as we are already using the std
> namespace.'

I'd have skipped that, as I think we shouldn't "use std". It doesn't
matter too much. At some point we should likely replace these messages
with assertion macros and exceptions (gtest was proposed too, it's an
option even if I don't like it much).

> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > ---
> >  test/utils.cpp | 18 +++++++++---------
> >  1 file changed, 9 insertions(+), 9 deletions(-)
> > 
> > diff --git a/test/utils.cpp b/test/utils.cpp
> > index 195fddc97d97..ae5b01746722 100644
> > --- a/test/utils.cpp
> > +++ b/test/utils.cpp
> > @@ -85,7 +85,7 @@ protected:
> >                         if (index != i || value != i + 1) {
> >                                 cerr << "utils::enumerate(<vector>) test failed: i=" << i
> >                                      << ", index=" << index << ", value=" << value
> > -                                    << std::endl;
> > +                                    << endl;
> >                                 return TestFail;
> >                         }
> >  
> > @@ -106,7 +106,7 @@ protected:
> >                         if (index != i || value != i) {
> >                                 cerr << "utils::enumerate(<span>) test failed: i=" << i
> >                                      << ", index=" << index << ", value=" << value
> > -                                    << std::endl;
> > +                                    << endl;
> >                                 return TestFail;
> >                         }
> >  
> > @@ -120,7 +120,7 @@ protected:
> >                         if (index != i || value != i * 2) {
> >                                 cerr << "utils::enumerate(<array>) test failed: i=" << i
> >                                      << ", index=" << index << ", value=" << value
> > -                                    << std::endl;
> > +                                    << endl;
> >                                 return TestFail;
> >                         }
> >  
> > @@ -138,32 +138,32 @@ protected:
> >  
> >                 exposure = 25ms + 25ms;
> >                 if (exposure.get<std::micro>() != 50000.0) {
> > -                       cerr << "utils::Duration failed to return microsecond count";
> > +                       cerr << "utils::Duration failed to return microsecond count" << endl;

I'd wrap this line and possibly the next one.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> >                         return TestFail;
> >                 }
> >  
> >                 exposure = 1.0s / 4;
> >                 if (exposure != 250ms) {
> > -                       cerr << "utils::Duration failed scalar divide test";
> > +                       cerr << "utils::Duration failed scalar divide test" << endl;
> >                         return TestFail;
> >                 }
> >  
> >                 exposure = 5000.5us;
> >                 if (!exposure) {
> > -                       cerr << "utils::Duration failed boolean test";
> > +                       cerr << "utils::Duration failed boolean test" << endl;
> >                         return TestFail;
> >                 }
> >  
> >                 os << exposure;
> >                 if (os.str() != "5000.50us") {
> > -                       cerr << "utils::Duration operator << failed";
> > +                       cerr << "utils::Duration operator << failed" << endl;
> >                         return TestFail;
> >                 }
> >  
> >                 exposure = 100ms;
> >                 ratio = exposure / 25ms;
> >                 if (ratio != 4.0) {
> > -                       cerr << "utils::Duration failed ratio test";
> > +                       cerr << "utils::Duration failed ratio test" << endl;
> >                         return TestFail;
> >                 }
> >  
> > @@ -219,7 +219,7 @@ protected:
> >                 std::string s = os.str();
> >                 if (s != ref) {
> >                         cerr << "utils::hex() test failed, expected '" << ref
> > -                            << "', got '" << s << "'";
> > +                            << "', got '" << s << "'" << endl;
> >                         return TestFail;
> >                 }
> >

Patch
diff mbox series

diff --git a/test/utils.cpp b/test/utils.cpp
index 195fddc97d97..ae5b01746722 100644
--- a/test/utils.cpp
+++ b/test/utils.cpp
@@ -85,7 +85,7 @@  protected:
 			if (index != i || value != i + 1) {
 				cerr << "utils::enumerate(<vector>) test failed: i=" << i
 				     << ", index=" << index << ", value=" << value
-				     << std::endl;
+				     << endl;
 				return TestFail;
 			}
 
@@ -106,7 +106,7 @@  protected:
 			if (index != i || value != i) {
 				cerr << "utils::enumerate(<span>) test failed: i=" << i
 				     << ", index=" << index << ", value=" << value
-				     << std::endl;
+				     << endl;
 				return TestFail;
 			}
 
@@ -120,7 +120,7 @@  protected:
 			if (index != i || value != i * 2) {
 				cerr << "utils::enumerate(<array>) test failed: i=" << i
 				     << ", index=" << index << ", value=" << value
-				     << std::endl;
+				     << endl;
 				return TestFail;
 			}
 
@@ -138,32 +138,32 @@  protected:
 
 		exposure = 25ms + 25ms;
 		if (exposure.get<std::micro>() != 50000.0) {
-			cerr << "utils::Duration failed to return microsecond count";
+			cerr << "utils::Duration failed to return microsecond count" << endl;
 			return TestFail;
 		}
 
 		exposure = 1.0s / 4;
 		if (exposure != 250ms) {
-			cerr << "utils::Duration failed scalar divide test";
+			cerr << "utils::Duration failed scalar divide test" << endl;
 			return TestFail;
 		}
 
 		exposure = 5000.5us;
 		if (!exposure) {
-			cerr << "utils::Duration failed boolean test";
+			cerr << "utils::Duration failed boolean test" << endl;
 			return TestFail;
 		}
 
 		os << exposure;
 		if (os.str() != "5000.50us") {
-			cerr << "utils::Duration operator << failed";
+			cerr << "utils::Duration operator << failed" << endl;
 			return TestFail;
 		}
 
 		exposure = 100ms;
 		ratio = exposure / 25ms;
 		if (ratio != 4.0) {
-			cerr << "utils::Duration failed ratio test";
+			cerr << "utils::Duration failed ratio test" << endl;
 			return TestFail;
 		}
 
@@ -219,7 +219,7 @@  protected:
 		std::string s = os.str();
 		if (s != ref) {
 			cerr << "utils::hex() test failed, expected '" << ref
-			     << "', got '" << s << "'";
+			     << "', got '" << s << "'" << endl;
 			return TestFail;
 		}