Ejemplo n.º 1
0
TEST(DataSetCoreTest, RemoveFilters)
{
    DataSet dataset;
    EXPECT_EQ(0, dataset.Filters().Size());

    Filter filter;
    filter.Properties().Add(Property("rq", "0.85", ">"));
    filter.Properties().Add(Property("RNAME", "chr1", "=="));
    EXPECT_EQ(2, filter.Properties().Size());

    Filter filter2;
    filter2.Properties().Add(Property("rq", "0.50", ">="));
    filter2.Properties().Add(Property("RNAME", "chr2", "!="));
    EXPECT_EQ(2, filter2.Properties().Size());

    dataset.Filters().Add(filter);
    dataset.Filters().Add(filter2);
    EXPECT_EQ(2, dataset.Filters().Size());

    // remove
    dataset.Filters().Remove(filter);
    EXPECT_EQ(1, dataset.Filters().Size());

    const Filters& filters = dataset.Filters();
    EXPECT_EQ(2, filters[0].Properties().Size());
}
Ejemplo n.º 2
0
TEST(DataSetCoreTest, EditFilters)
{
    DataSet dataset;
    EXPECT_EQ(0, dataset.Filters().Size());

    Filter filter;
    filter.Properties().Add(Property("rq", "0.85", ">"));
    filter.Properties().Add(Property("RNAME", "chr1", "=="));
    EXPECT_EQ(2, filter.Properties().Size());

    Filter filter2;
    filter2.Properties().Add(Property("rq", "0.50", ">="));
    filter2.Properties().Add(Property("RNAME", "chr2", "!="));
    EXPECT_EQ(2, filter2.Properties().Size());

    dataset.Filters().Add(filter);
    dataset.Filters().Add(filter2);
    EXPECT_EQ(2, dataset.Filters().Size());
    EXPECT_EQ(2, dataset.Filters()[0].Properties().Size());
    EXPECT_EQ(2, dataset.Filters()[1].Properties().Size());

    // edit property in-place
    Property& p = dataset.Filters()[0].Properties()[0];
    p.Name("someNewName");
    p.Value("someNewValue");
    p.Operator("==");

    const Property& p0 = dataset.Filters()[0].Properties()[0];
    EXPECT_EQ(string("someNewName"),  p0.Name());
    EXPECT_EQ(string("someNewValue"), p0.Value());
    EXPECT_EQ(string("=="),           p0.Operator());

    const Property& p1 = dataset.Filters()[0].Properties()[1];
    EXPECT_EQ(string("RNAME"), p1.Name());
    EXPECT_EQ(string("chr1"),  p1.Value());
    EXPECT_EQ(string("=="),    p1.Operator());

    const Property& p2 = dataset.Filters()[1].Properties()[0];
    EXPECT_EQ(string("rq"),   p2.Name());
    EXPECT_EQ(string("0.50"), p2.Value());
    EXPECT_EQ(string(">="),   p2.Operator());

    const Property& p3 = dataset.Filters()[1].Properties()[1];
    EXPECT_EQ(string("RNAME"), p3.Name());
    EXPECT_EQ(string("chr2"),  p3.Value());
    EXPECT_EQ(string("!="),    p3.Operator());
}
Ejemplo n.º 3
0
TEST(DataSetCoreTest, AddFilters)
{
    DataSet dataset;
    EXPECT_EQ(0, dataset.Filters().Size());

    Filter filter;
    filter.Properties().Add(Property("rq", "0.85", ">"));
    filter.Properties().Add(Property("RNAME", "chr1", "=="));
    EXPECT_EQ(2, filter.Properties().Size());

    Filter filter2;
    filter2.Properties().Add(Property("rq", "0.50", ">="));
    filter2.Properties().Add(Property("RNAME", "chr2", "!="));
    EXPECT_EQ(2, filter2.Properties().Size());

    dataset.Filters().Add(filter);
    dataset.Filters().Add(filter2);

    const Filters& filters = dataset.Filters();
    EXPECT_EQ(2, filters.Size());
    EXPECT_EQ(2, filters[0].Properties().Size());
    EXPECT_EQ(2, filters[1].Properties().Size());

    // direct access
    const Property& p0 = filters[0].Properties()[0];
    EXPECT_EQ(string("rq"),   p0.Name());
    EXPECT_EQ(string("0.85"), p0.Value());
    EXPECT_EQ(string(">"),    p0.Operator());

    const Property& p1 = filters[0].Properties()[1];
    EXPECT_EQ(string("RNAME"), p1.Name());
    EXPECT_EQ(string("chr1"),  p1.Value());
    EXPECT_EQ(string("=="),    p1.Operator());

    const Property& p2 = filters[1].Properties()[0];
    EXPECT_EQ(string("rq"),   p2.Name());
    EXPECT_EQ(string("0.50"), p2.Value());
    EXPECT_EQ(string(">="),   p2.Operator());

    const Property& p3 = filters[1].Properties()[1];
    EXPECT_EQ(string("RNAME"), p3.Name());
    EXPECT_EQ(string("chr2"),  p3.Value());
    EXPECT_EQ(string("!="),    p3.Operator());

    // iteratable
    size_t i = 0;
    size_t j = 0;
    for (const Filter& f : filters) {
        if (i == 0) {
            const Properties& properties = f.Properties();
            for (const Property& p : properties) {
                if (j == 0) {
                    EXPECT_EQ(string("rq"),   p.Name());
                    EXPECT_EQ(string("0.85"), p.Value());
                    EXPECT_EQ(string(">"),    p.Operator());
                } else {
                    EXPECT_EQ(string("RNAME"), p.Name());
                    EXPECT_EQ(string("chr1"),  p.Value());
                    EXPECT_EQ(string("=="),    p.Operator());
                }
                ++j;
            }
        } else {
            const Properties& properties = f.Properties();
            for (const Property& p : properties) {
                if (j == 0) {
                    EXPECT_EQ(string("rq"),   p.Name());
                    EXPECT_EQ(string("0.50"), p.Value());
                    EXPECT_EQ(string(">="),   p.Operator());
                } else {
                    EXPECT_EQ(string("RNAME"), p.Name());
                    EXPECT_EQ(string("chr2"),  p.Value());
                    EXPECT_EQ(string("!="),    p.Operator());
                }
                ++j;
            }
        }
        ++i;
        j = 0;
    }

}