document::element max{doc_view["max"]};
        REQUIRE(max);
        REQUIRE(max.type() == type::k_int32);
        REQUIRE(max.get_int32() == 100);

        // flags should be set to 0x10
        document::element padding{doc_view["flags"]};
        REQUIRE(padding);
        REQUIRE(padding.type() == type::k_int32);
        REQUIRE(padding.get_int32() == 0x10);

        // storageEngine should not be set
        document::element engine{doc_view["storageEngine"]};
        REQUIRE(!engine);

        // validator and validationLevel should be set, but not validationAction
        document::element validator{doc_view["validator"]};
        REQUIRE(validator);
        REQUIRE(validator.type() == type::k_document);
        REQUIRE(validator.get_document().value == rule);

        document::element validationLevel{doc_view["validationLevel"]};
        REQUIRE(validationLevel);
        REQUIRE(validationLevel.type() == type::k_utf8);
        REQUIRE(validationLevel.get_utf8().value.to_string() == "strict");

        document::element validationAction{doc_view["validationAction"]};
        REQUIRE(!validationAction);
    }
}
Пример #2
0
TEST_CASE("Hint", "[hint]") {
    SECTION("Can be constructed with index name") {
        std::string index_name = "a_1";
        hint index_hint{index_name};

        SECTION("Can be applied to a query") {
            document::value filter = builder::stream::document{}
                                     << "a" << 15
                                     << builder::stream::concatenate{index_hint.to_document()}
                                     << builder::stream::finalize;
            document::view view{filter.view()};
            document::element ele{view["hint"]};
            REQUIRE(ele);
            REQUIRE(ele.type() == type::k_utf8);
            REQUIRE(ele.get_utf8().value.to_string() == index_name);
        }

        SECTION("Compares equal to matching index name") {
            REQUIRE(index_hint == index_name);
            REQUIRE(index_name == index_hint);
        }

        SECTION("Does not equal non-matching index name") {
            REQUIRE(index_hint != "sam");
            REQUIRE("sam" != index_hint);
        }

        SECTION("Does not equal index document") {
            auto index_doc = builder::stream::document{} << "a" << 1 << builder::stream::finalize;
            REQUIRE(index_hint != index_doc);