From: Eric S. Raymond Date: Sun, 28 Sep 2014 01:29:04 +0000 (-0400) Subject: time_t regression test passes X-Git-Tag: 1.3~5 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=3e184f5dd49f6a311218d3e73bc2ada697ecf3b8;p=microjson.git time_t regression test passes --- diff --git a/test_microjson.c b/test_microjson.c index b81b797..e46e8a9 100644 --- a/test_microjson.c +++ b/test_microjson.c @@ -142,6 +142,12 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata, {"class", t_check, .dflt.check = "TPV"}, {"device", t_string, .addr.string = gpsdata->dev.path, .len = sizeof(gpsdata->dev.path)}, +#ifdef TIME_ENABLE + {"time", t_time, .addr.real = &gpsdata->fix.time, + .dflt.real = NAN}, +#else + {"time", t_ignore}, +#endif /* TIME_ENABLE */ {"ept", t_real, .addr.real = &gpsdata->fix.ept, .dflt.real = NAN}, {"lon", t_real, .addr.real = &gpsdata->fix.longitude, @@ -475,7 +481,8 @@ static void assert_real(char *attr, double fld, double check) /* *INDENT-OFF* */ static const char json_str1[] = "{\"class\":\"TPV\",\ \"device\":\"GPS#1\", \ - \"lon\":46.498203637,\"lat\":7.568074350,\ + \"time\":\"2005-06-19T12:12:42.03Z\", \ + \"lon\":46.498203637,\"lat\":7.568074350, \ \"alt\":1327.780,\"epx\":21.000,\"epy\":23.000,\"epv\":124.484,\"mode\":3}"; /* Case 2: SKY report */ @@ -653,6 +660,9 @@ static void jsontest(int i) status = libgps_json_unpack(json_str1, &gpsdata, NULL); assert_case(1, status); assert_string("device", gpsdata.dev.path, "GPS#1"); +#ifdef TIME_ENABLE + assert_real("time", gpsdata.fix.time, 1119183162.030000); +#endif /* TIME_ENABLE */ assert_integer("mode", gpsdata.fix.mode, 3); assert_real("lon", gpsdata.fix.longitude, 46.498203637); assert_real("lat", gpsdata.fix.latitude, 7.568074350);