Skip to content

Commit 68621f7

Browse files
committed
tests: fix new json test cases on MSVC
1 parent 353c045 commit 68621f7

File tree

5 files changed

+85
-8
lines changed

5 files changed

+85
-8
lines changed

.github/AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ This page lists all contributors improving this project over time, since the cre
2020
* GitHub: [funZX](https://github.com/funZX)
2121
* GitHub: [msmshazan](https://github.com/msmshazan)
2222
* GitHub: [BeastLe9enD](https://github.com/BeastLe9enD)
23+
* GitHub: [rheatley-pervasid](https://github.com/rheatley-pervasid)
2324
* YOU

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
19.0.0 - Check all results of zpl_alloc() when using JSON parser/writer (rheatley-pervasid)
2+
13
18.1.5 - set parent to parsed JSON nodes (fixed)
24
- fix zpl_json/csv_write_string off-by-one issue
35
18.1.4 - fix zpl_random_gen_isize/zpl_random_range_isize 32bit overflow

code/tests/cases/json.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,27 +267,30 @@ MODULE(json5_parser, {
267267
"test9": NaN,
268268
"test10": -NaN
269269
}));
270+
char *buffer = zpl_malloc(1);
270271
for (int i = 1; true; i++) {
271-
char buffer[i];
272+
buffer = zpl_resize(zpl_heap(), buffer, i-1, i);
272273
zpl_arena arena;
273-
zpl_arena_init_from_memory(&arena, buffer, sizeof(buffer));
274+
zpl_arena_init_from_memory(&arena, buffer, i);
274275
zpl_allocator allocator = zpl_arena_allocator(&arena);
275276

276277
zpl_json_object r={0};
277278
zpl_u8 err = zpl_json_parse(&r, (char *)t, allocator);
278-
if (err == ZPL_JSON_ERROR_OUT_OF_MEMORY)
279-
continue;
279+
if (err == ZPL_JSON_ERROR_OUT_OF_MEMORY)
280+
continue;
280281
EQUALS(err, ZPL_JSON_ERROR_NONE);
281282
EQUALS(zpl_array_count(r.nodes), 10);
282283
break;
283284
}
285+
zpl_mfree(buffer);
284286
});
285287

286288
IT("handles out of memory during construction", {
287-
for (int i = 1; true; i++) {
288-
char buffer[i];
289+
char *buffer = zpl_malloc(1);
290+
for (int i = 1; true; i++) {
291+
buffer = zpl_resize(zpl_heap(), buffer, i-1, i);
289292
zpl_arena arena;
290-
zpl_arena_init_from_memory(&arena, buffer, sizeof(buffer));
293+
zpl_arena_init_from_memory(&arena, buffer, i);
291294
zpl_allocator allocator = zpl_arena_allocator(&arena);
292295

293296
zpl_json_object doc, *o, *o2;
@@ -341,7 +344,8 @@ MODULE(json5_parser, {
341344
STREQUALS(expected, a);
342345
break;
343346
}
344-
});
347+
zpl_mfree(buffer);
348+
});
345349
});
346350

347351
#undef __PARSE

code/zpl_hedley.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,20 +790,27 @@
790790
#if defined(ZPL_DIAGNOSTIC_PUSH)
791791
# undef ZPL_DIAGNOSTIC_PUSH
792792
#endif
793+
#if defined(ZPL_DIAGNOSTIC_PUSH_WARNLEVEL)
794+
# undef ZPL_DIAGNOSTIC_PUSH_WARNLEVEL
795+
#endif
793796
#if defined(ZPL_DIAGNOSTIC_POP)
794797
# undef ZPL_DIAGNOSTIC_POP
795798
#endif
796799
#if defined(__clang__)
797800
# define ZPL_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
801+
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x)
798802
# define ZPL_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
799803
#elif ZPL_INTEL_VERSION_CHECK(13,0,0)
800804
# define ZPL_DIAGNOSTIC_PUSH _Pragma("warning(push)")
805+
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x)
801806
# define ZPL_DIAGNOSTIC_POP _Pragma("warning(pop)")
802807
#elif ZPL_GCC_VERSION_CHECK(4,6,0)
803808
# define ZPL_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
809+
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x)
804810
# define ZPL_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
805811
#elif ZPL_MSVC_VERSION_CHECK(15,0,0)
806812
# define ZPL_DIAGNOSTIC_PUSH __pragma(warning(push))
813+
# define ZPL_DIAGNOSTIC_PUSH_WARNLEVEL(x) __pragma(warning(push, x))
807814
# define ZPL_DIAGNOSTIC_POP __pragma(warning(pop))
808815
#elif ZPL_ARM_VERSION_CHECK(5,6,0)
809816
# define ZPL_DIAGNOSTIC_PUSH _Pragma("push")

zpl.10x

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0"?>
2+
<N10X>
3+
<Workspace>
4+
<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>
5+
<ExcludeFilter></ExcludeFilter>
6+
<SyncFiles>true</SyncFiles>
7+
<Recursive>true</Recursive>
8+
<IsVirtual>false</IsVirtual>
9+
<IsFolder>false</IsFolder>
10+
<BuildCommand>build.bat</BuildCommand>
11+
<RebuildCommand></RebuildCommand>
12+
<BuildFileCommand></BuildFileCommand>
13+
<CleanCommand></CleanCommand>
14+
<BuildWorkingDirectory></BuildWorkingDirectory>
15+
<RunCommand></RunCommand>
16+
<DebugCommand></DebugCommand>
17+
<ExePathCommand></ExePathCommand>
18+
<DebugSln></DebugSln>
19+
<UseVisualStudioEnvBat>false</UseVisualStudioEnvBat>
20+
<Configurations>
21+
<Configuration>Debug</Configuration>
22+
<Configuration>Release</Configuration>
23+
</Configurations>
24+
<Platforms>
25+
<Platform>x64</Platform>
26+
<Platform>Win32</Platform>
27+
</Platforms>
28+
<AdditionalIncludePaths>
29+
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include</AdditionalIncludePath>
30+
<AdditionalIncludePath>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include</AdditionalIncludePath>
31+
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt</AdditionalIncludePath>
32+
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um</AdditionalIncludePath>
33+
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared</AdditionalIncludePath>
34+
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt</AdditionalIncludePath>
35+
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt</AdditionalIncludePath>
36+
<AdditionalIncludePath>C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um</AdditionalIncludePath>
37+
</AdditionalIncludePaths>
38+
<Defines>
39+
<Define>_MSC_VER=9999</Define>
40+
<Define>_WIN32</Define>
41+
<Define>ZPL_IMPL</Define>
42+
<Define>EDITOR_10X</Define>
43+
</Defines>
44+
<ConfigProperties>
45+
<ConfigAndPlatform>
46+
<Name>Release:x64</Name>
47+
<Defines></Defines>
48+
<ForceIncludes>
49+
<ForceInclude>code/zpl.h</ForceInclude>
50+
</ForceIncludes>
51+
</ConfigAndPlatform>
52+
<Config>
53+
<Name>Release</Name>
54+
<Defines></Defines>
55+
</Config>
56+
<Platform>
57+
<Name>x64</Name>
58+
<Defines></Defines>
59+
</Platform>
60+
</ConfigProperties>
61+
<Children></Children>
62+
</Workspace>
63+
</N10X>

0 commit comments

Comments
 (0)