test/path_test.cc
changeset 1202 4fd76139b69e
parent 1092 dceba191c00d
     1.1 --- a/test/path_test.cc	Sat Feb 17 23:44:15 2018 +0100
     1.2 +++ b/test/path_test.cc	Sat Feb 17 23:44:32 2018 +0100
     1.3 @@ -108,6 +108,11 @@
     1.4      checkBackAndFrontInsertablePath<ListPath<GR> >();
     1.5      checkBackInsertablePath<SimplePath<GR> >();
     1.6  
     1.7 +    checkSubscriptOperator<Path<GR> >();
     1.8 +    checkSubscriptOperator<SimplePath<GR> >();
     1.9 +    checkSubscriptOperator<StaticPath<GR> >();
    1.10 +    checkSubscriptOperator<ListPath<GR> >();
    1.11 +
    1.12      checkListPathSplitAndSplice();
    1.13    }
    1.14  
    1.15 @@ -273,6 +278,25 @@
    1.16      check(checkPath(cgr, cp), "Wrong checkPath()");
    1.17    }
    1.18  
    1.19 +  template <typename P>
    1.20 +  void checkSubscriptOperator() {
    1.21 +    SimplePath<GR> p0;
    1.22 +    p0.addBack(a1);
    1.23 +    p0.addBack(a3);
    1.24 +    p0.addBack(a2);
    1.25 +    P p = p0;
    1.26 +    check(!p.empty(), "Wrong empty()");
    1.27 +    check(p.length() == 3, "Wrong length");
    1.28 +    check(p.front() == a1, "Wrong front()");
    1.29 +    check(p.back() == a2, "Wrong back()");
    1.30 +    check(p.nth(0) == a1, "Wrong nth()");
    1.31 +    check(p.nth(1) == a3, "Wrong nth()");
    1.32 +    check(p.nth(2) == a2, "Wrong nth()");
    1.33 +    check(p[0] == a1, "Wrong operator[]");
    1.34 +    check(p[1] == a3, "Wrong operator[]");
    1.35 +    check(p[2] == a2, "Wrong operator[]");
    1.36 +  }
    1.37 +
    1.38    void checkListPathSplitAndSplice() {
    1.39  
    1.40      // Build a path with spliceFront() and spliceBack()