%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         Regression Test Unit of loadjson and savejson
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i = 1:4
    fname = sprintf('example%d.json', i);
    if (exist(fname, 'file') == 0)
        break
    end
    fprintf(1, '===============================================\n>> %s\n', fname);
    json = savejson('data', loadjson(fname));
    fprintf(1, '%s\n', json);
    fprintf(1, '%s\n', savejson('data', loadjson(fname), 'Compact', 1));
    data = loadjson(json);
    savejson('data', data, 'selftest.json');
    data = loadjson('selftest.json');
end

for i = 1:4
    fname = sprintf('example%d.json', i);
    if (exist(fname, 'file') == 0)
        break
    end
    fprintf(1, '===============================================\n>> %s\n', fname);
    json = savebj('data', loadjson(fname));
    fprintf(1, '%s\n', json);
    data = loadbj(json);
    savejson('', data);
    savebj('data', data, 'selftest.ubj');
    data = loadbj('selftest.ubj');
end
