shouldBeEqualJSON

Used to assert that JSON object is equal.

void
shouldBeEqualJSON
(
in string actual
,
in string expected
,
in string message = null
,
in string file = __FILE__
,
in size_t line = __LINE__
)

Parameters

actual
Type: string

The actual JSON object.

expected
Type: string

The excpected JSON.

message
Type: string

Exception message.

file
Type: string

The file name that the assert failed in. Should be left as default.

line
Type: size_t

The file line that the assert failed in. Should be left as default.

Throws

If an JSON objects is not equal, will throw an UnitTestException.

Examples

1 // Will throw an exception like "UnitTestException@example.d(6): Error parsing JSON: Unexpected end of data. (Line 1:10)"
2 `{"test" :1`.shouldBeEqualJSON(`{"test":1}`);
3 
4 // Will throw an exception like "UnitTestException@example.d(6):`{"test" :1, "some" : "12"}`.shouldBeEqualJSON(`{"test":1}`);
5 `{"test" :1, "some" : "12"}`.shouldBeEqualJSON(`{"test":1}`);

Meta