Skip to content
This repository was archived by the owner on Sep 13, 2020. It is now read-only.

Commit ae93e19

Browse files
author
Damian Kowalewski
committed
using json parser from common code
1 parent 0f7dceb commit ae93e19

File tree

6 files changed

+16
-198
lines changed

6 files changed

+16
-198
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ RemoteSystemsTempFiles/
5555
**/unix/src/*.lo
5656
**/unix/samples/simple_parse_loop/simple_parse_loop
5757
**/unix/samples/simple_custom_loop/simple_custom_loop
58+
**/unix/samples/test/parse_test
5859
**/unix/yun/Makefile
5960
**/unix/yun/Makefile.in
6061
**/unix/yun/parse_push

unix/samples/test/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CC = gcc
2-
SRCS = main.c json.c
2+
SRCS = main.c simplejson.c
33
OBJS = $(SRCS:.c=.o)
4-
INCLUDES =
4+
INCLUDES = -I../../../common/
55
LIBDIRS =
66
LIBS = -lparse
77
TARGET = parse_test
@@ -11,8 +11,11 @@ all: $(TARGET)
1111
$(TARGET): $(OBJS)
1212
$(CC) $(LIBDIRS) $(OBJS) -o $(TARGET) $(LIBS)
1313

14-
.c.o:
15-
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
14+
main.o: main.c
15+
$(CC) $(CFLAGS) $(INCLUDES) -c $^ -o $@
16+
17+
simplejson.o: ../../../common/simplejson.c
18+
$(CC) $(CFLAGS) $(INCLUDES) -c $^ -o $@
1619

1720
clean:
1821
rm -fR $(TARGET) $(OBJS)

unix/samples/test/json.c

Lines changed: 0 additions & 159 deletions
This file was deleted.

unix/samples/test/json.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

unix/samples/test/main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <parse.h>
2727
#include <time.h>
2828

29-
#include "json.h"
29+
#include "simplejson.h"
3030

3131
int totalTests = 0;
3232
int successfullTests = 0;
@@ -95,8 +95,8 @@ static void pushCallback(ParseClient client, int error, const char *buffer) {
9595
char id[16] = {0};
9696
char orig[16] = {0};
9797
snprintf(orig, sizeof(orig), "%ld", run);
98-
if (simpleJson(buffer, "data", data, sizeof(data))) {
99-
if (simpleJson(data, "id", id, sizeof(id))) {
98+
if (simpleJsonProcessor(buffer, "data", data, sizeof(data))) {
99+
if (simpleJsonProcessor(data, "id", id, sizeof(id))) {
100100
if (strncmp(id, orig, sizeof(id)) == 0) {
101101
pushCounter++;
102102
}
@@ -120,7 +120,6 @@ int main(int argc, char *argv[]) {
120120

121121

122122
// TEST INITIALIZATION
123-
124123
ParseClient client = parseInitialize(YOUR_APP_IP, YOUR_CLIENT_KEY);
125124
logResults(client != NULL, 1, "parseInitialize call", "failed to start parse");
126125

@@ -144,7 +143,7 @@ int main(int argc, char *argv[]) {
144143
parseSendRequest(client, "POST", classPathOne, "{\"test\":\"object1\", \"value\":1}", callback);
145144
logResults(cachedRunResult != NULL, 0, "create test object 1", "creating object failed");
146145
memset(objectId, 0, sizeof(objectId));
147-
logResults(simpleJson(cachedRunResult, "objectId", objectId, sizeof(objectId)), 0, "object 1 created", "could not create an object");
146+
logResults(simpleJsonProcessor(cachedRunResult, "objectId", objectId, sizeof(objectId)), 0, "object 1 created", "could not create an object");
148147

149148
clearCachedResults();
150149

@@ -158,7 +157,7 @@ int main(int argc, char *argv[]) {
158157
parseSendRequest(client, "POST", classPathOne, "{\"test\":\"object1\", \"value\":2}", callback);
159158
logResults(cachedRunResult != NULL, 0, "create test object 2", "creating object failed");
160159
memset(objectId, 0, sizeof(objectId));
161-
logResults(simpleJson(cachedRunResult, "objectId", objectId, sizeof(objectId)), 0, "object 2 created", "could not create an object");
160+
logResults(simpleJsonProcessor(cachedRunResult, "objectId", objectId, sizeof(objectId)), 0, "object 2 created", "could not create an object");
162161

163162
clearCachedResults();
164163

@@ -172,7 +171,7 @@ int main(int argc, char *argv[]) {
172171
parseSendRequest(client, "POST", classPathOne, "{\"test\":\"object1\", \"value\":3}", callback);
173172
logResults(cachedRunResult != NULL, 0, "create test object 3", "creating object failed");
174173
char objectIdKeepAround[11] = {0};
175-
logResults(simpleJson(cachedRunResult, "objectId", objectIdKeepAround, sizeof(objectIdKeepAround)), 0, "object 3 created", "could not create an object");
174+
logResults(simpleJsonProcessor(cachedRunResult, "objectId", objectIdKeepAround, sizeof(objectIdKeepAround)), 0, "object 3 created", "could not create an object");
176175

177176
clearCachedResults();
178177

@@ -186,7 +185,7 @@ int main(int argc, char *argv[]) {
186185
parseSendRequest(client, "POST", classPathOne, "{\"test\":\"object1\", \"value\":2}", callback);
187186
logResults(cachedRunResult != NULL, 0, "create test object 4", "creating object failed");
188187
memset(objectId, 0, sizeof(objectId));
189-
logResults(simpleJson(cachedRunResult, "objectId", objectId, sizeof(objectId)), 0, "object 4 created", "could not create an object");
188+
logResults(simpleJsonProcessor(cachedRunResult, "objectId", objectId, sizeof(objectId)), 0, "object 4 created", "could not create an object");
190189

191190
clearCachedResults();
192191

unix/samples/test/push.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22

3+
34
COUNTER=0
45
while [ $COUNTER -lt 10 ]; do
56
curl -X POST \

0 commit comments

Comments
 (0)