コード例 #1
0
ファイル: SqlBooleanTest.cs プロジェクト: z77ma/runtime
        public void Or()
        {
            SqlBoolean sqlTrue2  = new SqlBoolean(true);
            SqlBoolean sqlFalse2 = new SqlBoolean(false);

            SqlBoolean sqlResult;

            // true || false
            sqlResult = SqlBoolean.Or(_sqlTrue, _sqlFalse);
            Assert.True(sqlResult.Value);
            sqlResult = SqlBoolean.Or(_sqlFalse, _sqlTrue);
            Assert.True(sqlResult.Value);

            // true || true
            sqlResult = SqlBoolean.Or(_sqlTrue, _sqlTrue);
            Assert.True(sqlResult.Value);
            sqlResult = SqlBoolean.Or(_sqlTrue, sqlTrue2);
            Assert.True(sqlResult.Value);

            // false || false
            sqlResult = SqlBoolean.Or(_sqlFalse, _sqlFalse);
            Assert.False(sqlResult.Value);
            sqlResult = SqlBoolean.Or(_sqlFalse, sqlFalse2);
            Assert.False(sqlResult.Value);
        }
コード例 #2
0
        public void Or()
        {
            SqlBoolean SqlTrue2  = new SqlBoolean(true);
            SqlBoolean SqlFalse2 = new SqlBoolean(false);

            SqlBoolean SqlResult;

            // true || false
            SqlResult = SqlBoolean.Or(SqlTrue, SqlFalse);
            Assert.IsTrue(SqlResult.Value, "Or method does not work correctly (true || false)");
            SqlResult = SqlBoolean.Or(SqlFalse, SqlTrue);
            Assert.IsTrue(SqlResult.Value, "Or method does not work correctly (false || true)");

            // true || true
            SqlResult = SqlBoolean.Or(SqlTrue, SqlTrue);
            Assert.IsTrue(SqlResult.Value, "Or method does not work correctly (true || true)");
            SqlResult = SqlBoolean.Or(SqlTrue, SqlTrue2);
            Assert.IsTrue(SqlResult.Value, "Or method does not work correctly (true || true2)");

            // false || false
            SqlResult = SqlBoolean.Or(SqlFalse, SqlFalse);
            Assert.IsTrue(!SqlResult.Value, "Or method does not work correctly (false || false)");
            SqlResult = SqlBoolean.Or(SqlFalse, SqlFalse2);
            Assert.IsTrue(!SqlResult.Value, "Or method does not work correctly (false || false2)");
        }
コード例 #3
0
        override public Object Aggregate(int[] records, AggregateType kind)
        {
            bool hasData = false;

            try {
                switch (kind)
                {
                case AggregateType.Min:
                    SqlBoolean min = true;
                    for (int i = 0; i < records.Length; i++)
                    {
                        int record = records[i];
                        if (IsNull(record))
                        {
                            continue;
                        }
                        min     = SqlBoolean.And(values[record], min);
                        hasData = true;
                    }
                    if (hasData)
                    {
                        return(min);
                    }
                    return(NullValue);

                case AggregateType.Max:
                    SqlBoolean max = false;
                    for (int i = 0; i < records.Length; i++)
                    {
                        int record = records[i];
                        if (IsNull(record))
                        {
                            continue;
                        }
                        max     = SqlBoolean.Or(values[record], max);
                        hasData = true;
                    }
                    if (hasData)
                    {
                        return(max);
                    }
                    return(NullValue);

                case AggregateType.First:
                    if (records.Length > 0)
                    {
                        return(values[records[0]]);
                    }
                    return(NullValue);

                case AggregateType.Count:
                    int count = 0;
                    for (int i = 0; i < records.Length; i++)
                    {
                        if (!IsNull(records[i]))
                        {
                            count++;
                        }
                    }
                    return(count);
                }
            }
            catch (OverflowException) {
                throw ExprException.Overflow(typeof(SqlBoolean));
            }
            throw ExceptionBuilder.AggregateException(kind, DataType);
        }
コード例 #4
0
        public override object Aggregate(int[] records, AggregateType kind)
        {
            bool flag = false;

            try
            {
                int        num;
                int        num2;
                int        num3;
                int        num4;
                SqlBoolean flag2;
                SqlBoolean flag3;
                int        num5;
                int        num6;
                switch (kind)
                {
                case AggregateType.Min:
                    flag3 = 1;
                    num3  = 0;
                    goto Label_0061;

                case AggregateType.Max:
                    flag2 = 0;
                    num2  = 0;
                    goto Label_00C1;

                case AggregateType.First:
                    if (records.Length <= 0)
                    {
                        return(base.NullValue);
                    }
                    return(this.values[records[0]]);

                case AggregateType.Count:
                    num4 = 0;
                    num  = 0;
                    goto Label_012A;

                default:
                    goto Label_014F;
                }
Label_0030:
                num6 = records[num3];
                if (!this.IsNull(num6))
                {
                    flag3 = SqlBoolean.And(this.values[num6], flag3);
                    flag  = true;
                }
                num3++;
Label_0061:
                if (num3 < records.Length)
                {
                    goto Label_0030;
                }
                if (flag)
                {
                    return(flag3);
                }
                return(base.NullValue);

Label_0090:
                num5 = records[num2];
                if (!this.IsNull(num5))
                {
                    flag2 = SqlBoolean.Or(this.values[num5], flag2);
                    flag  = true;
                }
                num2++;
Label_00C1:
                if (num2 < records.Length)
                {
                    goto Label_0090;
                }
                if (flag)
                {
                    return(flag2);
                }
                return(base.NullValue);

Label_0115:
                if (!this.IsNull(records[num]))
                {
                    num4++;
                }
                num++;
Label_012A:
                if (num < records.Length)
                {
                    goto Label_0115;
                }
                return(num4);
            }
            catch (OverflowException)
            {
                throw ExprException.Overflow(typeof(SqlBoolean));
            }
Label_014F:
            throw ExceptionBuilder.AggregateException(kind, base.DataType);
        }