Skip to content

Commit

Permalink
ICU-22746 Refactor MF2 tests to be data-driven and add JSON lib
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
2 people authored and echeran committed May 7, 2024
1 parent 9369b7a commit 85a9b2e
Show file tree
Hide file tree
Showing 36 changed files with 51,532 additions and 2,089 deletions.
2 changes: 2 additions & 0 deletions .cpyskip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ KEYS
*.intaglio
*.jar
*.jpg
*.json
*.launch
*.nrm
*.odp
Expand Down Expand Up @@ -117,3 +118,4 @@ tools/unicodetools/*
# vendor
#
vendor/double-conversion/upstream/*
vendor/json/upstream/*
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------

JSON parsing library (nlohmann/json)

File: vendor/json/upstream/single_include/nlohmann/json.hpp (only for ICU4C)

MIT License

Copyright (c) 2013-2022 Niels Lohmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------------------------------------------------------------

File: aclocal.m4 (only for ICU4C)
Section: pkg.m4 - Macros to locate and utilise pkg-config.

Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/intltest/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fldset.o dadrfmt.o dadrcal.o dcfmapts.o decoll.o dtfmapts.o dtfmrgts.o dtfmtrtts
dtptngts.o encoll.o escoll.o ficoll.o frcoll.o g7coll.o intltest.o \
itercoll.o itformat.o itmajor.o itutil.o jacoll.o lcukocol.o \
loctest.o localebuildertest.o localematchertest.o \
messageformat2test.o messageformat2test_builtin.o messageformat2test_custom.o messageformat2test_features.o messageformat2test_fromjson.o messageformat2test_icu.o \
messageformat2test.o messageformat2test_builtin.o messageformat2test_custom.o messageformat2test_features.o messageformat2test_read_json.o messageformat2test_icu.o \
miscdtfm.o mnkytst.o msfmrgts.o nmfmapts.o nmfmtrt.o \
numfmtst.o numrgts.o plurults.o plurfmts.o pptest.o regcoll.o restest.o restsnew.o \
sdtfmtts.o svccoll.o tchcfmt.o selfmts.o \
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/intltest/intltest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
<ClCompile Include="messageformat2test.cpp" />
<ClCompile Include="messageformat2test_custom.cpp" />
<ClCompile Include="messageformat2test_features.cpp" />
<ClCompile Include="messageformat2test_fromjson.cpp" />
<ClCompile Include="messageformat2test_icu.cpp" />
<ClCompile Include="messageformat2test_read_json.cpp" />
<ClCompile Include="miscdtfm.cpp" />
<ClCompile Include="msfmrgts.cpp" />
<ClCompile Include="nmfmapts.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/intltest/intltest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@
<ClCompile Include="messageformat2test.cpp" />
<ClCompile Include="messageformat2test_custom.cpp" />
<ClCompile Include="messageformat2test_features.cpp" />
<ClCompile Include="messageformat2test_fromjson.cpp" />
<ClCompile Include="messageformat2test_icu.cpp" />
<ClCompile Include="messageformat2test_read_json.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="itrbbi.h">
Expand Down
Loading

0 comments on commit 85a9b2e

Please sign in to comment.