Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Qup42 committed Feb 10, 2025
1 parent e21c5fb commit b99fdc0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
5 changes: 2 additions & 3 deletions test/DeltaTriplesCountTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ TEST(DeltaTriplesCountTest, toJson) {
TEST(DeltaTriplesCountTest, subtractOperator) {
constexpr DeltaTriplesCount count1{10, 5};
constexpr DeltaTriplesCount count2{3, 2};
constexpr DeltaTriplesCount expected{7, 3};
const DeltaTriplesCount actual = count1 - count2;
EXPECT_THAT(actual, testing::Eq(expected));
EXPECT_THAT(count1 - count2, testing::Eq(DeltaTriplesCount{7, 3}));
EXPECT_THAT(count2 - count1, testing::Eq(DeltaTriplesCount{-7, -3}));
}
2 changes: 1 addition & 1 deletion test/DeltaTriplesTestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ inline auto NumTriplesInAllPermutations =
// `getCounts()` of a `DeltaTriples` and `numTriples()` for all
// `LocatedTriplesPerBlock` of the `DeltaTriples`.
inline auto NumTriples =
[](size_t inserted, size_t deleted,
[](int64_t inserted, int64_t deleted,
size_t inAllPermutations) -> testing::Matcher<const DeltaTriples&> {
return testing::AllOf(
AD_PROPERTY(DeltaTriples, numInserted, testing::Eq(inserted)),
Expand Down
24 changes: 13 additions & 11 deletions test/ExecuteUpdateTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ TEST(ExecuteUpdate, executeUpdate) {
auto expectExecuteUpdate =
[&index, &expectExecuteUpdateHelper](
const std::string& update,
const testing::Matcher<const DeltaTriples&>& deltaTriplesMatcher) {
const testing::Matcher<const DeltaTriples&>& deltaTriplesMatcher,
source_location sourceLocation = source_location::current()) {
auto l = generateLocationTrace(sourceLocation);
DeltaTriples deltaTriples{index};
expectExecuteUpdateHelper(update, deltaTriples);
EXPECT_THAT(deltaTriples, deltaTriplesMatcher);
Expand Down Expand Up @@ -127,7 +129,9 @@ TEST(ExecuteUpdate, computeGraphUpdateQuads) {
[&executeComputeGraphUpdateQuads](
const std::string& update,
const Matcher<const std::vector<::IdTriple<>>&>& toInsertMatcher,
const Matcher<const std::vector<::IdTriple<>>&>& toDeleteMatcher) {
const Matcher<const std::vector<::IdTriple<>>&>& toDeleteMatcher,
source_location sourceLocation = source_location::current()) {
auto l = generateLocationTrace(sourceLocation);
EXPECT_THAT(executeComputeGraphUpdateQuads(update),
Pair(AD_FIELD(ExecuteUpdate::IdTriplesAndLocalVocab,
idTriples_, toInsertMatcher),
Expand All @@ -137,7 +141,9 @@ TEST(ExecuteUpdate, computeGraphUpdateQuads) {
auto expectComputeGraphUpdateQuadsFails =
[&executeComputeGraphUpdateQuads](
const std::string& update,
const Matcher<const std::string&>& messageMatcher) {
const Matcher<const std::string&>& messageMatcher,
source_location sourceLocation = source_location::current()) {
auto l = generateLocationTrace(sourceLocation);
AD_EXPECT_THROW_WITH_MESSAGE(executeComputeGraphUpdateQuads(update),
messageMatcher);
};
Expand All @@ -151,22 +157,18 @@ TEST(ExecuteUpdate, computeGraphUpdateQuads) {
ElementsAreArray({IdTriple(Id("<z>"), Id("<label>"), Id("\"zz\"@en"))}));
expectComputeGraphUpdateQuads(
"DELETE { ?s <is-a> ?o } INSERT { <s> <p> <o> } WHERE { ?s <is-a> ?o }",
ElementsAreArray({IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>")),
IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>"))}),
ElementsAreArray({IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>"))}),
ElementsAreArray({IdTriple(Id("<x>"), Id("<is-a>"), Id("<y>")),
IdTriple(Id("<y>"), Id("<is-a>"), Id("<x>"))}));
expectComputeGraphUpdateQuads(
"DELETE { <s> <p> <o> } INSERT { <s> <p> <o> } WHERE { ?s <is-a> ?o }",
ElementsAreArray({IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>")),
IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>"))}),
ElementsAreArray({IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>")),
IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>"))}));
ElementsAreArray({IdTriple(LVI("<s>"), LVI("<p>"), LVI("<o>"))}),
IsEmpty());
expectComputeGraphUpdateQuads(
"DELETE { ?s <is-a> ?o } INSERT { ?s <is-a> ?o } WHERE { ?s <is-a> ?o }",
ElementsAreArray({IdTriple(Id("<x>"), Id("<is-a>"), Id("<y>")),
IdTriple(Id("<y>"), Id("<is-a>"), Id("<x>"))}),
ElementsAreArray({IdTriple(Id("<x>"), Id("<is-a>"), Id("<y>")),
IdTriple(Id("<y>"), Id("<is-a>"), Id("<x>"))}));
IsEmpty());
expectComputeGraphUpdateQuads(
"DELETE WHERE { ?s ?p ?o }", IsEmpty(),
UnorderedElementsAreArray(
Expand Down
3 changes: 2 additions & 1 deletion test/ServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ TEST(ServerTest, createResponseMetadata) {
json deltaTriplesJson{
{"before", {{"inserted", 0}, {"deleted", 0}, {"total", 0}}},
{"after", {{"inserted", 1}, {"deleted", 0}, {"total", 1}}},
{"difference", {{"inserted", 1}, {"deleted", 0}, {"total", 1}}}};
{"difference", {{"inserted", 1}, {"deleted", 0}, {"total", 1}}},
{"operation", {{"inserted", 1}, {"deleted", 0}, {"total", 1}}}};
json locatedTriplesJson{
{"SPO", {{"blocks-affected", 1}, {"blocks-total", 1}}},
{"POS", {{"blocks-affected", 1}, {"blocks-total", 1}}},
Expand Down

0 comments on commit b99fdc0

Please sign in to comment.