Commit e844254f authored by Giorgio Azzinnaro's avatar Giorgio Azzinnaro

message as key test; protobuf test definitions

parent 26591fc4
......@@ -51,7 +51,9 @@ struct Format
MessageTreeNode tree = marshaller->Marshal(message); \
BOOST_TEST_MESSAGE(tree.DebugString());
BOOST_FIXTURE_TEST_CASE(int_key, Format)
BOOST_FIXTURE_TEST_SUITE(marshal, Format)
BOOST_AUTO_TEST_CASE(int_key)
{
schema::KeyInt message;
message.set_int_key(17526); // TODO Should be random
......@@ -61,7 +63,7 @@ BOOST_FIXTURE_TEST_CASE(int_key, Format)
BOOST_TEST(std::to_string(message.int_key()) == tree.message().key().value());
}
BOOST_FIXTURE_TEST_CASE(string_key, Format)
BOOST_AUTO_TEST_CASE(string_key)
{
schema::KeyStr message;
message.set_string_key("hp9gh3bv3wgqq"); // TODO Should be random
......@@ -71,7 +73,7 @@ BOOST_FIXTURE_TEST_CASE(string_key, Format)
BOOST_TEST(message.string_key() == tree.message().key().value());
}
BOOST_FIXTURE_TEST_CASE(repeated_int_key, Format)
BOOST_AUTO_TEST_CASE(repeated_int_key)
{
schema::RepeatedKeyInt message;
message.add_int_key_repeated(29813);
......@@ -79,9 +81,11 @@ BOOST_FIXTURE_TEST_CASE(repeated_int_key, Format)
message.add_int_key_repeated(8746);
DEBUG_MESSAGE
BOOST_TEST("$29813$465560$8746" == tree.message().key().value());
}
BOOST_FIXTURE_TEST_CASE(nonkeyable_nested, Format)
BOOST_AUTO_TEST_CASE(nonkeyable_nested)
{
schema::NonKeyableNested message;
message.set_int_key(98125489);
......@@ -90,13 +94,28 @@ BOOST_FIXTURE_TEST_CASE(nonkeyable_nested, Format)
DEBUG_MESSAGE
}
BOOST_FIXTURE_TEST_CASE(keyable_nested, Format)
BOOST_AUTO_TEST_CASE(keyable_nested)
{
schema::KeyableNested message;
message.set_str_key("oht24oh24t");
message.mutable_nested_keyable()->set_int_key(11290142);
DEBUG_MESSAGE
BOOST_TEST("11290142" == tree.children()[0].message().key().value());
}
BOOST_AUTO_TEST_CASE(message_as_key)
{
schema::MessageAsKey message;
message.mutable_message_key()->set_int_(12985433);
message.mutable_message_key()->set_str("42ò3r2");
message.mutable_message_key()->set_boolean(true);
DEBUG_MESSAGE
BOOST_TEST(message.message_key().SerializeAsString() == tree.message().key().value());
}
BOOST_AUTO_TEST_SUITE_END()
#undef DEBUG_MESSAGE
......@@ -6,18 +6,22 @@ import "profanedb/protobuf/options.proto";
import "nested.proto";
// Simply check that key is serialized properly
message KeyInt {
int32 int_key = 1 [ (profanedb.protobuf.options).key = true ];
}
// Key should match the provided value
message KeyStr {
string string_key = 1 [ (profanedb.protobuf.options).key = true ];
}
// Check repeated key with separator
message RepeatedKeyInt {
repeated int32 int_key_repeated = 1 [ (profanedb.protobuf.options).key = true ];
}
// The nested message shouldn't appear in the MessageTree
message NonKeyableNested {
int32 int_key = 1 [ (profanedb.protobuf.options).key = true ];
......@@ -27,8 +31,52 @@ message NonKeyableNested {
Nested nested_nonkeyable_message = 2;
}
// `nested_keyable` should be in root MessageTree children
message KeyableNested {
string str_key = 1;
string str_key = 1 [ (profanedb.protobuf.options).key = true ];
KeyInt nested_keyable = 2;
}
// TODO A Key can also be a message
message MessageAsKey {
message MyKeyObj {
int32 int = 1;
string str = 2;
bool boolean = 3;
}
MyKeyObj message_key = 1 [ (profanedb.protobuf.options).key = true ];
}
// TODO `nested_nonkeyable.nested_keyable` Key should appear in MessageTree
message KeyableInNonkeyableNested {
string str_key = 1 [ (profanedb.protobuf.options).key = true ];
message NonkeyableNested {
message KeyableNested {
int64 int_key = 1;
}
KeyableNested nested_keyable = 1;
}
NonkeyableNested nested_nonkeyable = 2;
}
// TODO This is to test collisions with repeated Key separator (currently $)
message RepeatedKeyStr {
repeated string int_key_repeated = 1 [ (profanedb.protobuf.options).key = true ];
}
// TODO Avoid circular recursion,
// multiple occurrencies when writing,
// infinite loop when reading
message RecursionParent {
int32 int_key = 1 [ (profanedb.protobuf.options).key = true ];
repeated RecursionChild children = 2;
}
message RecursionChild {
int32 int_key = 1 [ (profanedb.protobuf.options).key = true ];
RecursionParent parent = 2;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment