Fix tests that expect debug_assert to fail

Reviewers: buda, mferencevic

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D639
This commit is contained in:
Mislav Bradac 2017-08-07 13:53:50 +02:00
parent 2ba0f0cdea
commit 7fe799f232
7 changed files with 12 additions and 52 deletions

View File

@ -110,11 +110,11 @@ int64_t GraphDbAccessor::vertices_count(
const LabelPropertyIndex::Key key(label, property);
debug_assert(db_.label_property_index_.IndexExists(key),
"Index doesn't exist.");
debug_assert(lower || upper, "At least one bound must be provided");
debug_assert(
permanent_assert(lower || upper, "At least one bound must be provided");
permanent_assert(
!lower || lower.value().value().type() != PropertyValue::Type::Null,
"Null value is not a valid index bound");
debug_assert(
permanent_assert(
!upper || upper.value().value().type() != PropertyValue::Type::Null,
"Null value is not a valid index bound");

View File

@ -330,7 +330,8 @@ class LabelPropertyIndex {
int64_t Count(const Key &key) {
auto index = GetKeyStorage(key);
permanent_assert(index != nullptr, "Index doesn't exist.");
debug_assert(ready_for_use_.access().contains(key), "Index not yet ready.");
permanent_assert(ready_for_use_.access().contains(key),
"Index not yet ready.");
return index->access().size();
}

View File

@ -59,9 +59,6 @@ TEST_F(IntQueue, IteratorPrefixIncrement) {
auto it = cpq.begin();
EXPECT_EQ(*(++it), 1);
EXPECT_EQ(*it, 1);
++it;
++it;
EXPECT_DEATH(++it, "Prefix");
}
TEST_F(IntQueue, IteratorPostfixIncrement) {
@ -69,9 +66,6 @@ TEST_F(IntQueue, IteratorPostfixIncrement) {
auto it = cpq.begin();
EXPECT_EQ(*it++, 2);
EXPECT_EQ(*it, 1);
it++;
it++;
EXPECT_DEATH(it++, "Postfix");
}
TEST_F(IntQueue, IteratorEquality) {
@ -170,8 +164,7 @@ TEST(ConcurrentPushQueue, RvalueLvalueElements) {
std::string lvalue("lvalue");
cpq.push(lvalue);
std::vector<std::string> expected;
for (auto &elem : cpq)
expected.emplace_back(elem);
for (auto &elem : cpq) expected.emplace_back(elem);
EXPECT_THAT(expected, ::testing::ElementsAre("lvalue", "rvalue"));
}

View File

@ -78,12 +78,3 @@ TEST(DynamicBitset, ConstBitset) {
dbs.set(17);
const_accepting(dbs);
}
TEST(DynamicBitset, GroupAcrossBlockFail) {
DynamicBitset<uint8_t> db;
// groups must be aligned to block_t
db.set(8, 1);
EXPECT_DEATH(db.at(7, 2), "Invalid index");
EXPECT_DEATH(db.set(7, 2), "Invalid index");
EXPECT_DEATH(db.clear(7, 2), "Invalid index");
}

View File

@ -4,8 +4,8 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "database/graph_db_accessor.hpp"
#include "database/dbms.hpp"
#include "database/graph_db_accessor.hpp"
#include "utils/bound.hpp"
using testing::UnorderedElementsAreArray;
@ -103,8 +103,6 @@ TEST_F(GraphDbAccessorIndex, EdgeTypeCount) {
TEST_F(GraphDbAccessorIndex, LabelPropertyIndexBuild) {
AddVertex(0);
::testing::FLAGS_gtest_death_test_style = "threadsafe";
EXPECT_DEATH(dba->vertices_count(label, property), "Index doesn't exist.");
Commit();
dba->BuildIndex(label, property);

View File

@ -554,8 +554,10 @@ TEST_F(QueryPlanExpandVariable, ExistingEdges) {
TEST_F(QueryPlanExpandVariable, GraphState) {
auto test_expand = [&](GraphView graph_view) {
auto e = Edge("r", EdgeAtom::Direction::OUT);
return GetResults(AddMatch<ExpandVariable>(nullptr, "n", 0, EdgeAtom::Direction::OUT,
2, 2, e, false, "m", graph_view), e);
return GetResults(
AddMatch<ExpandVariable>(nullptr, "n", 0, EdgeAtom::Direction::OUT, 2,
2, e, false, "m", graph_view),
e);
};
EXPECT_EQ(test_expand(GraphView::OLD), (map_int{{2, 8}}));
@ -1438,15 +1440,6 @@ TEST(QueryPlan, ScanAllByLabelProperty) {
check(value_a, Bound::Type::INCLUSIVE, value_b, Bound::Type::INCLUSIVE,
{});
}
// it's not allowed to have Null as a bound, we assert against that
::testing::FLAGS_gtest_death_test_style = "threadsafe";
EXPECT_DEATH(check(TypedValue::Null, Bound::Type::INCLUSIVE, 0,
Bound::Type::INCLUSIVE, {}),
"Null value is not a valid index bound");
EXPECT_DEATH(check(0, Bound::Type::INCLUSIVE, TypedValue::Null,
Bound::Type::INCLUSIVE, {}),
"Null value is not a valid index bound");
}
TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) {

View File

@ -1,6 +1,6 @@
#include "data_structures/bitset/static_bitset.hpp"
#include <gmock/gmock.h>
#include <vector>
#include "data_structures/bitset/static_bitset.hpp"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
@ -58,22 +58,6 @@ TEST(StaticBitset, SetAndReadBit) {
EXPECT_EQ(bitset.At(3), false);
}
TEST(StaticBitset, SetOutOfRange) {
const int n = 50;
Bitset<char> bitset(n);
EXPECT_DEATH(bitset.Set(-1), "Invalid bit location.");
EXPECT_DEATH(bitset.Set(150), "Invalid bit location.");
bitset.Set(49);
}
TEST(StaticBitset, AtOutOfRange) {
const int n = 50;
Bitset<char> bitset(n);
bitset.Set(33);
EXPECT_DEATH(bitset.At(150), "Invalid bit location.");
EXPECT_DEATH(bitset.At(-1), "Invalid bit location.");
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();