Example #1
0
void test_sscan(client &c) {
    c.flushdb();
    std::set<std::string> expected;
    for (int i=42; i<442; i++) {
        std::string k("key");
        k+=boost::lexical_cast<std::string>(i);
        c.sadd("myset", {k});
        expected.insert(k);
    }

    std::set<std::string> keys;
    for(auto i=c.sscan("myset"); i!=c.end(); ++i) {
        keys.insert(*i);
    }
    assert(keys==expected);
}
Example #2
0
void test_zscan(client &c) {
    c.flushdb();
    std::set<std::string> expected;
    for (int i=42; i<442; i++) {
        std::string k("key");
        k+=boost::lexical_cast<std::string>(i);
        c.zadd("myzset", {{1.2, k}});
        expected.insert(k);
    }

    std::set<std::string> keys;
    for(auto i=c.zscan("myzset"); i!=c.end(); ++i) {
        keys.insert(*i);
        assert(i.score()==1.2);
    }
    assert(keys==expected);
}
Example #3
0
void test_hscan(client &c) {
    c.flushdb();
    std::set<std::string> expected;
    for (int i=42; i<442; i++) {
        std::string k("key");
        k+=boost::lexical_cast<std::string>(i);
        std::string v("key");
        v+=boost::lexical_cast<std::string>(i);
        c.hset("myhash", k, v);
        expected.insert(k);
    }

    std::set<std::string> keys;
    for(auto i=c.hscan("myhash"); i!=c.end(); ++i) {
        keys.insert(*i);
    }
    assert(keys==expected);
}