Exemplo n.º 1
0
END_TEST

START_TEST (test_nmea_gprmc_parse)
{
    gprmc_t *loc = (gprmc_t *)malloc(sizeof(gprmc_t));
    nmea_parse_gprmc("$GPRMC,081836,A,3751.65,S,14507.36,E,000.05,360.0,130998,011.3,E*62", loc);

    char buf[48];

    snprintf(buf, sizeof(buf), "The readed latitude is: %f", loc->latitude);
    ck_assert_double_eq(3751.65, loc->latitude, buf);

    snprintf(buf, sizeof(buf), "The readed lat is: %c", loc->lat);
    ck_assert_msg(loc->lat == 'S', buf);

    snprintf(buf, sizeof(buf), "The readed longitude is: %f", loc->longitude);
    ck_assert_double_eq(14507.36, loc->longitude, buf);

    snprintf(buf, sizeof(buf), "The readed lon is: %c", loc->lon);
    ck_assert_msg(loc->lon == 'E', buf);

    snprintf(buf, sizeof(buf), "The readed speed is: %lf", loc->speed);
    ck_assert_double_eq(0.05, loc->speed, buf);

    snprintf(buf, sizeof(buf), "The readed course/angle is: %lf", loc->course);
    ck_assert_msg(loc->course == 360, buf);
}
Exemplo n.º 2
0
END_TEST

START_TEST (test_invalid_nmea_gpgga_parse)
{
    gpgga_t *loc = (gpgga_t *)malloc(sizeof(gpgga_t));
    nmea_parse_gpgga("$GPGGA,080919.091,,,,,0,0,,,M,,M,,*49", loc);

    char buf[48];

    snprintf(buf, sizeof(buf), "The readed latitude is: %f", loc->latitude);
    ck_assert_double_eq(0, loc->latitude, buf);

    snprintf(buf, sizeof(buf), "The readed lat is: %c", loc->lat);
    ck_assert_msg(loc->lat == '\0', buf);

    snprintf(buf, sizeof(buf), "The readed longitude is: %f", loc->longitude);
    ck_assert_double_eq(0, loc->longitude, buf);

    snprintf(buf, sizeof(buf), "The readed lon is: %c", loc->lon);
    ck_assert_msg(loc->lon == '\0', buf);

    snprintf(buf, sizeof(buf), "The readed quality is: %d", loc->quality);
    ck_assert_msg(loc->quality == 0, buf);

    snprintf(buf, sizeof(buf), "The readed satellites is: %d", loc->satellites);
    ck_assert_msg(loc->satellites == 0, buf);

    snprintf(buf, sizeof(buf), "The readed altitude is: %lf", loc->altitude);
    ck_assert_double_eq(0, loc->altitude, buf);
}
Exemplo n.º 3
0
END_TEST

START_TEST(ck_double_eq_and_ne)
{
	ck_assert_double_eq(0.4,0.4);
	ck_assert_double_eq(0.4,0.4 + 1E-6);
	ck_assert_double_ne(0.4,0.4 + 1E-3);
}
Exemplo n.º 4
0
END_TEST

START_TEST(ck_double_eq_fails)
{
	ck_assert_double_eq(0.41,0.4);
}