You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/03/18 20:44:49 UTC

[1/5] incubator-mynewt-core git commit: minor revision to be more consistent with test macros

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 44e560f98 -> 18477e345


minor revision to be more consistent with test macros


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/04dbf5c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/04dbf5c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/04dbf5c5

Branch: refs/heads/develop
Commit: 04dbf5c50faf71bb91b25f96fbd7d0b9f46718d6
Parents: 655b79e
Author: Paul Dietrich <pa...@yahoo.com>
Authored: Fri Mar 11 12:27:48 2016 -0800
Committer: Paul Dietrich <pa...@yahoo.com>
Committed: Fri Mar 11 13:07:20 2016 -0800

----------------------------------------------------------------------
 libs/json/src/test/test_json.h            | 4 ++--
 libs/json/src/test/test_json_simple.c     | 6 +++---
 libs/testutil/include/testutil/testutil.h | 4 ++++
 3 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/04dbf5c5/libs/json/src/test/test_json.h
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json.h b/libs/json/src/test/test_json.h
index 8466213..ea5efcf 100644
--- a/libs/json/src/test/test_json.h
+++ b/libs/json/src/test/test_json.h
@@ -20,8 +20,8 @@
 #ifndef TEST_JSON_H
 #define TEST_JSON_H
 
-void test_json_simple_encode(void);
-void test_json_simple_decode(void);
+TEST_CASE_DECL(test_json_simple_encode);
+TEST_CASE_DECL(test_json_simple_decode);
 
 #endif /* TEST_JSON_H */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/04dbf5c5/libs/json/src/test/test_json_simple.c
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json_simple.c b/libs/json/src/test/test_json_simple.c
index e7046bd..ab2d005 100644
--- a/libs/json/src/test/test_json_simple.c
+++ b/libs/json/src/test/test_json_simple.c
@@ -17,10 +17,10 @@
  * under the License.
  */
 
-#include "test_json.h"
 #include <assert.h>
 #include <string.h>
 #include "testutil/testutil.h"
+#include "test_json.h"
 #include "json/json.h"
 
 static char *output = "{\"KeyBool\": true,\"KeyInt\": -1234,\"KeyUint\": 1353214,\"KeyString\": \"foobar\",\"KeyStringN\": \"foobarlong\"}";
@@ -35,7 +35,7 @@ static int test_write(void *buf, char* data, int len) {
     return len;
 }
 
-void test_json_simple_encode(void) {
+TEST_CASE(test_json_simple_encode){
     struct json_encoder encoder;
     struct json_value value;
     int rc;
@@ -145,7 +145,7 @@ test_buf_init(struct test_jbuf *ptjb, char *string) {
 }
 
 /* now test the decode on a string */
-void test_json_simple_decode(void) {
+TEST_CASE(test_json_simple_decode){
     struct test_jbuf tjb; 
     unsigned int uint_val;
     int int_val;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/04dbf5c5/libs/testutil/include/testutil/testutil.h
----------------------------------------------------------------------
diff --git a/libs/testutil/include/testutil/testutil.h b/libs/testutil/include/testutil/testutil.h
index 2868cdd..2c8000a 100644
--- a/libs/testutil/include/testutil/testutil.h
+++ b/libs/testutil/include/testutil/testutil.h
@@ -98,6 +98,10 @@ extern jmp_buf tu_case_jb;
     static void                                                               \
     TEST_SUITE_##suite_name(void)
 
+/* for creating multiple files with test cases all belonging to the same
+ * suite */
+#define TEST_CASE_DECL(case_name)  int case_name(void);
+
 #define TEST_CASE(case_name)                                                  \
     static void TEST_CASE_##case_name(void);                                  \
                                                                               \


[2/5] incubator-mynewt-core git commit: better implementation of the flat buffer json decoder since folks may copy it.

Posted by cc...@apache.org.
better implementation of the flat buffer json decoder since folks may copy it.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/655b79e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/655b79e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/655b79e8

Branch: refs/heads/develop
Commit: 655b79e8832918a4cb9eeb3cf4aa43cfd7720d84
Parents: 1c3f5ac
Author: Paul Dietrich <pa...@yahoo.com>
Authored: Fri Mar 11 09:53:04 2016 -0800
Committer: Paul Dietrich <pa...@yahoo.com>
Committed: Fri Mar 11 13:07:20 2016 -0800

----------------------------------------------------------------------
 libs/json/include/json/json.h         |  4 +-
 libs/json/src/test/test_json_simple.c | 71 ++++++++++++++++++------------
 2 files changed, 45 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/655b79e8/libs/json/include/json/json.h
----------------------------------------------------------------------
diff --git a/libs/json/include/json/json.h b/libs/json/include/json/json.h
index 436c7e2..668b7b1 100644
--- a/libs/json/include/json/json.h
+++ b/libs/json/include/json/json.h
@@ -192,9 +192,9 @@ struct json_buffer;
 
 /* when you implement a json buffer, you must implement these functions */
 
-/* returns the next character in the buffer or '\0' */
+/* returns the next character in the buffer or '\0'*/
 typedef char (*json_buffer_read_next_byte_t)(struct json_buffer *);
-/* returns the next character in the buffer or '\0' */
+/* returns the previous character in the buffer or '\0' */
 typedef char (*json_buffer_read_prev_byte_t)(struct json_buffer *);
 /* returns the number of characters read or zero */
 typedef int (*json_buffer_readn_t)(struct json_buffer *, char *buf, int n);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/655b79e8/libs/json/src/test/test_json_simple.c
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json_simple.c b/libs/json/src/test/test_json_simple.c
index e6c5590..e7046bd 100644
--- a/libs/json/src/test/test_json_simple.c
+++ b/libs/json/src/test/test_json_simple.c
@@ -23,13 +23,6 @@
 #include "testutil/testutil.h"
 #include "json/json.h"
 
-struct test_jbuf {
-    /* json_buffer must be first element in the structure */
-    struct json_buffer json_buf;
-    char * current_buf_ptr;
-    int string_left;
-};
-
 static char *output = "{\"KeyBool\": true,\"KeyInt\": -1234,\"KeyUint\": 1353214,\"KeyString\": \"foobar\",\"KeyStringN\": \"foobarlong\"}";
 static char bigbuf[512];
 static int buf_index;
@@ -87,43 +80,70 @@ void test_json_simple_encode(void) {
 }
 
 
+/* a test structure to hold the json flat buffer and pass bytes
+ * to the decoder */
+struct test_jbuf {
+    /* json_buffer must be first element in the structure */
+    struct json_buffer json_buf;
+    char * start_buf;
+    char * end_buf;
+    int current_position;
+};
+
 
 static char 
 test_jbuf_read_next(struct json_buffer *jb) {
     char c;
-    struct test_jbuf  *ptest = (struct test_jbuf*) jb;    
+    struct test_jbuf  *ptjb = (struct test_jbuf*) jb;    
     
-    if(ptest->string_left) {
-        c = *ptest->current_buf_ptr;
-        ptest->current_buf_ptr++;
-        ptest->string_left--;
+    if((ptjb->start_buf + ptjb->current_position) <= ptjb->end_buf) {
+        c = *(ptjb->start_buf + ptjb->current_position);
+        ptjb->current_position++;
         return c;
     }
     return '\0';    
 }
+
+/* this goes backward in the buffer one character */
 static char 
 test_jbuf_read_prev(struct json_buffer *jb) {
     char c;
-    struct test_jbuf  *ptest = (struct test_jbuf*) jb;
-    ptest->current_buf_ptr--;
-    ptest->string_left++;    
-    c = *ptest->current_buf_ptr;
-    return c;
+    struct test_jbuf  *ptjb = (struct test_jbuf*) jb;
+    if(ptjb->current_position) {
+       ptjb->current_position--; 
+       c = *(ptjb->start_buf + ptjb->current_position);
+       return c;
+    }
+    
+    /* can't rewind */
+    return '\0';
+    
 }
 
 static int 
 test_jbuf_readn(struct json_buffer *jb, char *buf, int size) {
-    struct test_jbuf  *ptest = (struct test_jbuf*) jb;  
+    struct test_jbuf  *ptjb = (struct test_jbuf*) jb;    
     
-    if(ptest->string_left >= size) {
-        memcpy(buf, ptest->current_buf_ptr, size);
-        ptest->current_buf_ptr+= size;
-        ptest->string_left-= size;
+    if((ptjb->end_buf - (ptjb->start_buf + ptjb->current_position) + 1) >= size) {
+        memcpy(buf, ptjb->start_buf + ptjb->current_position, size);
+        ptjb->current_position += size;
         return 0;
     }
     return -1;
 }
 
+static void 
+test_buf_init(struct test_jbuf *ptjb, char *string) {
+    /* initialize the decode */
+    ptjb->json_buf.jb_read_next = test_jbuf_read_next;
+    ptjb->json_buf.jb_read_prev = test_jbuf_read_prev;
+    ptjb->json_buf.jb_readn = test_jbuf_readn;
+    ptjb->start_buf = string;
+    ptjb->end_buf = string + strlen(string);  
+    /* end buf points to the NULL */
+    ptjb->current_position = 0;
+}
+
 /* now test the decode on a string */
 void test_json_simple_decode(void) {
     struct test_jbuf tjb; 
@@ -169,12 +189,7 @@ void test_json_simple_decode(void) {
             }
     };    
     
-    /* intialize the decode */
-    tjb.current_buf_ptr = output;
-    tjb.json_buf.jb_read_next = test_jbuf_read_next;
-    tjb.json_buf.jb_read_prev = test_jbuf_read_prev;
-    tjb.json_buf.jb_readn = test_jbuf_readn;
-    tjb.string_left = strlen(output) + 1; // for NULL 
+    test_buf_init(&tjb, output);
 
     rc = json_read_object(&tjb.json_buf, test_attr);
     TEST_ASSERT(rc==0);    


[3/5] incubator-mynewt-core git commit: add unit test for json. This is just a simple test to ensure that we encode and decode a very simple json structure properly. NOTE: This can also serve as example code on how to do json encoding and decoding

Posted by cc...@apache.org.
add unit test for json.  This is just a simple test to ensure that we encode
and decode a very simple json structure properly.  NOTE: This can also serve
as example code on how to do json encoding and decoding


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/32dd023f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/32dd023f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/32dd023f

Branch: refs/heads/develop
Commit: 32dd023ff0401531fca2050577d6bb4d1b7a6872
Parents: 473f5a8
Author: Paul Dietrich <pa...@yahoo.com>
Authored: Fri Mar 11 09:28:25 2016 -0800
Committer: Paul Dietrich <pa...@yahoo.com>
Committed: Fri Mar 11 13:07:20 2016 -0800

----------------------------------------------------------------------
 libs/json/include/json/json.h         |   6 +
 libs/json/pkg.yml                     |   2 +
 libs/json/src/test/test_json.c        |  41 +++++++
 libs/json/src/test/test_json.h        |  28 +++++
 libs/json/src/test/test_json_simple.c | 191 +++++++++++++++++++++++++++++
 5 files changed, 268 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32dd023f/libs/json/include/json/json.h
----------------------------------------------------------------------
diff --git a/libs/json/include/json/json.h b/libs/json/include/json/json.h
index 9f8e29c..436c7e2 100644
--- a/libs/json/include/json/json.h
+++ b/libs/json/include/json/json.h
@@ -189,8 +189,14 @@ struct json_attr_t {
 };
 
 struct json_buffer;
+
+/* when you implement a json buffer, you must implement these functions */
+
+/* returns the next character in the buffer or '\0' */
 typedef char (*json_buffer_read_next_byte_t)(struct json_buffer *);
+/* returns the next character in the buffer or '\0' */
 typedef char (*json_buffer_read_prev_byte_t)(struct json_buffer *);
+/* returns the number of characters read or zero */
 typedef int (*json_buffer_readn_t)(struct json_buffer *, char *buf, int n);
 
 struct json_buffer {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32dd023f/libs/json/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/json/pkg.yml b/libs/json/pkg.yml
index a9e45a9..b0bf349 100644
--- a/libs/json/pkg.yml
+++ b/libs/json/pkg.yml
@@ -24,5 +24,7 @@ pkg.author: Sterling Hughes <st...@apache.org>
 pkg.homepage: http://mynewt.apache.org/os/modules/json/json/
 pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 pkg.keywords:
+pkg.deps.TEST:
+   - libs/testutil
 
 pkg.cflags.float_user: -DFLOAT_SUPPORT

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32dd023f/libs/json/src/test/test_json.c
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json.c b/libs/json/src/test/test_json.c
new file mode 100644
index 0000000..78495dd
--- /dev/null
+++ b/libs/json/src/test/test_json.c
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <testutil/testutil.h>
+#include <test_json.h>
+
+
+TEST_SUITE(test_suite_json) {
+    test_encode_simple();
+    test_decode_simple();
+}
+
+#ifdef MYNEWT_SELFTEST
+
+int
+main(int argc, char **argv)
+{
+    tu_config.tc_print_results = 1;
+    tu_init();
+
+    test_suite_json();
+
+    return tu_any_failed;
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32dd023f/libs/json/src/test/test_json.h
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json.h b/libs/json/src/test/test_json.h
new file mode 100644
index 0000000..b63109e
--- /dev/null
+++ b/libs/json/src/test/test_json.h
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef TEST_JSON_H
+#define TEST_JSON_H
+
+void test_encode_simple(void);
+void test_decode_simple(void);
+
+
+#endif /* TEST_JSON_H */
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/32dd023f/libs/json/src/test/test_json_simple.c
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json_simple.c b/libs/json/src/test/test_json_simple.c
new file mode 100644
index 0000000..7b8ff97
--- /dev/null
+++ b/libs/json/src/test/test_json_simple.c
@@ -0,0 +1,191 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "test_json.h"
+#include <assert.h>
+#include <string.h>
+#include "testutil/testutil.h"
+#include "json/json.h"
+
+struct test_jbuf {
+    /* json_buffer must be first element in the structure */
+    struct json_buffer json_buf;
+    char * current_buf_ptr;
+    int string_left;
+};
+
+static char *output = "{\"KeyBool\": true,\"KeyInt\": -1234,\"KeyUint\": 1353214,\"KeyString\": \"foobar\",\"KeyStringN\": \"foobarlong\"}";
+static char bigbuf[512];
+static int buf_index;
+
+static int test_write(void *buf, char* data, int len) {
+    int i;
+    for(i = 0; i < len; i++) {
+        putchar(data[i]);
+        bigbuf[buf_index++] = data[i];        
+    }
+    return len;
+}
+
+void test_encode_simple(void) {
+    struct json_encoder encoder;
+    struct json_value value;
+    int rc;
+    
+    /* reset the state of the internal test */
+    buf_index = 0;    
+    memset(&encoder, 0, sizeof(encoder));
+    
+    encoder.je_write = test_write;
+    encoder.je_arg= NULL;
+    
+    rc = json_encode_object_start(&encoder);    
+    TEST_ASSERT(rc == 0);
+    
+    JSON_VALUE_BOOL(&value, 1);
+    rc = json_encode_object_entry(&encoder, "KeyBool", &value);
+    TEST_ASSERT(rc == 0);
+    
+    JSON_VALUE_INT(&value, -1234);
+    rc = json_encode_object_entry(&encoder, "KeyInt", &value);
+    TEST_ASSERT(rc == 0);    
+
+    JSON_VALUE_UINT(&value, 1353214);
+    rc = json_encode_object_entry(&encoder, "KeyUint", &value);
+    TEST_ASSERT(rc == 0);    
+    
+    JSON_VALUE_STRING(&value, "foobar");
+    rc = json_encode_object_entry(&encoder, "KeyString", &value);
+    TEST_ASSERT(rc == 0);    
+    
+    /* we'll decode later differently */
+    JSON_VALUE_STRINGN(&value, "foobarlongstring", 10);
+    rc = json_encode_object_entry(&encoder, "KeyStringN", &value);
+    TEST_ASSERT(rc == 0);  
+    
+    rc = json_encode_object_finish(&encoder);    
+    TEST_ASSERT(rc == 0);
+    
+    /* does it match what we expect it to */
+    rc = strcmp(bigbuf, output);
+    TEST_ASSERT(rc == 0);
+}
+
+
+
+static char 
+test_jbuf_read_next(struct json_buffer *jb) {
+    char c;
+    struct test_jbuf  *ptest = (struct test_jbuf*) jb;    
+    
+    if(ptest->string_left) {
+        c = *ptest->current_buf_ptr;
+        ptest->current_buf_ptr++;
+        ptest->string_left--;
+        return c;
+    }
+    return '\0';    
+}
+static char 
+test_jbuf_read_prev(struct json_buffer *jb) {
+    char c;
+    struct test_jbuf  *ptest = (struct test_jbuf*) jb;
+    ptest->current_buf_ptr--;
+    ptest->string_left++;    
+    c = *ptest->current_buf_ptr;
+    return c;
+}
+
+static int 
+test_jbuf_readn(struct json_buffer *jb, char *buf, int size) {
+    struct test_jbuf  *ptest = (struct test_jbuf*) jb;  
+    
+    if(ptest->string_left >= size) {
+        memcpy(buf, ptest->current_buf_ptr, size);
+        ptest->current_buf_ptr+= size;
+        ptest->string_left-= size;
+        return 0;
+    }
+    return -1;
+}
+
+/* now test the decode on a string */
+void test_decode_simple(void) {
+    struct test_jbuf tjb; 
+    unsigned int uint_val;
+    int int_val;
+    bool bool_val;
+    char string1[16];
+    char string2[16];
+    int rc;
+
+    const struct json_attr_t test_attr[5] = {
+        [0] = {
+            .attribute = "KeyBool",
+            .type = t_boolean,
+            .addr.boolean = &bool_val,
+            .nodefault = true
+        },
+        [1] = {
+            .attribute = "KeyInt",
+            .type = t_integer,
+            .addr.integer = &int_val,
+            .nodefault = true
+            },
+        [2] = {
+            .attribute = "KeyUint",
+            .type = t_uinteger,
+            .addr.uinteger = &uint_val,
+            .nodefault = true
+            },
+        [3] = {
+            .attribute = "KeyString",
+            .type = t_string,
+            .addr.string = string1,
+            .nodefault = true,
+            .len = sizeof(string1)
+            },
+        [4] = {
+            .attribute = "KeyStringN",
+            .type = t_string,
+            .addr.string = string2,
+            .nodefault = true,
+            .len = sizeof(string2)                    
+            }
+    };    
+    
+    /* intialize the decode */
+    tjb.current_buf_ptr = output;
+    tjb.json_buf.jb_read_next = test_jbuf_read_next;
+    tjb.json_buf.jb_read_prev = test_jbuf_read_prev;
+    tjb.json_buf.jb_readn = test_jbuf_readn;
+    tjb.string_left = strlen(output) + 1; // for NULL 
+
+    rc = json_read_object(&tjb.json_buf, test_attr);
+    TEST_ASSERT(rc==0);    
+    TEST_ASSERT(bool_val == 1);
+    TEST_ASSERT(int_val ==  -1234);
+    TEST_ASSERT(uint_val == 1353214);
+    
+    rc = memcmp(string1, "foobar", strlen("foobar"));
+    TEST_ASSERT(rc==0);    
+   
+    rc = memcmp(string2, "foobarlongstring", 10);
+    TEST_ASSERT(rc==0);            
+}
\ No newline at end of file


[4/5] incubator-mynewt-core git commit: fix names to be matching so it sets a good example for testing

Posted by cc...@apache.org.
fix names to be matching so it sets a good example for testing


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1c3f5ac7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1c3f5ac7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1c3f5ac7

Branch: refs/heads/develop
Commit: 1c3f5ac76b81b5c7f4b7f0375d4a684ec888891e
Parents: 32dd023
Author: Paul Dietrich <pa...@yahoo.com>
Authored: Fri Mar 11 09:32:49 2016 -0800
Committer: Paul Dietrich <pa...@yahoo.com>
Committed: Fri Mar 11 13:07:20 2016 -0800

----------------------------------------------------------------------
 libs/json/src/test/test_json.c        | 8 ++++----
 libs/json/src/test/test_json.h        | 5 ++---
 libs/json/src/test/test_json_simple.c | 5 ++---
 3 files changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c3f5ac7/libs/json/src/test/test_json.c
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json.c b/libs/json/src/test/test_json.c
index 78495dd..80e9abe 100644
--- a/libs/json/src/test/test_json.c
+++ b/libs/json/src/test/test_json.c
@@ -20,9 +20,9 @@
 #include <test_json.h>
 
 
-TEST_SUITE(test_suite_json) {
-    test_encode_simple();
-    test_decode_simple();
+TEST_SUITE(test_json_suite) {
+    test_json_simple_encode();
+    test_json_simple_decode();
 }
 
 #ifdef MYNEWT_SELFTEST
@@ -33,7 +33,7 @@ main(int argc, char **argv)
     tu_config.tc_print_results = 1;
     tu_init();
 
-    test_suite_json();
+    test_json_suite();
 
     return tu_any_failed;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c3f5ac7/libs/json/src/test/test_json.h
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json.h b/libs/json/src/test/test_json.h
index b63109e..8466213 100644
--- a/libs/json/src/test/test_json.h
+++ b/libs/json/src/test/test_json.h
@@ -20,9 +20,8 @@
 #ifndef TEST_JSON_H
 #define TEST_JSON_H
 
-void test_encode_simple(void);
-void test_decode_simple(void);
-
+void test_json_simple_encode(void);
+void test_json_simple_decode(void);
 
 #endif /* TEST_JSON_H */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c3f5ac7/libs/json/src/test/test_json_simple.c
----------------------------------------------------------------------
diff --git a/libs/json/src/test/test_json_simple.c b/libs/json/src/test/test_json_simple.c
index 7b8ff97..e6c5590 100644
--- a/libs/json/src/test/test_json_simple.c
+++ b/libs/json/src/test/test_json_simple.c
@@ -37,13 +37,12 @@ static int buf_index;
 static int test_write(void *buf, char* data, int len) {
     int i;
     for(i = 0; i < len; i++) {
-        putchar(data[i]);
         bigbuf[buf_index++] = data[i];        
     }
     return len;
 }
 
-void test_encode_simple(void) {
+void test_json_simple_encode(void) {
     struct json_encoder encoder;
     struct json_value value;
     int rc;
@@ -126,7 +125,7 @@ test_jbuf_readn(struct json_buffer *jb, char *buf, int size) {
 }
 
 /* now test the decode on a string */
-void test_decode_simple(void) {
+void test_json_simple_decode(void) {
     struct test_jbuf tjb; 
     unsigned int uint_val;
     int int_val;


[5/5] incubator-mynewt-core git commit: This closes #17 (paulfdietrich:MYNEWT-210)

Posted by cc...@apache.org.
This closes #17 (paulfdietrich:MYNEWT-210)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/18477e34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/18477e34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/18477e34

Branch: refs/heads/develop
Commit: 18477e345eadc752ab11586ebcbe615836cce9d3
Parents: 44e560f 04dbf5c
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 18 12:43:18 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 18 12:43:18 2016 -0700

----------------------------------------------------------------------
 libs/json/include/json/json.h             |   6 +
 libs/json/pkg.yml                         |   2 +
 libs/json/src/test/test_json.c            |  41 +++++
 libs/json/src/test/test_json.h            |  27 ++++
 libs/json/src/test/test_json_simple.c     | 205 +++++++++++++++++++++++++
 libs/testutil/include/testutil/testutil.h |   4 +
 6 files changed, 285 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/18477e34/libs/json/pkg.yml
----------------------------------------------------------------------
diff --cc libs/json/pkg.yml
index 4944622,b0bf349..3dc0be6
--- a/libs/json/pkg.yml
+++ b/libs/json/pkg.yml
@@@ -18,9 -18,13 +18,11 @@@
  #
  
  pkg.name: libs/json 
 -pkg.vers: 0.8.0
  pkg.description: JSON encoding / decoding library.
 -pkg.author: Sterling Hughes <st...@apache.org>
 -pkg.homepage: http://mynewt.apache.org/os/modules/json/json/
 -pkg.repository: https://git-wip-us.apache.org/repos/asf/incubator-mynewt-core
 +pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
 +pkg.homepage: "http://mynewt.apache.org/"
  pkg.keywords:
+ pkg.deps.TEST:
+    - libs/testutil
  
  pkg.cflags.float_user: -DFLOAT_SUPPORT