Add parsing tests

This commit is contained in:
Andrea Marco Sartori 2023-06-13 22:13:58 +02:00
parent a6e7eca23a
commit 840469a24f

View File

@ -1,6 +1,7 @@
<?php
use Cerbero\JsonParser\Dataset;
use Cerbero\JsonParser\Decoders\SimdjsonDecoder;
use Cerbero\JsonParser\JsonParser;
use function Cerbero\JsonParser\parseJson;
@ -18,6 +19,14 @@ it('parses JSON when calling the helper', function (string $json, array $parsed)
expect(parseJson($json))->toParseTo($parsed);
})->with(Dataset::forParsing());
it('parses with custom decoders', function (string $json, array $parsed) {
expect(JsonParser::parse($json)->decoder(new SimdjsonDecoder()))->toParseTo($parsed);
})->with(Dataset::forParsing());
it('parses a custom number of bytes', function (string $json, array $parsed) {
expect(JsonParser::parse($json)->bytes(1024))->toParseTo($parsed);
})->with(Dataset::forParsing());
it('eager loads JSON into an array', function (string $json, array $parsed) {
expect(JsonParser::parse($json)->toArray())->toBe($parsed);
})->with(Dataset::forParsing());