-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests and inevitably fix the bugs that those tests discovered.
- Loading branch information
Showing
16 changed files
with
163 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,7 @@ | |
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
|
||
#ifndef QLEVER_CARTESIANPRODUCTJOIN_H | ||
#define QLEVER_CARTESIANPRODUCTJOIN_H | ||
|
||
#pragma once | ||
#include "engine/Operation.h" | ||
#include "engine/QueryExecutionTree.h" | ||
|
||
|
@@ -92,5 +90,3 @@ class CartesianProductJoin : public Operation { | |
std::span<const Id> inputColumn, size_t groupSize, | ||
size_t offset); | ||
}; | ||
|
||
#endif // QLEVER_CARTESIANPRODUCTJOIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2021, University of Freiburg, Chair of Algorithms and Data | ||
/// Copyright 2021, University of Freiburg, Chair of Algorithms and Data | ||
// Structures. Author: Johannes Kalmbach <[email protected]> | ||
|
||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2024, University of Freiburg, | ||
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include "../util/GTestHelpers.h" | ||
#include "../util/IndexTestHelpers.h" | ||
#include "engine/ScanSpecification.h" | ||
|
||
// _____________________________________________________________________________ | ||
TEST(ScanSpecification, validate) { | ||
Id i = Id::makeFromInt(42); | ||
auto n = std::nullopt; | ||
using S = ScanSpecification; | ||
EXPECT_NO_THROW(S(i, i, i)); | ||
EXPECT_NO_THROW(S(i, i, n)); | ||
EXPECT_NO_THROW(S(i, n, n)); | ||
EXPECT_NO_THROW(S(n, n, n)); | ||
|
||
EXPECT_ANY_THROW(S(n, i, i)); | ||
EXPECT_ANY_THROW(S(n, n, i)); | ||
EXPECT_ANY_THROW(S(n, i, n)); | ||
EXPECT_ANY_THROW(S(i, n, i)); | ||
} | ||
|
||
// _____________________________________________________________________________ | ||
TEST(ScanSpecification, ScanSpecificationAsTripleComponent) { | ||
Id i = Id::makeFromInt(42); | ||
TripleComponent iTc{42}; | ||
auto n = std::nullopt; | ||
using S = ScanSpecification; | ||
using STc = ScanSpecificationAsTripleComponent; | ||
|
||
EXPECT_ANY_THROW(STc(n, iTc, iTc)); | ||
EXPECT_ANY_THROW(STc(n, n, iTc)); | ||
EXPECT_ANY_THROW(STc(n, iTc, n)); | ||
EXPECT_ANY_THROW(STc(iTc, n, iTc)); | ||
|
||
const auto& index = ad_utility::testing::getQec()->getIndex(); | ||
auto toScanSpec = [&index](const STc& s) { | ||
return s.toScanSpecification(index); | ||
}; | ||
|
||
// Match that a `ScanSpecificationAsTripleComponent` has the expected number | ||
// of columns, and yields the expected `ScanSpecification` when | ||
// `toScanSpecification` is called on it. | ||
auto matchScanSpec = | ||
[&toScanSpec](const std::optional<ScanSpecification> spec, | ||
size_t numColumns = 0) -> ::testing::Matcher<const STc&> { | ||
auto innerMatcher = [&toScanSpec, &spec] { | ||
return ::testing::ResultOf(toScanSpec, ::testing::Eq(spec)); | ||
}; | ||
if (!spec.has_value()) { | ||
return innerMatcher(); | ||
} else { | ||
return ::testing::AllOf( | ||
innerMatcher(), | ||
AD_PROPERTY(STc, numColumns, ::testing::Eq(numColumns))); | ||
} | ||
}; | ||
EXPECT_THAT(STc(iTc, iTc, iTc), matchScanSpec(S(i, i, i), 0)); | ||
EXPECT_THAT(STc(iTc, iTc, n), matchScanSpec(S(i, i, n), 1)); | ||
EXPECT_THAT(STc(iTc, n, n), matchScanSpec(S(i, n, n), 2)); | ||
EXPECT_THAT(STc(n, n, n), matchScanSpec(S(n, n, n), 3)); | ||
|
||
// Test the resolution of vocab entries. | ||
auto getId = ad_utility::testing::makeGetId(index); | ||
auto x = getId("<x>"); | ||
TripleComponent xIri = TripleComponent::Iri::fromIriref("<x>"); | ||
|
||
EXPECT_THAT(STc(xIri, xIri, xIri), matchScanSpec(S(x, x, x), 0)); | ||
|
||
// For an entry that is not in the vocabulary, the complete result of | ||
// `toScanSpecification` is `nullopt`. | ||
TripleComponent notInVocab = | ||
TripleComponent::Iri::fromIriref("<thisIriIsNotContained>"); | ||
EXPECT_THAT(STc(notInVocab, xIri, xIri), matchScanSpec(std::nullopt)); | ||
EXPECT_THAT(STc(xIri, notInVocab, xIri), matchScanSpec(std::nullopt)); | ||
EXPECT_THAT(STc(xIri, xIri, notInVocab), matchScanSpec(std::nullopt)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters