On 02/21/2017 11:49 AM, Dr. David Alan Gilbert wrote:
>> +static void test_arr_ptr_str_0_save(void)
>> +{
>> +    TestStructTriv ar[AR_SIZE] = {{.i = 0}, {.i = 1}, {.i = 2}, {.i = 3} };
>> +    TestArrayOfPtrToStuct sample = {.ar = {&ar[0], NULL, &ar[2], &ar[3]} };
>> +    uint8_t wire_sample[] = {
>> +        0x00, 0x00, 0x00, 0x00,
>> +        VMS_NULLPTR_MARKER,
>> +        0x00, 0x00, 0x00, 0x02,
>> +        0x00, 0x00, 0x00, 0x03,
>> +        QEMU_VM_EOF
>> +    };
>> +
>> +    save_vmstate(&vmsd_arps, &sample);
>> +    compare_vmstate(wire_sample, sizeof(wire_sample));
>> +}
>> +
>> +static void test_arr_ptr_str_0_load(void)
>> +{
>> +    TestStructTriv ar_gt[AR_SIZE] = {{.i = 0}, {.i = 0}, {.i = 2}, {.i = 3} 
>> };
>> +    TestStructTriv ar[AR_SIZE] = {};
>> +    TestArrayOfPtrToStuct obj = {.ar = {&ar[0], NULL, &ar[2], &ar[3]} };
>> +    int idx;
>> +    uint8_t wire_sample[] = {
>> +        0x00, 0x00, 0x00, 0x00,
>> +        VMS_NULLPTR_MARKER,
>> +        0x00, 0x00, 0x00, 0x02,
>> +        0x00, 0x00, 0x00, 0x03,
>> +        QEMU_VM_EOF
>> +    };
> If possible; it would be better if you could share the wire_sample, and ar_gt 
> between
> the two functions rather than copying them.
> 
> Dave
> 

Certainly possible. I did it this way because I prefer
unit tests as self contained as possible, but consistent
style is also important.

Will factor wire_sample out for the next version.

Cheers,
Halil


Reply via email to