Skip to content

Commit

Permalink
t/vsistdout.t: decode JSON and use is_deeply for test
Browse files Browse the repository at this point in the history
Refactor the expected structure in the process.
  • Loading branch information
shawnlaffan committed Nov 18, 2023
1 parent 1388d8e commit 037f80d
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions t/vsistdout.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ if(1){
$gdal->CloseWriter;

my $ret = $output->output;
my $exp = <<'EODATA'
{"type": "FeatureCollection","features": [{ "type": "Feature", "id": 0, "properties": { "value": 12 }, "geometry": { "type": "Point", "coordinates": [ 1.0, 1.0 ] } },{ "type": "Feature", "id": 1, "properties": { "value": 12 }, "geometry": { "type": "Point", "coordinates": [ 1.0, 2.0 ] } }]}
EODATA
;
$exp =~ s/\n$//;
$ret = decode_json $ret;

is($ret, $exp,
my $exp = decode_json (get_expected_json_data());

is_deeply ($ret, $exp,
"Redirect vsistdout to write/close methods of a class.");

}
Expand All @@ -72,3 +70,38 @@ if(1){
}

done_testing();


sub get_expected_json_data {
my $json = <<'EOJSON'
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": 0,
"properties": {
"value": 12
},
"geometry": {
"type": "Point",
"coordinates": [1.0, 1.0]
}
}, {
"type": "Feature",
"id": 1,
"properties": {
"value": 12
},
"geometry": {
"type": "Point",
"coordinates": [1.0, 2.0]
}
}
]
}
EOJSON
;
return $json;
}


0 comments on commit 037f80d

Please sign in to comment.