[v2,2/2] test: utils: Extend utils::hex() test to 8-bit and 16-bit values
diff mbox series

Message ID 20240704100728.7003-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit 131039f6330f4c1a4a36f0b4d381f0033b9ecf46
Headers show
Series
  • [v2,1/2] libcamera: base: utils: Implement hex() for 8-bit and 16-bit values
Related show

Commit Message

Laurent Pinchart July 4, 2024, 10:07 a.m. UTC
Now that the utils::hex() function supports 8-bit and 16-bit integers,
extend the unit test to cover them.

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

Comments

Umang Jain July 4, 2024, 10:49 a.m. UTC | #1
Hi Laurent,

Thank you for the patch

On 04/07/24 3:37 pm, Laurent Pinchart wrote:
> Now that the utils::hex() function supports 8-bit and 16-bit integers,
> extend the unit test to cover them.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

LGTM,

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>   test/utils.cpp | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/test/utils.cpp b/test/utils.cpp
> index 41af954b326f..d25475cb93b9 100644
> --- a/test/utils.cpp
> +++ b/test/utils.cpp
> @@ -176,6 +176,14 @@ protected:
>   		std::ostringstream os;
>   		std::string ref;
>   
> +		os << utils::hex(static_cast<int8_t>(0x42)) << " ";
> +		ref += "0x42 ";
> +		os << utils::hex(static_cast<uint8_t>(0x42)) << " ";
> +		ref += "0x42 ";
> +		os << utils::hex(static_cast<int16_t>(0x42)) << " ";
> +		ref += "0x0042 ";
> +		os << utils::hex(static_cast<uint16_t>(0x42)) << " ";
> +		ref += "0x0042 ";
>   		os << utils::hex(static_cast<int32_t>(0x42)) << " ";
>   		ref += "0x00000042 ";
>   		os << utils::hex(static_cast<uint32_t>(0x42)) << " ";
> @@ -184,6 +192,15 @@ protected:
>   		ref += "0x0000000000000042 ";
>   		os << utils::hex(static_cast<uint64_t>(0x42)) << " ";
>   		ref += "0x0000000000000042 ";
> +
> +		os << utils::hex(static_cast<int8_t>(0x42), 6) << " ";
> +		ref += "0x000042 ";
> +		os << utils::hex(static_cast<uint8_t>(0x42), 1) << " ";
> +		ref += "0x42 ";
> +		os << utils::hex(static_cast<int16_t>(0x42), 6) << " ";
> +		ref += "0x000042 ";
> +		os << utils::hex(static_cast<uint16_t>(0x42), 1) << " ";
> +		ref += "0x42 ";
>   		os << utils::hex(static_cast<int32_t>(0x42), 4) << " ";
>   		ref += "0x0042 ";
>   		os << utils::hex(static_cast<uint32_t>(0x42), 1) << " ";
Stefan Klug July 4, 2024, 10:58 a.m. UTC | #2
Hi Laurent,

Thank you for the patch.

On Thu, Jul 04, 2024 at 01:07:28PM +0300, Laurent Pinchart wrote:
> Now that the utils::hex() function supports 8-bit and 16-bit integers,
> extend the unit test to cover them.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> 

Regards,
Stefan

> ---
>  test/utils.cpp | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/test/utils.cpp b/test/utils.cpp
> index 41af954b326f..d25475cb93b9 100644
> --- a/test/utils.cpp
> +++ b/test/utils.cpp
> @@ -176,6 +176,14 @@ protected:
>  		std::ostringstream os;
>  		std::string ref;
>  
> +		os << utils::hex(static_cast<int8_t>(0x42)) << " ";
> +		ref += "0x42 ";
> +		os << utils::hex(static_cast<uint8_t>(0x42)) << " ";
> +		ref += "0x42 ";
> +		os << utils::hex(static_cast<int16_t>(0x42)) << " ";
> +		ref += "0x0042 ";
> +		os << utils::hex(static_cast<uint16_t>(0x42)) << " ";
> +		ref += "0x0042 ";
>  		os << utils::hex(static_cast<int32_t>(0x42)) << " ";
>  		ref += "0x00000042 ";
>  		os << utils::hex(static_cast<uint32_t>(0x42)) << " ";
> @@ -184,6 +192,15 @@ protected:
>  		ref += "0x0000000000000042 ";
>  		os << utils::hex(static_cast<uint64_t>(0x42)) << " ";
>  		ref += "0x0000000000000042 ";
> +
> +		os << utils::hex(static_cast<int8_t>(0x42), 6) << " ";
> +		ref += "0x000042 ";
> +		os << utils::hex(static_cast<uint8_t>(0x42), 1) << " ";
> +		ref += "0x42 ";
> +		os << utils::hex(static_cast<int16_t>(0x42), 6) << " ";
> +		ref += "0x000042 ";
> +		os << utils::hex(static_cast<uint16_t>(0x42), 1) << " ";
> +		ref += "0x42 ";
>  		os << utils::hex(static_cast<int32_t>(0x42), 4) << " ";
>  		ref += "0x0042 ";
>  		os << utils::hex(static_cast<uint32_t>(0x42), 1) << " ";
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/test/utils.cpp b/test/utils.cpp
index 41af954b326f..d25475cb93b9 100644
--- a/test/utils.cpp
+++ b/test/utils.cpp
@@ -176,6 +176,14 @@  protected:
 		std::ostringstream os;
 		std::string ref;
 
+		os << utils::hex(static_cast<int8_t>(0x42)) << " ";
+		ref += "0x42 ";
+		os << utils::hex(static_cast<uint8_t>(0x42)) << " ";
+		ref += "0x42 ";
+		os << utils::hex(static_cast<int16_t>(0x42)) << " ";
+		ref += "0x0042 ";
+		os << utils::hex(static_cast<uint16_t>(0x42)) << " ";
+		ref += "0x0042 ";
 		os << utils::hex(static_cast<int32_t>(0x42)) << " ";
 		ref += "0x00000042 ";
 		os << utils::hex(static_cast<uint32_t>(0x42)) << " ";
@@ -184,6 +192,15 @@  protected:
 		ref += "0x0000000000000042 ";
 		os << utils::hex(static_cast<uint64_t>(0x42)) << " ";
 		ref += "0x0000000000000042 ";
+
+		os << utils::hex(static_cast<int8_t>(0x42), 6) << " ";
+		ref += "0x000042 ";
+		os << utils::hex(static_cast<uint8_t>(0x42), 1) << " ";
+		ref += "0x42 ";
+		os << utils::hex(static_cast<int16_t>(0x42), 6) << " ";
+		ref += "0x000042 ";
+		os << utils::hex(static_cast<uint16_t>(0x42), 1) << " ";
+		ref += "0x42 ";
 		os << utils::hex(static_cast<int32_t>(0x42), 4) << " ";
 		ref += "0x0042 ";
 		os << utils::hex(static_cast<uint32_t>(0x42), 1) << " ";