public void TestInBound() { // int //[6,5,4) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(5, ArgName, 4, 6)); //[5,6,4) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(6, ArgName, 4, 5)); //[4,6,5) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(6, ArgName, 5, 4)); //[6,4,5) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(4, ArgName, 5, 6)); //[4,5,6) Assert.DoesNotThrow(() => ArgChk.InBound(5, ArgName, 6, 4)); //[5,4,6) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(4, ArgName, 6, 5)); //[0,-1,1) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(-1, ArgName, 1)); //[0,1,-1) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(1, ArgName, -1)); //[0,0,0) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(0, ArgName, 0)); //[0,0,0) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(0, ArgName, 0)); //[0,1,2) Assert.DoesNotThrow(() => ArgChk.InBound(1, ArgName, 2)); //[0,1,1) Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(1, ArgName, 1)); // collection var col3 = new Collection <int> { 1, 2, 3 }; Assert.DoesNotThrow(() => ArgChk.InBound(0, ArgName, col3)); Assert.DoesNotThrow(() => ArgChk.InBound(2, ArgName, col3)); Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(-1, ArgName, col3)); Assert.Throws <ArgumentOutOfRangeException>(() => ArgChk.InBound(3, ArgName, col3)); }
internal IConvertible Arg([NotNull] IToken token, int idx) { ArgChk.NotNull(token, nameof(token)); ArgChk.InBound(idx, nameof(idx), token.Children); return(EvalToken(token.Children[idx])); }