reordered code so that it is C90-compilant, renamed variables so that they are different that function names, fixed formatting to match NTP's convention
hextolfp.c:
removed a trailing endline, changed formatting to match NTP's convention,
decodenetnum.c:
changed the order of imports, removed an unnecessary import, removed a trailing space, changed the return type from a function to be in a new line
run-humandate.c, run-hextolfp.c, run-decodenetnum.c:
autogenerated
bk: 5597e227acs3bFvp8m1Ag6w4DKuorA
#include "config.h"
#include "ntp_stdlib.h"
-#include "ntp_calendar.h"
-#include "unity.h"
-
#include "sockaddrtest.h"
+#include "unity.h"
+
-void test_IPv4AddressOnly(void) {
+void
+test_IPv4AddressOnly(void) {
const char *str = "192.0.2.1";
sockaddr_u actual;
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IPv4AddressWithPort(void) {
+void
+test_IPv4AddressWithPort(void) {
const char *str = "192.0.2.2:2000";
sockaddr_u actual;
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IPv6AddressOnly(void) {
+void
+test_IPv6AddressOnly(void) {
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
+ 0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
};
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IPv6AddressWithPort(void) {
+void
+test_IPv6AddressWithPort(void) {
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
+ 0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
};
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IllegalAddress(void) {
+void
+test_IllegalAddress(void) {
const char *str = "192.0.2.270:2000";
sockaddr_u actual;
TEST_ASSERT_FALSE(decodenetnum(str, &actual));
}
-void test_IllegalCharInPort(void) {
+void
+test_IllegalCharInPort(void) {
/* An illegal port does not make the decodenetnum fail, but instead
* makes it use the standard port.
*/
#include "lfptest.h"
-void test_PositiveInteger(void) {
+void
+test_PositiveInteger(void) {
const char *str = "00001000.00000000";
l_fp actual;
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_NegativeInteger(void) {
+void
+test_NegativeInteger(void) {
const char *str = "ffffffff.00000000"; // -1 decimal
l_fp actual;
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_PositiveFraction(void) {
+void
+test_PositiveFraction(void) {
const char *str = "00002000.80000000"; // 8196.5 decimal
l_fp actual;
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_NegativeFraction(void) {
+void
+test_NegativeFraction(void) {
const char *str = "ffffffff.40000000"; // -1 + 0.25 decimal
l_fp actual;
TEST_ASSERT_TRUE(IsEqual(expected, actual));
}
-void test_IllegalNumberOfInteger(void) {
+void
+test_IllegalNumberOfInteger(void) {
const char *str = "1000000.00000000"; // Missing one digit in integral part.
l_fp actual;
TEST_ASSERT_FALSE(hextolfp(str, &actual));
}
-void test_IllegalChar(void) {
+void
+test_IllegalChar(void) {
const char *str = "10000000.0000h000"; // Illegal character h.
l_fp actual;
TEST_ASSERT_FALSE(hextolfp(str, &actual));
}
-
#include "unity.h"
-void test_RegularTime(void)
+void
+test_RegularTime(void)
{
time_t sample = 1276601278;
char expected[15];
+ struct tm* tm;
- struct tm* time;
- time = localtime(&sample);
+ tm = localtime(&sample);
TEST_ASSERT_TRUE(time != NULL);
- snprintf(expected, 15, "%02d:%02d:%02d", time->tm_hour, time->tm_min, time->tm_sec);
+ snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
}
-void test_CurrentTime(void)
+void
+test_CurrentTime(void)
{
time_t sample;
char expected[15];
+ struct tm* tm;
time(&sample);
- struct tm* time;
- time = localtime(&sample);
+ tm = localtime(&sample);
TEST_ASSERT_TRUE(time != NULL);
- snprintf(expected, 15, "%02d:%02d:%02d", time->tm_hour, time->tm_min, time->tm_sec);
+ snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
}
Unity.TestFile = "decodenetnum.c";
UnityBegin("decodenetnum.c");
RUN_TEST(test_IPv4AddressOnly, 9);
- RUN_TEST(test_IPv4AddressWithPort, 22);
- RUN_TEST(test_IPv6AddressOnly, 35);
- RUN_TEST(test_IPv6AddressWithPort, 55);
- RUN_TEST(test_IllegalAddress, 75);
- RUN_TEST(test_IllegalCharInPort, 82);
+ RUN_TEST(test_IPv4AddressWithPort, 23);
+ RUN_TEST(test_IPv6AddressOnly, 37);
+ RUN_TEST(test_IPv6AddressWithPort, 58);
+ RUN_TEST(test_IllegalAddress, 79);
+ RUN_TEST(test_IllegalCharInPort, 87);
return (UnityEnd());
}
progname = argv[0];
Unity.TestFile = "hextolfp.c";
UnityBegin("hextolfp.c");
- RUN_TEST(test_PositiveInteger, 10);
- RUN_TEST(test_NegativeInteger, 20);
- RUN_TEST(test_PositiveFraction, 30);
- RUN_TEST(test_NegativeFraction, 40);
- RUN_TEST(test_IllegalNumberOfInteger, 50);
- RUN_TEST(test_IllegalChar, 57);
+ RUN_TEST(test_PositiveInteger, 11);
+ RUN_TEST(test_NegativeInteger, 22);
+ RUN_TEST(test_PositiveFraction, 33);
+ RUN_TEST(test_NegativeFraction, 44);
+ RUN_TEST(test_IllegalNumberOfInteger, 55);
+ RUN_TEST(test_IllegalChar, 63);
return (UnityEnd());
}
//=======External Functions This Runner Calls=====
extern void setUp(void);
extern void tearDown(void);
+void resetTest(void);
extern void test_RegularTime(void);
extern void test_CurrentTime(void);
progname = argv[0];
Unity.TestFile = "humandate.c";
UnityBegin("humandate.c");
- RUN_TEST(test_RegularTime, 8);
- RUN_TEST(test_CurrentTime, 22);
+ RUN_TEST(test_RegularTime, 9);
+ RUN_TEST(test_CurrentTime, 24);
return (UnityEnd());
}