Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON Unit Tests #2

Merged
merged 1 commit into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Include filepaths for source and include.
include(jsonFilePaths.cmake)

# JSON library target.
add_library( json
${JSON_SOURCES} )

# JSON public include path.
target_include_directories( json PUBLIC ${JSON_INCLUDE_PUBLIC_DIRS}
${LOGGING_INCLUDE_DIRS} )

# Organization of JSON in IDE projects.
set_target_properties( json PROPERTIES FOLDER libraries/standard )
source_group( include FILES include/json.h )
source_group( src FILES ${JSON_SOURCES} )

if(BUILD_TESTS)
add_subdirectory(utest)
endif()
8 changes: 7 additions & 1 deletion include/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ typedef enum
JSONSuccess,
JSONIllegalDocument,
JSONMaxDepthExceeded,
JSONNotFound
JSONNotFound,
JSONNullParameter,
JSONBadParameter
} JSONStatus_t;

/**
Expand All @@ -40,6 +42,8 @@ typedef enum
* @param[in] max The size of the buffer.
*
* @return #JSONSuccess if the buffer contents are valid JSON;
* #JSONNullParameter if buf is NULL;
* #JSONBadParameter if max is 0;
* #JSONIllegalDocument if the buffer contents are NOT valid JSON;
* #JSONMaxDepthExceeded if object and array nesting exceeds a threshold;
* #JSONPartial if the buffer contents are potentially valid but incomplete.
Expand Down Expand Up @@ -91,6 +95,8 @@ JSONStatus_t JSON_Validate( const char * buf,
* }
*
* @return #JSONSuccess if the queryKey is found and the value output;
* #JSONNullParameter if any pointer parameters are NULL;
* #JSONBadParameter if the queryKey is empty, or any subpart is empty, or max is 0;
* #JSONIllegalDocument if the buffer contents are NOT valid JSON;
* #JSONMaxDepthExceeded if object and array nesting exceeds a threshold;
* #JSONNotFound if the queryKey is NOT found.
Expand Down
14 changes: 14 additions & 0 deletions jsonFilePaths.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is to add source files and include directories
# into variables so that it can be reused from different repositories
# in their Cmake based build system by including this file.
#
# Files specific to the repository such as test runner, platform tests
# are not added to the variables.

# JSON library source files.
set( JSON_SOURCES
${MODULES_DIR}/standard/json/src/json.c )

# JSON library Public Include directories.
set( JSON_INCLUDE_PUBLIC_DIRS
${MODULES_DIR}/standard/json/include )
15 changes: 15 additions & 0 deletions lexicon.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
abc
ascii
bf
bmp
buf
buflength
com
Expand All @@ -10,6 +11,7 @@ df
dfff
ef
endif
enums
fb
fc
fd
Expand All @@ -19,14 +21,19 @@ foo
ifndef
inc
json
jsonbadparameter
jsonillegaldocument
jsonmaxdepthexceeded
jsonnotfound
jsonnullparameter
jsonpartial
jsonsuccess
keylength
len
misra
msb
multibyte
nextkeyvaluepair
noninfringement
nul
outvalue
Expand All @@ -37,6 +44,14 @@ querykey
querykeylength
requirelowsurrogate
sizeof
skiparrayscalars
skipdecimals
skipdigits
skipescape
skipexponent
skiphexescape
skipobjectscalars
skipstring
src
sublicense
unescaped
Expand Down
Loading