Skip to content

Commit 85a9b2e

Browse files
catamorphismsrl295
authored andcommitted
ICU-22746 Refactor MF2 tests to be data-driven and add JSON lib
This change moves all test strings out of test/intltest/messageformat2test.cpp and into JSON files, which are parsed/run by code in a new file, test/intltest/messageformat2test_read_json.cpp . It also removes the file test/intltest/messageformat2test_fromjson.cpp , which contained tests that are now stored in JSON files. To enable this, a new vendored library is added: nlohmann/json . This library is introduced as a dependency for the MF2 tests. The required part of the library is a single header file, which is added under icu4c/source/tools/toolutil/. Also adds a wrapper file for the vendored JSON header file that defines macros that disable exceptions. Co-authored-by: Steven R. Loomis <[email protected]>
1 parent 9369b7a commit 85a9b2e

36 files changed

+51532
-2089
lines changed

.cpyskip.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ KEYS
3434
*.intaglio
3535
*.jar
3636
*.jpg
37+
*.json
3738
*.launch
3839
*.nrm
3940
*.odp
@@ -117,3 +118,4 @@ tools/unicodetools/*
117118
# vendor
118119
#
119120
vendor/double-conversion/upstream/*
121+
vendor/json/upstream/*

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
433433

434434
----------------------------------------------------------------------
435435

436+
JSON parsing library (nlohmann/json)
437+
438+
File: vendor/json/upstream/single_include/nlohmann/json.hpp (only for ICU4C)
439+
440+
MIT License
441+
442+
Copyright (c) 2013-2022 Niels Lohmann
443+
444+
Permission is hereby granted, free of charge, to any person obtaining a copy
445+
of this software and associated documentation files (the "Software"), to deal
446+
in the Software without restriction, including without limitation the rights
447+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
448+
copies of the Software, and to permit persons to whom the Software is
449+
furnished to do so, subject to the following conditions:
450+
451+
The above copyright notice and this permission notice shall be included in all
452+
copies or substantial portions of the Software.
453+
454+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
455+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
456+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
457+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
458+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
459+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
460+
SOFTWARE.
461+
462+
----------------------------------------------------------------------
463+
436464
File: aclocal.m4 (only for ICU4C)
437465
Section: pkg.m4 - Macros to locate and utilise pkg-config.
438466

icu4c/source/test/intltest/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fldset.o dadrfmt.o dadrcal.o dcfmapts.o decoll.o dtfmapts.o dtfmrgts.o dtfmtrtts
4949
dtptngts.o encoll.o escoll.o ficoll.o frcoll.o g7coll.o intltest.o \
5050
itercoll.o itformat.o itmajor.o itutil.o jacoll.o lcukocol.o \
5151
loctest.o localebuildertest.o localematchertest.o \
52-
messageformat2test.o messageformat2test_builtin.o messageformat2test_custom.o messageformat2test_features.o messageformat2test_fromjson.o messageformat2test_icu.o \
52+
messageformat2test.o messageformat2test_builtin.o messageformat2test_custom.o messageformat2test_features.o messageformat2test_read_json.o messageformat2test_icu.o \
5353
miscdtfm.o mnkytst.o msfmrgts.o nmfmapts.o nmfmtrt.o \
5454
numfmtst.o numrgts.o plurults.o plurfmts.o pptest.o regcoll.o restest.o restsnew.o \
5555
sdtfmtts.o svccoll.o tchcfmt.o selfmts.o \

icu4c/source/test/intltest/intltest.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@
143143
<ClCompile Include="messageformat2test.cpp" />
144144
<ClCompile Include="messageformat2test_custom.cpp" />
145145
<ClCompile Include="messageformat2test_features.cpp" />
146-
<ClCompile Include="messageformat2test_fromjson.cpp" />
147146
<ClCompile Include="messageformat2test_icu.cpp" />
147+
<ClCompile Include="messageformat2test_read_json.cpp" />
148148
<ClCompile Include="miscdtfm.cpp" />
149149
<ClCompile Include="msfmrgts.cpp" />
150150
<ClCompile Include="nmfmapts.cpp" />

icu4c/source/test/intltest/intltest.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@
575575
<ClCompile Include="messageformat2test.cpp" />
576576
<ClCompile Include="messageformat2test_custom.cpp" />
577577
<ClCompile Include="messageformat2test_features.cpp" />
578-
<ClCompile Include="messageformat2test_fromjson.cpp" />
579578
<ClCompile Include="messageformat2test_icu.cpp" />
579+
<ClCompile Include="messageformat2test_read_json.cpp" />
580580
</ItemGroup>
581581
<ItemGroup>
582582
<ClInclude Include="itrbbi.h">

0 commit comments

Comments
 (0)