diff mbox series

[v2,2/3] tests/unit: Expand test_fifo8_peek_buf_wrap() coverage

Message ID 20240906132909.78886-3-philmd@linaro.org
State Superseded
Headers show
Series tests/unit: Slightly expand FIFO8 tests | expand

Commit Message

Philippe Mathieu-Daudé Sept. 6, 2024, 1:29 p.m. UTC
Test fifo8_peek_buf() can fill a buffer with wrapped data.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tests/unit/test-fifo.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Mark Cave-Ayland Sept. 6, 2024, 9:02 p.m. UTC | #1
On 06/09/2024 14:29, Philippe Mathieu-Daudé wrote:

> Test fifo8_peek_buf() can fill a buffer with wrapped data.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tests/unit/test-fifo.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c
> index 9b3a4940d0..fada526b6c 100644
> --- a/tests/unit/test-fifo.c
> +++ b/tests/unit/test-fifo.c
> @@ -158,7 +158,7 @@ static void test_fifo8_peek_buf_wrap(void)
>       Fifo8 fifo;
>       uint8_t data_in1[] = { 0x1, 0x2, 0x3, 0x4 };
>       uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc };
> -    uint8_t data_out[4];
> +    uint8_t data_out[8];
>       int count;
>   
>       fifo8_create(&fifo, 8);
> @@ -174,6 +174,13 @@ static void test_fifo8_peek_buf_wrap(void)
>       g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 &&
>                data_out[2] == 0x7 && data_out[3] == 0x8);
>   
> +    count = fifo8_peek_buf(&fifo, data_out, 8);
> +    g_assert(count == 8);
> +    g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 &&
> +             data_out[2] == 0x7 && data_out[3] == 0x8);
> +    g_assert(data_out[4] == 0x9 && data_out[5] == 0xa &&
> +             data_out[6] == 0xb && data_out[7] == 0xc);
> +
>       g_assert(fifo8_num_used(&fifo) == 8);
>       fifo8_destroy(&fifo);
>   }

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
diff mbox series

Patch

diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c
index 9b3a4940d0..fada526b6c 100644
--- a/tests/unit/test-fifo.c
+++ b/tests/unit/test-fifo.c
@@ -158,7 +158,7 @@  static void test_fifo8_peek_buf_wrap(void)
     Fifo8 fifo;
     uint8_t data_in1[] = { 0x1, 0x2, 0x3, 0x4 };
     uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc };
-    uint8_t data_out[4];
+    uint8_t data_out[8];
     int count;
 
     fifo8_create(&fifo, 8);
@@ -174,6 +174,13 @@  static void test_fifo8_peek_buf_wrap(void)
     g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 &&
              data_out[2] == 0x7 && data_out[3] == 0x8);
 
+    count = fifo8_peek_buf(&fifo, data_out, 8);
+    g_assert(count == 8);
+    g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 &&
+             data_out[2] == 0x7 && data_out[3] == 0x8);
+    g_assert(data_out[4] == 0x9 && data_out[5] == 0xa &&
+             data_out[6] == 0xb && data_out[7] == 0xc);
+
     g_assert(fifo8_num_used(&fifo) == 8);
     fifo8_destroy(&fifo);
 }