mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
Tests: Fix AK/TestJSON.cpp by not relying on disk resources
The following commit broke Tests/AK/TestJSON.cpp as it removed the
file that the test loaded from disk to validate JSON parsing.
commit ad141a2286
Author: Andreas Kling <kling@serenityos.org>
Date: Sat Jul 31 15:26:14 2021 +0200
Base: Remove "test.frm" from HackStudio test project
Instead of restoring the file, lets just embed a bit of JSON in the
test case to avoid using external resources, as they obviously are
surprising and make the test less portable across environments.
This commit is contained in:
parent
05faca91d5
commit
c54ae3afd6
3 changed files with 22 additions and 17 deletions
|
@ -71,6 +71,3 @@ set(AK_TEST_SOURCES
|
||||||
foreach(source ${AK_TEST_SOURCES})
|
foreach(source ${AK_TEST_SOURCES})
|
||||||
serenity_test(${source} AK)
|
serenity_test(${source} AK)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
get_filename_component(TEST_FRM_RESOLVED ./test.frm REALPATH)
|
|
||||||
install(FILES ${TEST_FRM_RESOLVED} DESTINATION usr/Tests/AK)
|
|
||||||
|
|
|
@ -15,20 +15,29 @@
|
||||||
|
|
||||||
TEST_CASE(load_form)
|
TEST_CASE(load_form)
|
||||||
{
|
{
|
||||||
FILE* fp = fopen("test.frm", "r");
|
String raw_form_json = R"(
|
||||||
VERIFY(fp);
|
{
|
||||||
|
"name": "Form1",
|
||||||
|
"widgets": [
|
||||||
|
{
|
||||||
|
"enabled": true,
|
||||||
|
"forecolor": "#000000ff",
|
||||||
|
"ruler_visible": false,
|
||||||
|
"autofill": false,
|
||||||
|
"x": 155,
|
||||||
|
"tooltip": null,
|
||||||
|
"height": 121,
|
||||||
|
"width": 126,
|
||||||
|
"y": 10,
|
||||||
|
"class": "GTextEditor",
|
||||||
|
"text": "Hi",
|
||||||
|
"backcolor": "#c0c0c0ff",
|
||||||
|
"visible":true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})";
|
||||||
|
|
||||||
StringBuilder builder;
|
JsonValue form_json = JsonValue::from_string(raw_form_json).value();
|
||||||
for (;;) {
|
|
||||||
char buffer[1024];
|
|
||||||
if (!fgets(buffer, sizeof(buffer), fp))
|
|
||||||
break;
|
|
||||||
builder.append(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
JsonValue form_json = JsonValue::from_string(builder.to_string()).value();
|
|
||||||
|
|
||||||
EXPECT(form_json.is_object());
|
EXPECT(form_json.is_object());
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../Base/home/anon/Source/little/test.frm
|
|
Loading…
Add table
Add a link
Reference in a new issue