1+ /*
2+ * To run this test suite, you must first install the ArduinoUnit library
3+ * to your Arduino/libraries/ directory.
4+ * You can get ArduinoUnit here: https://github.com/mmurdoch/arduinounit
5+ * Download version 2.0 or greater.
6+ */
7+
18#include < ArduinoUnit.h>
29#include < Firmata.h>
310
4- TestSuite suite;
5-
611void setup ()
712{
813 Serial.begin (9600 );
914}
1015
1116void loop ()
1217{
13- suite.run ();
14- }
15-
16- void assertStringsEqual (Test& __test__, const char * expected, const String& actual)
17- {
18- size_t expectedLength = strlen (expected);
19- assertEquals (expectedLength, actual.length ());
20- for (size_t i = 0 ; i < expectedLength; i++)
21- {
22- assertEquals (expected[i], actual[i]);
23- }
18+ Test::run ();
2419}
2520
21+ // Note: this test required adding a method (Firmata.unsetFirmwareVersion()) to
22+ // Firmata.cpp solely for the purpose of running this test. The method has been
23+ // removed from Firmata.cpp, but keeping the test here as a recored
2624// test(setFirmwareVersionDoesNotLeakMemory)
2725// {
2826// Firmata.setFirmwareVersion(1, 0);
@@ -48,7 +46,7 @@ test(beginPrintsVersion)
4846 FIRMATA_MINOR_VERSION,
4947 0
5048 };
51- assertStringsEqual (__test__, expected, stream.bytesWritten ());
49+ assertEqual ( expected, stream.bytesWritten ());
5250}
5351
5452void processMessage (const byte* message, size_t length)
@@ -84,7 +82,7 @@ test(processWriteDigital_0)
8482 byte message[] = { DIGITAL_MESSAGE, 0 , 0 };
8583 processMessage (message, 3 );
8684
87- assertEquals (0 , _digitalPortValue);
85+ assertEqual (0 , _digitalPortValue);
8886}
8987
9088test (processWriteDigital_127)
@@ -95,7 +93,7 @@ test(processWriteDigital_127)
9593 byte message[] = { DIGITAL_MESSAGE, 127 , 0 };
9694 processMessage (message, 3 );
9795
98- assertEquals (127 , _digitalPortValue);
96+ assertEqual (127 , _digitalPortValue);
9997}
10098
10199test (processWriteDigital_128)
@@ -106,7 +104,7 @@ test(processWriteDigital_128)
106104 byte message[] = { DIGITAL_MESSAGE, 0 , 1 };
107105 processMessage (message, 3 );
108106
109- assertEquals (128 , _digitalPortValue);
107+ assertEqual (128 , _digitalPortValue);
110108}
111109
112110test (processWriteLargestDigitalValue)
@@ -118,7 +116,7 @@ test(processWriteLargestDigitalValue)
118116 processMessage (message, 3 );
119117
120118 // Maximum of 14 bits can be set (B0011111111111111)
121- assertEquals (0x3FFF , _digitalPortValue);
119+ assertEqual (0x3FFF , _digitalPortValue);
122120}
123121
124122test (defaultDigitalWritePortIsZero)
@@ -129,7 +127,7 @@ test(defaultDigitalWritePortIsZero)
129127 byte message[] = { DIGITAL_MESSAGE, 0 , 0 };
130128 processMessage (message, 3 );
131129
132- assertEquals (0 , _digitalPort);
130+ assertEqual (0 , _digitalPort);
133131}
134132
135133test (specifiedDigitalWritePort)
@@ -140,6 +138,5 @@ test(specifiedDigitalWritePort)
140138 byte message[] = { DIGITAL_MESSAGE + 1 , 0 , 0 };
141139 processMessage (message, 3 );
142140
143- assertEquals (1 , _digitalPort);
141+ assertEqual (1 , _digitalPort);
144142}
145-
0 commit comments