Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SET_RETURN_SEQ should reset return_val_seq_idx #101

Open
jackdigitalinsight opened this issue Sep 15, 2021 · 1 comment
Open

SET_RETURN_SEQ should reset return_val_seq_idx #101

jackdigitalinsight opened this issue Sep 15, 2021 · 1 comment

Comments

@jackdigitalinsight
Copy link

Describe the bug
Within one test case, I want to modify a fake's return value sequence. SET_RETURN_SEQ updates the sequence and length, but doesn't reset the next index.

To Reproduce
example:

void test_protocol()
{
	int rx1[] = { 1, 2, -1 };
	SET_RETURN_SEQ(hal_uart_rx, rx1, 3);
        protocol_update();
        // assert results

        int rx2[] = { 3, 4, 5, 6, -1 };
	SET_RETURN_SEQ(hal_uart_rx, rx2, 5);
        protocol_update();
        // assert results
}

Expected behavior
second protocol_update() calls to hal_uart_rx(fake) should see 3, 4, 5, 6, -1. Instead it gets 6, -1.

Compiler, toolset, platform (please complete the following information):

  • OS: Windows 10g
  • Compiler: g++ 5.3.0 (MingW32)

Suggested change*

 #define SET_RETURN_SEQ(FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \
     FUNCNAME##_fake.return_val_seq = ARRAY_POINTER; \
-    FUNCNAME##_fake.return_val_seq_len = ARRAY_LEN;
+    FUNCNAME##_fake.return_val_seq_len = ARRAY_LEN; \
+    FUNCNAME##_fake.return_val_seq_idx = 0;
+
@CiderMan
Copy link

CiderMan commented Jan 3, 2023

@meekrosoft I think that this makes sense (and the equivalent for custom fake sequences); would you be happy to consider a PR for this change?

jackdigitalinsight pushed a commit to jackdigitalinsight/fff that referenced this issue Jan 3, 2023
reset return sequence index when setting a return sequence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants