public void Current_returns_the_var_at_the_current_position_or_null_if_position_is_outside_array() { var enumerator = new VarVec.VarVecEnumerator(CreateVarVec(1)); Assert.Null(enumerator.Current); enumerator.MoveNext(); Assert.Equal(1, enumerator.Current.Id); enumerator.MoveNext(); Assert.Null(enumerator.Current); }
/// <summary> /// Create a new enumerator for a VarVec; use a free one if its /// available; otherwise, create a new one /// </summary> /// <param name="vec"></param> /// <returns></returns> internal VarVec.VarVecEnumerator GetVarVecEnumerator(VarVec vec) { VarVec.VarVecEnumerator enumerator; if (m_disableVarVecEnumCaching || m_freeVarVecEnumerators.Count == 0) { enumerator = new VarVec.VarVecEnumerator(vec); } else { enumerator = m_freeVarVecEnumerators.Pop(); enumerator.Init(vec); } return enumerator; }
public void MoveNext_returns_true_for_true_bits_and_false_when_end_is_reached() { var enumerator = new VarVec.VarVecEnumerator(CreateVarVec(1)); Assert.True(enumerator.MoveNext()); Assert.False(enumerator.MoveNext()); }