Skip to content

Commit

Permalink
tests: fix new json test cases on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Jan 20, 2023
1 parent 353c045 commit 68621f7
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ This page lists all contributors improving this project over time, since the cre
* GitHub: [funZX](https://github.com/funZX)
* GitHub: [msmshazan](https://github.com/msmshazan)
* GitHub: [BeastLe9enD](https://github.com/BeastLe9enD)
* GitHub: [rheatley-pervasid](https://github.com/rheatley-pervasid)
* YOU
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
19.0.0 - Check all results of zpl_alloc() when using JSON parser/writer (rheatley-pervasid)

18.1.5 - set parent to parsed JSON nodes (fixed)
- fix zpl_json/csv_write_string off-by-one issue
18.1.4 - fix zpl_random_gen_isize/zpl_random_range_isize 32bit overflow
Expand Down
20 changes: 12 additions & 8 deletions code/tests/cases/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,27 +267,30 @@ MODULE(json5_parser, {
"test9": NaN,
"test10": -NaN
}));
char *buffer = zpl_malloc(1);
for (int i = 1; true; i++) {
char buffer[i];
buffer = zpl_resize(zpl_heap(), buffer, i-1, i);
zpl_arena arena;
zpl_arena_init_from_memory(&arena, buffer, sizeof(buffer));
zpl_arena_init_from_memory(&arena, buffer, i);
zpl_allocator allocator = zpl_arena_allocator(&arena);

zpl_json_object r={0};
zpl_u8 err = zpl_json_parse(&r, (char *)t, allocator);
if (err == ZPL_JSON_ERROR_OUT_OF_MEMORY)
continue;
if (err == ZPL_JSON_ERROR_OUT_OF_MEMORY)
continue;
EQUALS(err, ZPL_JSON_ERROR_NONE);
EQUALS(zpl_array_count(r.nodes), 10);
break;
}
zpl_mfree(buffer);
});

IT("handles out of memory during construction", {
for (int i = 1; true; i++) {
char buffer[i];
char *buffer = zpl_malloc(1);
for (int i = 1; true; i++) {
buffer = zpl_resize(zpl_heap(), buffer, i-1, i);
zpl_arena arena;
zpl_arena_init_from_memory(&arena, buffer, sizeof(buffer));
zpl_arena_init_from_memory(&arena, buffer, i);
zpl_allocator allocator = zpl_arena_allocator(&arena);

zpl_json_object doc, *o, *o2;
Expand Down Expand Up @@ -341,7 +344,8 @@ MODULE(json5_parser, {
STREQUALS(expected, a);
break;
}
});
zpl_mfree(buffer);
});
});

#undef __PARSE
7 changes: 7 additions & 0 deletions code/zpl_hedley.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,20 +790,27 @@
#if defined(ZPL_DIAGNOSTIC_PUSH)
# undef ZPL_DIAGNOSTIC_PUSH
#endif
#if defined(ZPL_DIAGNOSTIC_PUSH_WARNLEVEL)
# undef ZPL_DIAGNOSTIC_PUSH_WARNLEVEL
#endif
#if defined(ZPL_DIAGNOSTIC_POP)
# undef ZPL_DIAGNOSTIC_POP
#endif
#if defined(__clang__)
# define ZPL_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x)
# define ZPL_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
#elif ZPL_INTEL_VERSION_CHECK(13,0,0)
# define ZPL_DIAGNOSTIC_PUSH _Pragma("warning(push)")
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x)
# define ZPL_DIAGNOSTIC_POP _Pragma("warning(pop)")
#elif ZPL_GCC_VERSION_CHECK(4,6,0)
# define ZPL_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x)
# define ZPL_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
#elif ZPL_MSVC_VERSION_CHECK(15,0,0)
# define ZPL_DIAGNOSTIC_PUSH __pragma(warning(push))
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x) __pragma(warning(push, x))
# define ZPL_DIAGNOSTIC_POP __pragma(warning(pop))
#elif ZPL_ARM_VERSION_CHECK(5,6,0)
# define ZPL_DIAGNOSTIC_PUSH _Pragma("push")
Expand Down
63 changes: 63 additions & 0 deletions zpl.10x
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0"?>
<N10X>
<Workspace>
<IncludeFilter>*.c,*.cc,*.cpp,*.c++,*.cp,*.cxx,*.h,*.hh,*.hpp,*.h++,*.hp,*.hxx,*.inl,*.cs,*.rs,*.java,*.jav,*.js,*.jsc,*.jsx,*.json,*.cls,*.py,*.rpy,*.php,*.php3,*.phl,*.phtml,*.rhtml,*.tpl,*.phps,*.lua,*.html,*.html5,*.htm,*.xml,*.xaml,*.css,*.ssi,*.haml,*.yaml,*.bat,*.wbf,*.wbt,*.txt,*.cmake,*.make,*.makefile,*.mak,*.mk,*.sh,*.bash,*.csv,*.asp,*.pl,*.mac,*.ws,*.vbs,*.perl,*.src,*.rss,*.inc,*.f,*.go,*.prl,*.plx,*.rb,*.lsp,*.lpx,*.ps1,*.command,*.cbl,*.cob,*.qs,*.wxs,*.ph,*.msc,*.glsl,*.hlsl,*.fx,*.vert,*.tesc,*.tese,*.geom,*.frag,*.comp,*.pssl,*.scons,</IncludeFilter>
<ExcludeFilter></ExcludeFilter>
<SyncFiles>true</SyncFiles>
<Recursive>true</Recursive>
<IsVirtual>false</IsVirtual>
<IsFolder>false</IsFolder>
<BuildCommand>build.bat</BuildCommand>
<RebuildCommand></RebuildCommand>
<BuildFileCommand></BuildFileCommand>
<CleanCommand></CleanCommand>
<BuildWorkingDirectory></BuildWorkingDirectory>
<RunCommand></RunCommand>
<DebugCommand></DebugCommand>
<ExePathCommand></ExePathCommand>
<DebugSln></DebugSln>
<UseVisualStudioEnvBat>false</UseVisualStudioEnvBat>
<Configurations>
<Configuration>Debug</Configuration>
<Configuration>Release</Configuration>
</Configurations>
<Platforms>
<Platform>x64</Platform>
<Platform>Win32</Platform>
</Platforms>
<AdditionalIncludePaths>
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt</AdditionalIncludePath>
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um</AdditionalIncludePath>
</AdditionalIncludePaths>
<Defines>
<Define>_MSC_VER=9999</Define>
<Define>_WIN32</Define>
<Define>ZPL_IMPL</Define>
<Define>EDITOR_10X</Define>
</Defines>
<ConfigProperties>
<ConfigAndPlatform>
<Name>Release:x64</Name>
<Defines></Defines>
<ForceIncludes>
<ForceInclude>code/zpl.h</ForceInclude>
</ForceIncludes>
</ConfigAndPlatform>
<Config>
<Name>Release</Name>
<Defines></Defines>
</Config>
<Platform>
<Name>x64</Name>
<Defines></Defines>
</Platform>
</ConfigProperties>
<Children></Children>
</Workspace>
</N10X>

0 comments on commit 68621f7

Please sign in to comment.