forked from ad-freiburg/qlever
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IdTripleTest.cpp
64 lines (55 loc) · 1.97 KB
/
IdTripleTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2024, University of Freiburg
// Chair of Algorithms and Data Structures.
// Authors:
// 2024 Julian Mundhahs <[email protected]>
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
#include "./util/GTestHelpers.h"
#include "./util/IdTestHelpers.h"
#include "global/IdTriple.h"
using namespace ad_utility::testing;
TEST(IdTripleTest, constructors) {
const std::array<Id, 4> ids{Id::makeFromInt(42), VocabId(10),
Id::makeFromBool(false), VocabId(123)};
const std::array<Id, 2> payload{Id::makeFromDouble(3.14),
Id::makeFromBool(true)};
{
auto idTriple = IdTriple(ids);
EXPECT_THAT(idTriple,
AD_FIELD(IdTriple<>, ids_, testing::ElementsAreArray(ids)));
}
{
auto idTriple = IdTriple(ids, payload);
EXPECT_THAT(idTriple,
AD_FIELD(IdTriple<2>, ids_, testing::ElementsAreArray(ids)));
EXPECT_THAT(idTriple, AD_FIELD(IdTriple<2>, payload_,
testing::ElementsAreArray(payload)));
}
}
TEST(IdTripleTest, permute) {
auto V = VocabId;
std::array<Id, 4> ids{V(0), V(1), V(2), V(3)};
// Without a payload
{
IdTriple<0> idTriple{ids};
EXPECT_THAT(idTriple.permute({1, 0, 2}),
testing::Eq(IdTriple{std::array<Id, 4>{
VocabId(1), VocabId(0), VocabId(2), VocabId(3)}}));
}
// With a payload
{
IdTriple<2> idTriple(ids, {IntId(10), IntId(5)});
EXPECT_THAT(idTriple.permute({1, 0, 2}),
testing::Eq(IdTriple<2>(
{VocabId(1), VocabId(0), VocabId(2), VocabId(3)},
{IntId(10), IntId(5)})));
}
}
TEST(IdTripleTest, toPermutedTriple) {
{
IdTriple<0> idTriple({VocabId(0), VocabId(10), VocabId(5), VocabId(42)});
EXPECT_THAT(idTriple.toPermutedTriple(),
testing::Eq(CompressedBlockMetadata::PermutedTriple{
VocabId(0), VocabId(10), VocabId(5), VocabId(42)}));
}
}