firmware  v0.1.2
Chromation Spectrometer Dev-Kit
ExampleCalls.c
1 // Calls for testing mock-c corner cases.
2 #include "ExampleCalls.h"
3 #include <Mock.h>
4 #include <RecordedCall.h>
5 
6 static RecordedCall * Mock_TakesNoArg(void)
7 {
8  char const *call_name = "TakesNoArg";
9  RecordedCall *record_of_call = RecordedCall_new(call_name);
10  return record_of_call;
11 }
12 void Expect_TakesNoArg(void) {
13  RecordExpectedCall(mock, Mock_TakesNoArg());
14 }
15 void TakesNoArg_Stubbed(void) {
16  RecordActualCall(mock, Mock_TakesNoArg());
17 }
18 void SpanishInquisition_Stubbed(void) {
19  RecordedCall *record_of_call = RecordedCall_new("SpanishInquisition");
20  RecordActualCall(mock, record_of_call);
21 }
22 
23 static RecordedCall * Mock_TakesOneArg(uint8_t b1)
24 {
25  char const *call_name = "TakesOneArg";
26  RecordedCall *record_of_call = RecordedCall_new(call_name);
27  RecordedArg *record_of_arg1 = RecordedArg_new(SetupRecord_uint8_t);
28  *((uint8_t *)record_of_arg1->pArg) = b1;
29  RecordArg(record_of_call, record_of_arg1);
30  return record_of_call;
31 }
32 void Expect_TakesOneArg(uint8_t b1) {
33  RecordExpectedCall(mock, Mock_TakesOneArg(b1));
34 }
35 void TakesOneArg_Stubbed(uint8_t b1) {
36  RecordActualCall(mock, Mock_TakesOneArg(b1));
37 }
38 void TakesTwoArgs_StubbedWithCallName_TakesOneArg(uint8_t b1, uint8_t b2) {
39  RecordedCall *record_of_call = RecordedCall_new("TakesOneArg");
40  RecordedArg *record_of_arg1 = RecordedArg_new(SetupRecord_uint8_t);
41  *((uint8_t *)record_of_arg1->pArg) = b1;
42  RecordedArg *record_of_arg2 = RecordedArg_new(SetupRecord_uint8_t);
43  *((uint8_t *)record_of_arg2->pArg) = b2;
44  RecordArg(record_of_call, record_of_arg1);
45  RecordArg(record_of_call, record_of_arg2);
46  RecordActualCall(mock, record_of_call);
47 }
48 
49 static RecordedCall * Mock_TakesTwoArgs(uint8_t b1, uint8_t b2)
50 {
51  char const *call_name = "TakesTwoArgs";
52  RecordedCall *record_of_call = RecordedCall_new(call_name);
53  RecordedArg *record_of_arg1 = RecordedArg_new(SetupRecord_uint8_t);
54  *((uint8_t *)record_of_arg1->pArg) = b1;
55  RecordedArg *record_of_arg2 = RecordedArg_new(SetupRecord_uint8_t);
56  *((uint8_t *)record_of_arg2->pArg) = b2;
57  RecordArg(record_of_call, record_of_arg1);
58  RecordArg(record_of_call, record_of_arg2);
59  return record_of_call;
60 }
61 void Expect_TakesTwoArgs(uint8_t b1, uint8_t b2) {
62  RecordExpectedCall(mock, Mock_TakesTwoArgs(b1, b2));
63 }
64 void TakesTwoArgs_Stubbed(uint8_t b1, uint8_t b2) {
65  RecordActualCall(mock, Mock_TakesTwoArgs(b1, b2));
66 }
67 void TakesOneArg_StubbedWithCallName_TakesTwoArgs(uint8_t b1) {
68  RecordedCall *record_of_call = RecordedCall_new("TakesTwoArgs");
69  RecordedArg *record_of_arg1 = RecordedArg_new(SetupRecord_uint8_t);
70  *((uint8_t *)record_of_arg1->pArg) = b1;
71  RecordArg(record_of_call, record_of_arg1);
72  RecordActualCall(mock, record_of_call);
73 }