Run a single test case for a SELECT query.
| 141 | |
| 142 | // Run a single test case for a SELECT query. |
| 143 | void runSelectQueryTestCase( |
| 144 | const TestCaseSelectQuery& testCase, bool useTextIndex = false, |
| 145 | ad_utility::source_location l = AD_CURRENT_SOURCE_LOC()) { |
| 146 | auto cleanup = setRuntimeParameterForTest< |
| 147 | &RuntimeParameters::sparqlResultsJsonWithTime_>(false); |
| 148 | auto trace = generateLocationTrace(l, "runSelectQueryTestCase"); |
| 149 | using enum ad_utility::MediaType; |
| 150 | EXPECT_EQ( |
| 151 | runQueryStreamableResult(testCase.kg, testCase.query, tsv, useTextIndex), |
| 152 | testCase.resultTsv); |
| 153 | EXPECT_EQ( |
| 154 | runQueryStreamableResult(testCase.kg, testCase.query, csv, useTextIndex), |
| 155 | testCase.resultCsv); |
| 156 | |
| 157 | auto resultJSON = nlohmann::json::parse(runQueryStreamableResult( |
| 158 | testCase.kg, testCase.query, qleverJson, useTextIndex)); |
| 159 | // TODO<joka921> Test other members of the JSON result (e.g. the selected |
| 160 | // variables). |
| 161 | ASSERT_EQ(resultJSON["query"], testCase.query); |
| 162 | ASSERT_EQ(resultJSON["resultSizeTotal"], testCase.resultSize); |
| 163 | ASSERT_EQ(resultJSON["resultSizeExported"], testCase.resultSize); |
| 164 | EXPECT_EQ(resultJSON["res"], testCase.resultQLeverJSON); |
| 165 | |
| 166 | EXPECT_EQ(nlohmann::json::parse(runQueryStreamableResult( |
| 167 | testCase.kg, testCase.query, sparqlJson, useTextIndex)), |
| 168 | testCase.resultSparqlJSON); |
| 169 | |
| 170 | // TODO<joka921> Use this for proper testing etc. |
| 171 | auto xmlAsString = runQueryStreamableResult(testCase.kg, testCase.query, |
| 172 | sparqlXml, useTextIndex); |
| 173 | EXPECT_EQ(testCase.resultXml, xmlAsString); |
| 174 | |
| 175 | // Test the interaction of normal limit (the LIMIT of the query) and export |
| 176 | // limit (the value of the `send` parameter). |
| 177 | for (uint64_t exportLimit = 0ul; exportLimit < 4ul; ++exportLimit) { |
| 178 | auto resultJson = nlohmann::json::parse(runQueryStreamableResult( |
| 179 | testCase.kg, testCase.query, qleverJson, useTextIndex, exportLimit)); |
| 180 | ASSERT_EQ(resultJson["resultSizeTotal"], testCase.resultSize); |
| 181 | ASSERT_EQ(resultJson["resultSizeExported"], |
| 182 | std::min(exportLimit, testCase.resultSize)); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // Run a single test case for a CONSTRUCT query. |
| 187 | void runConstructQueryTestCase( |
no test coverage detected