summaryrefslogtreecommitdiff
path: root/test_json.c
diff options
context:
space:
mode:
Diffstat (limited to 'test_json.c')
-rw-r--r--test_json.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/test_json.c b/test_json.c
index aff1aa08..84c86fa7 100644
--- a/test_json.c
+++ b/test_json.c
@@ -223,8 +223,14 @@ static const char *json_strTOFF = "{\"class\":\"TOFF\",\"device\":\"GPS#1\"," \
"\"real_sec\":1428001514, \"real_nsec\":1000000," \
"\"clock_sec\":1428001513,\"clock_nsec\":999999999}";
+/* Case 12: test parsing of OSC message */
+
+static const char *json_strOSC = "{\"class\":\"OSC\",\"device\":\"GPS#1\"," \
+ "\"running\":true,\"reference\":true,\"disciplined\":false," \
+ "\"delta\":67}";
+
#ifndef JSON_MINIMAL
-/* Case 12: Read array of integers */
+/* Case 13: Read array of integers */
static const char *json_strInt = "[23,-17,5]";
static int intstore[4], intcount;
@@ -236,7 +242,7 @@ static const struct json_array_t json_array_Int = {
.maxlen = sizeof(intstore)/sizeof(intstore[0]),
};
-/* Case 13: Read array of booleans */
+/* Case 14: Read array of booleans */
static const char *json_strBool = "[true,false,true]";
static bool boolstore[4];
@@ -249,13 +255,13 @@ static const struct json_array_t json_array_Bool = {
.maxlen = sizeof(boolstore)/sizeof(boolstore[0]),
};
-/* Case 14: Read array of reals */
+/* Case 15: Read array of reals */
-static const char *json_str14 = "[23.1,-17.2,5.3]";
+static const char *json_str15 = "[23.1,-17.2,5.3]";
static double realstore[4];
static int realcount;
-static const struct json_array_t json_array_14 = {
+static const struct json_array_t json_array_15 = {
.element_type = t_real,
.arr.reals.store = realstore,
.count = &realcount,
@@ -386,10 +392,20 @@ static void jsontest(int i)
assert_integer("clock_nsec", gpsdata.pps.clock.tv_nsec, 999999999);
break;
+ case 12:
+ status = json_oscillator_read(json_strOSC, &gpsdata, NULL);
+ assert_case(12,status);
+ assert_string("device", gpsdata.dev.path, "GPS#1");
+ assert_boolean("running", gpsdata.osc.running, true);
+ assert_boolean("reference", gpsdata.osc.reference, true);
+ assert_boolean("disciplined", gpsdata.osc.disciplined, false);
+ assert_integer("delta", gpsdata.osc.delta, 67);
+ break;
+
#ifdef JSON_MINIMAL
-#define MAXTEST 11
+#define MAXTEST 12
#else
- case 12:
+ case 13:
status = json_read_array(json_strInt, &json_array_Int, NULL);
assert_integer("count", intcount, 3);
assert_integer("intstore[0]", intstore[0], 23);
@@ -398,7 +414,7 @@ static void jsontest(int i)
assert_integer("intstore[3]", intstore[3], 0);
break;
- case 13:
+ case 14:
status = json_read_array(json_strBool, &json_array_Bool, NULL);
assert_integer("count", boolcount, 3);
assert_boolean("boolstore[0]", boolstore[0], true);
@@ -407,8 +423,8 @@ static void jsontest(int i)
assert_boolean("boolstore[3]", boolstore[3], false);
break;
- case 14:
- status = json_read_array(json_str14, &json_array_14, NULL);
+ case 15:
+ status = json_read_array(json_str15, &json_array_15, NULL);
assert_integer("count", realcount, 3);
assert_real("realstore[0]", realstore[0], 23.1);
assert_real("realstore[1]", realstore[1], -17.2);
@@ -416,7 +432,7 @@ static void jsontest(int i)
assert_real("realstore[3]", realstore[3], 0);
break;
-#define MAXTEST 14
+#define MAXTEST 15
#endif /* JSON_MINIMAL */
default: