Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
TestUrlParsing.cpp File Reference

Unit tests for verifying URL parsing into CURL objects. More...

#include "ServiceBroker.h"
#include "URL.h"
#include "filesystem/MultiPathDirectory.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"
#include "utils/URIUtils.h"
#include <utility>
#include <gtest/gtest.h>
#include "test/TestUtils.h"
#include "utils/JSONVariantParser.h"
#include "utils/JSONVariantWriter.h"
#include "utils/Variant.h"
#include <fstream>

Classes

class  TestURLParseDetails
 

Functions

 TEST_F (TestURLParseDetails, ParseAllURLResults)
 

Detailed Description

Unit tests for verifying URL parsing into CURL objects.

This test suite validates the correctness and robustness of Kodi's URL parsing implementation by ensuring that different types of URLs are correctly decomposed into their component parts (scheme, host, port, path, query, etc.) within CURL objects.

Overview

Each test loads URL test cases from JSON files that define the expected parse results. The tests then verify that the CURL object correctly represents each URL as expected. This provides a comprehensive regression suite to guard against changes or regressions in URL parsing logic.

Test Data

The input and expected output for these tests are stored as JSON files under xbmc/utils/test/testdata/. As there are many such test files, it is often easier to regenerate them rather than edit each file manually.

To regenerate all test case JSON files, define the following symbol before building or running the tests:

#define GENERATE_JSON_TEST_FILES

This can be defined either inline in this test file or passed via the build system when building kodi-test. When defined, executing the tests will generate updated JSON test case files in your CMake build directory.

After generation, the new JSON files should be reviewed and copied or moved into the xbmc/utils/test/testdata/ directory before committing them with your branch.

Running the Tests

These tests are part of the kodi-test suite and are executed using GoogleTest. To run all URL parsing tests:

kodi-test --gtest_filter=TestURLParseDetails.ParseAllURLResults
Definition TestUrlParsing.cpp:737
Definition addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h:21

Modifying or Adding Tests

  • To add a new test case, create or update a JSON file in the testdata directory and ensure it follows the existing format.
  • When modifying the parsing logic in Kodi, regenerate the JSON test files to reflect the new expected behavior.
  • Always run the full TestURLParseDetails suite after changes to confirm no regressions were introduced.
See also
CURL
xbmc/utils/test/testdata/

Function Documentation

◆ TEST_F()

TEST_F ( TestURLParseDetails ,
ParseAllURLResults  )