コード例 #1
0
        validation.level(validation_criteria::validation_level::k_strict);

        cc.validation_criteria(validation);
        cc.capped(true);
        cc.size(256);
        cc.max(100);
        cc.no_padding(true);

        auto doc = cc.to_document();
        document::view doc_view{doc.view()};

        // capped field is set to true
        document::element capped{doc_view["capped"]};
        REQUIRE(capped);
        REQUIRE(capped.type() == type::k_bool);
        REQUIRE(capped.get_bool() == true);

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

        // size should be set
        document::element size{doc_view["size"]};
        REQUIRE(size);
        REQUIRE(size.type() == type::k_int32);
        REQUIRE(size.get_int32() == 256);

        // max should be set
        document::element max{doc_view["max"]};
        REQUIRE(max);
        REQUIRE(max.type() == type::k_int32);
コード例 #2
0
        validation.level(validation_criteria::validation_level::k_strict);

        auto index = builder::stream::document{} << "a" << 1 << finalize;

        cm.index(index.view(), std::chrono::seconds(10));
        cm.validation_criteria(validation);
        cm.no_padding(false);

        auto doc = cm.to_document();
        document::view doc_view{doc.view()};

        // noPadding should be set to false
        document::element padding{doc_view["noPadding"]};
        REQUIRE(padding);
        REQUIRE(padding.type() == type::k_bool);
        REQUIRE(padding.get_bool() == false);

        // 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);