Esempio n. 1
0
    TEST(WriteConcern, NodesString) {
        BSONObj result;
        WriteConcern wc;

        wc.nodes(3);
        ASSERT_FALSE(wc.hasMode());
        ASSERT_EQUALS(wc.nodes(), 3);
        result = wc.obj();
        ASSERT_TRUE(result.hasField("w"));
        ASSERT_EQUALS(result["w"].Int(), 3);

        wc.mode(WriteConcern::kMajority);
        ASSERT_TRUE(wc.hasMode());
        ASSERT_EQUALS(wc.mode(), string(WriteConcern::kMajority));
        result = wc.obj();
        ASSERT_TRUE(result.hasField("w"));
        ASSERT_EQUALS(result["w"].String(), string(WriteConcern::kMajority));

        wc.nodes(5);
        ASSERT_FALSE(wc.hasMode());
        ASSERT_EQUALS(wc.nodes(), 5);
        result = wc.obj();
        ASSERT_TRUE(result.hasField("w"));
        ASSERT_EQUALS(result["w"].Int(), 5);
    }
Esempio n. 2
0
    TEST(WriteConcern, DefaultToBSON) {
        BSONObj result;

        WriteConcern wc;
        ASSERT_EQUALS(wc.nodes(), 1);
        result = wc.obj();
        ASSERT_FALSE(result.hasField("w"));
        ASSERT_FALSE(result.hasField("j"));
        ASSERT_FALSE(result.hasField("fsync"));
        ASSERT_FALSE(result.hasField("wtimeout"));
    }