anchor.diff:                  [
                       fun should_collate_fwd/1,
                       fun should_collate_rev/1,
  -                    fun should_collate_range/1,
  +                    fun should_collate_range_/1,
                       fun should_collate_with_inclusive_end_fwd/1,
                       fun should_collate_with_inclusive_end_rev/1,
                       fun should_collate_without_inclusive_end_fwd/1,
  
positive.code:     <<"B">>,
      <<"ba">>,
      <<"bb">>,
  
      [<<"a">>],
      [<<"b">>],
  
negative.code:     Expect = [{meta, [{total, length(?VALUES)}, {offset, 0}]}] ++ lists:reverse(rows()),
      ?_assertEquiv(Expect, Results).
  
  should_collate_range_(Db) ->
      Index = lists:zip(lists:seq(0, length(?VALUES)-1), ?VALUES),
      lists:map(fun(V) ->
          {ok, Results} = run_query(Db, [{start_key, V}, {end_key, V}]),
          Expect = [
              {meta, [{total, length(?VALUES)}, find_offset(Index, V)]} |
              find_matching_rows(Index, V)
          ],
          ?_assertEquiv(Expect, Results)
      end, ?VALUES).
  
  find_offset(Index, Value) ->
      [{Offset, _} | _] = lists:dropwhile(fun({_, V}) ->
          couch_ejson_compare:less(Value, V) =/= 0
      end, Index),
      {offset, Offset}.
  
  find_matching_rows(Index, Value) ->
      Matches = lists:filter(fun({_, V}) ->
          couch_ejson_compare:less(Value, V) =:= 0
      end, Index),
      lists:map(fun({Id, V}) ->
          {row, [{id, list_to_binary(integer_to_list(Id))}, {key, V}, {value, 0}]}
      end, Matches).
  
  should_collate_with_inclusive_end_fwd(Db) ->
      Opts = [{end_key, <<"b">>}, {inclusive_end, true}],
  