1

I have been trying to learn cmocka to perform unitest. After looking at various examples on internet, I am confused as to how I should do unit testing, specifically I am unable to understand following syntax:

static int functionname(void **state) {
 // What should I write here??
 return 0;
}

I am unable to understand Why void ** state is being used and what does it signifies. I am doing unittesting on circular buffer to check whether it is full, how should I do it? Till now I have written the uni test for c mocka as follows:

static int CBfull(void **state) {
    if(bufffull=1)
    failcount++;
    else passcount++;
}
skink
  • 5,133
  • 6
  • 37
  • 58
  • `void ** state` is a pointer to a pointer. Probably the function is called with the address of a pointer so the function can modify the caller's variable. What it "signifies" depends on the design of the module using it. Note that `bufffull=1)` is an _assignment_, not a test. Use `==` for testing if the value is equal to 1. – Paul Ogilvie Oct 26 '17 at 16:53

0 Answers0