@@ -1862,6 +1862,64 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterBool) {
1862
1862
delete reader;
1863
1863
}
1864
1864
1865
+ struct CharReaderAllowDropNullTest : JsonTest::TestCase {};
1866
+
1867
+ JSONTEST_FIXTURE (CharReaderAllowDropNullTest, issue178) {
1868
+ Json::CharReaderBuilder b;
1869
+ b.settings_ [" allowDroppedNullPlaceholders" ] = true ;
1870
+ Json::Value root;
1871
+ std::string errs;
1872
+ Json::CharReader* reader (b.newCharReader ());
1873
+ {
1874
+ char const doc[] = " []" ;
1875
+ bool ok = reader->parse (
1876
+ doc, doc + std::strlen (doc),
1877
+ &root, &errs);
1878
+ JSONTEST_ASSERT (ok);
1879
+ JSONTEST_ASSERT (errs == " " );
1880
+ JSONTEST_ASSERT_EQUAL (0u , root.size ());
1881
+ JSONTEST_ASSERT_EQUAL (Json::arrayValue, root);
1882
+ }
1883
+ {
1884
+ char const doc[] = " [null]" ;
1885
+ bool ok = reader->parse (
1886
+ doc, doc + std::strlen (doc),
1887
+ &root, &errs);
1888
+ JSONTEST_ASSERT (ok);
1889
+ JSONTEST_ASSERT (errs == " " );
1890
+ JSONTEST_ASSERT_EQUAL (1u , root.size ());
1891
+ }
1892
+ {
1893
+ char const doc[] = " [,null]" ;
1894
+ bool ok = reader->parse (
1895
+ doc, doc + std::strlen (doc),
1896
+ &root, &errs);
1897
+ JSONTEST_ASSERT (ok);
1898
+ JSONTEST_ASSERT (errs == " " );
1899
+ JSONTEST_ASSERT_EQUAL (2u , root.size ());
1900
+ }
1901
+ {
1902
+ char const doc[] = " [,,null]" ;
1903
+ bool ok = reader->parse (
1904
+ doc, doc + std::strlen (doc),
1905
+ &root, &errs);
1906
+ JSONTEST_ASSERT (ok);
1907
+ JSONTEST_ASSERT (errs == " " );
1908
+ JSONTEST_ASSERT_EQUAL (3u , root.size ());
1909
+ }
1910
+ {
1911
+ char const doc[] = " [,,,[]]" ;
1912
+ bool ok = reader->parse (
1913
+ doc, doc + std::strlen (doc),
1914
+ &root, &errs);
1915
+ JSONTEST_ASSERT (ok);
1916
+ JSONTEST_ASSERT (errs == " " );
1917
+ JSONTEST_ASSERT_EQUAL (4u , root.size ());
1918
+ JSONTEST_ASSERT_EQUAL (Json::arrayValue, root[3u ]);
1919
+ }
1920
+ delete reader;
1921
+ }
1922
+
1865
1923
struct IteratorTest : JsonTest::TestCase {};
1866
1924
1867
1925
JSONTEST_FIXTURE (IteratorTest, distance) {
@@ -1925,6 +1983,8 @@ int main(int argc, const char* argv[]) {
1925
1983
JSONTEST_REGISTER_FIXTURE (runner, CharReaderFailIfExtraTest, commentAfterArray);
1926
1984
JSONTEST_REGISTER_FIXTURE (runner, CharReaderFailIfExtraTest, commentAfterBool);
1927
1985
1986
+ JSONTEST_REGISTER_FIXTURE (runner, CharReaderAllowDropNullTest, issue178);
1987
+
1928
1988
JSONTEST_REGISTER_FIXTURE (runner, IteratorTest, distance);
1929
1989
1930
1990
return runner.runCommandLine (argc, argv);
0 commit comments