mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-09 10:06:04 -05:00
Move JSON helpers to lib
This commit is contained in:
@@ -64,9 +64,14 @@ target_sources(
|
||||
|
||||
# --- json --- #
|
||||
|
||||
if(TARGET jsoncons)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE jsoncons)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE JSONPATH_SUPPORT=1)
|
||||
endif()
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC nlohmann_json::nlohmann_json)
|
||||
target_sources(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE test-json.cpp ${ADVSS_SOURCE_DIR}/plugins/base/utils/json-helpers.cpp)
|
||||
${PROJECT_NAME} PRIVATE test-json.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/json-helpers.cpp)
|
||||
|
||||
# --- math --- #
|
||||
|
||||
@@ -95,8 +100,6 @@ target_sources(
|
||||
|
||||
# --- utility --- #
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC nlohmann_json::nlohmann_json)
|
||||
|
||||
target_sources(
|
||||
${PROJECT_NAME} PRIVATE test-utility.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/utility.cpp)
|
||||
|
||||
@@ -51,3 +51,18 @@ TEST_CASE("MatchJson", "[json-helpers]")
|
||||
result = advss::MatchJson("{\n \"test\": true\n}\n", "(", regex);
|
||||
REQUIRE(result == false);
|
||||
}
|
||||
|
||||
TEST_CASE("GetJsonField", "[utility]")
|
||||
{
|
||||
auto result = advss::GetJsonField("{}", "");
|
||||
REQUIRE_FALSE(result);
|
||||
|
||||
result = advss::GetJsonField("{}", "not there");
|
||||
REQUIRE_FALSE(result);
|
||||
|
||||
result = advss::GetJsonField("invalid json", "not there");
|
||||
REQUIRE_FALSE(result);
|
||||
|
||||
result = advss::GetJsonField("{ \"test\": 1 }", "test");
|
||||
REQUIRE(*result == "1");
|
||||
}
|
||||
@@ -20,21 +20,6 @@ TEST_CASE("ReplaceAll", "[utility]")
|
||||
REQUIRE(input == "sleeping");
|
||||
}
|
||||
|
||||
TEST_CASE("GetJsonField", "[utility]")
|
||||
{
|
||||
auto result = advss::GetJsonField("{}", "");
|
||||
REQUIRE_FALSE(result);
|
||||
|
||||
result = advss::GetJsonField("{}", "not there");
|
||||
REQUIRE_FALSE(result);
|
||||
|
||||
result = advss::GetJsonField("invalid json", "not there");
|
||||
REQUIRE_FALSE(result);
|
||||
|
||||
result = advss::GetJsonField("{ \"test\": 1 }", "test");
|
||||
REQUIRE(*result == "1");
|
||||
}
|
||||
|
||||
TEST_CASE("CompareIgnoringLineEnding", "[utility]")
|
||||
{
|
||||
QString s1;
|
||||
|
||||
Reference in New Issue
Block a user