示例#1
0
        public void Parse()
        {
            try
            {
                SqlSingle.Parse(null);
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(ArgumentNullException), e.GetType());
            }

            try
            {
                SqlSingle.Parse("not-a-number");
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(FormatException), e.GetType());
            }

            try
            {
                SqlSingle.Parse("9e44");
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(OverflowException), e.GetType());
            }

            Assert.Equal(150, SqlSingle.Parse("150").Value);
        }
示例#2
0
        public void GetTypeTest()
        {
            SqlSingle Test = new SqlSingle(84);

            Assert.Equal("System.Data.SqlTypes.SqlSingle", Test.GetType().ToString());
            Assert.Equal("System.Single", Test.Value.GetType().ToString());
        }
示例#3
0
        public void GetHashCodeTest()
        {
            SqlSingle Test15 = new SqlSingle(15);

            // FIXME: Better way to test HashCode
            Assert.Equal(Test15.GetHashCode(), Test15.GetHashCode());
        }
示例#4
0
        internal static object GetSqlValueFromComVariant(object comVal)
        {
            object sqlVal = null;

            if (comVal is float)
            {
                sqlVal = new SqlSingle((float)comVal);
            }
            else if (comVal is string)
            {
                sqlVal = new SqlString((string)comVal);
            }
            else if (comVal is double)
            {
                sqlVal = new SqlDouble((double)comVal);
            }
            else if (comVal is System.Byte[])
            {
                sqlVal = new SqlBinary((byte[])comVal);
            }
            else if (comVal is System.Guid)
            {
                sqlVal = new SqlGuid((Guid)comVal);
            }
            else if (comVal is bool)
            {
                sqlVal = new SqlBoolean((bool)comVal);
            }
            else if (comVal is byte)
            {
                sqlVal = new SqlByte((byte)comVal);
            }
            else if (comVal is Int16)
            {
                sqlVal = new SqlInt16((Int16)comVal);
            }
            else if (comVal is Int32)
            {
                sqlVal = new SqlInt32((Int32)comVal);
            }
            else if (comVal is Int64)
            {
                sqlVal = new SqlInt64((Int64)comVal);
            }
            else if (comVal is Decimal)
            {
                sqlVal = new SqlDecimal((Decimal)comVal);
            }
            else if (comVal is DateTime)
            {
                sqlVal = new SqlDateTime((DateTime)comVal);
            }
            else
            {
                Debug.Assert(false, "unknown SqlType class stored in sqlVal");
            }

            return(sqlVal);
        }
示例#5
0
 public SqlSingle Adjust(SqlSingle value)
 {
     if (type != typeof(Single))
     {
         throw new ArgumentException("Value does not match the SqlMetaData type");
     }
     return(value);
 }
示例#6
0
        public void SqlSingleToSqlDecimal()
        {
            SqlSingle test = new SqlSingle(1E+9);

            Assert.Equal(1000000000m, ((SqlDecimal)test).Value);

            Assert.Throws <OverflowException>(() => (SqlDecimal)SqlSingle.MaxValue);
        }
示例#7
0
 public void ConversionSingleOverflowException()
 {
     Assert.Throws <OverflowException>(() =>
     {
         SqlString String9E300 = new SqlString("9E+300");
         SqlSingle test        = String9E300.ToSqlSingle().Value;
     });
 }
示例#8
0
        public void GetSqlSingle()
        {
            HsqlDataReader testSubject = NewTestSubject();

            SqlSingle actual = testSubject.GetSqlSingle(ColumnOrdinalFor.Real);

            Assert.Fail("TODO");
        }
示例#9
0
        public void SqlSingleToSqlByte()
        {
            SqlSingle testSingle64  = new SqlSingle(64);
            SqlSingle testSingle900 = new SqlSingle(900);

            Assert.Equal((byte)64, ((SqlByte)testSingle64).Value);
            Assert.Throws <OverflowException>(() => (SqlByte)testSingle900);
        }
示例#10
0
文件: SGCalc.cs 项目: andreyV512/rag
    static public void ExecFill(object _result, out SqlInt32 _par, out SqlSingle _val, out SqlString _msg)
    {
        Result r = _result as Result;

        _par = r.par;
        _val = Convert.ToSingle(r.val);
        _msg = r.msg;
    }
示例#11
0
 public Employee(int id, string name, string surname, string city, SqlSingle salary)
 {
     this.id      = id;
     this.name    = name;
     this.surname = surname;
     this.city    = city;
     this.salary  = salary;
 }
示例#12
0
        public void ArithmeticMethods()
        {
            SqlSingle Test0   = new SqlSingle(0);
            SqlSingle Test1   = new SqlSingle(15E+18);
            SqlSingle Test2   = new SqlSingle(-65E+6);
            SqlSingle Test3   = new SqlSingle(5E+30);
            SqlSingle Test4   = new SqlSingle(5E+18);
            SqlSingle TestMax = new SqlSingle(SqlSingle.MaxValue.Value);

            // Add()
            Assert.AreEqual(15E+18f, SqlSingle.Add(Test1, Test0).Value, "#D01A");
            Assert.AreEqual(1.5E+19f, SqlSingle.Add(Test1, Test2).Value, "#D02A");

            try {
                SqlSingle test = SqlSingle.Add(SqlSingle.MaxValue,
                                               SqlSingle.MaxValue);
                Assert.Fail("#D03A");
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D04A");
            }

            // Divide()
            Assert.AreEqual((SqlSingle)3, SqlSingle.Divide(Test1, Test4), "#D01B");
            Assert.AreEqual(-1.3E-23f, SqlSingle.Divide(Test2, Test3).Value, "#D02B");

            try {
                SqlSingle test = SqlSingle.Divide(Test1, Test0).Value;
                Assert.Fail("#D03B");
            } catch (Exception e) {
                Assert.AreEqual(typeof(DivideByZeroException),
                                e.GetType(), "#D04B");
            }

            // Multiply()
            Assert.AreEqual((float)(7.5E+37),
                            SqlSingle.Multiply(Test1, Test4).Value, "#D01D");
            Assert.AreEqual((float)0, SqlSingle.Multiply(Test1, Test0).Value, "#D02D");

            try {
                SqlSingle test = SqlSingle.Multiply(TestMax, Test1);
                Assert.Fail("#D03D");
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D04D");
            }


            // Subtract()
            Assert.AreEqual((float)(-5E+30),
                            SqlSingle.Subtract(Test1, Test3).Value, "#D01F");

            try {
                SqlSingle test = SqlSingle.Subtract(
                    SqlSingle.MinValue, SqlSingle.MaxValue);
                Assert.Fail("D02F");
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#D03F");
            }
        }
示例#13
0
        public void AddRepeat(SqlSingle value, SqlInt32 count)
        {
            if (count.IsNull)
            {
                return;
            }

            _list.AddRepeat(value.IsNull ? default(Single?) : value.Value, count.Value);
        }
示例#14
0
 override public void SetCapacity(int capacity)
 {
     SqlSingle[] newValues = new SqlSingle[capacity];
     if (null != values)
     {
         Array.Copy(values, 0, newValues, 0, Math.Min(capacity, values.Length));
     }
     values = newValues;
 }
示例#15
0
        public void SetItem(SqlInt32 index, SqlSingle value)
        {
            if (index.IsNull)
            {
                return;
            }

            _list[index.Value] = value.IsNull ? default(Single?) : value.Value;
        }
        public static SqlBoolean op_Explicit(SqlSingle x)
        {
            if (x.IsNull)
            {
                return(SqlBoolean.Null);
            }

            return(new SqlBoolean(x.Value != 0.0F));
        }
示例#17
0
 public void SetFlatItem(SqlSingle value, SqlInt32 index)
 {
     if (!index.IsNull)
     {
         new ArrayIndex(_arrayInfo)
         {
             FlatIndex = index.Value
         }
     }
示例#18
0
        /// <summary>
        /// <paramref name="sqlValue"/>의 값을 Nullable 수형으로 반환한다. 실제 값이 Null인 경우는 Null을 반환한다.
        /// </summary>
        public static float?ToNullableValue(this SqlSingle sqlValue)
        {
            if (ConvertTool.IsNullOrDbNull(sqlValue))
            {
                return(null);
            }

            return(sqlValue.Value);
        }
 public override void SetCapacity(int capacity)
 {
     SqlSingle[] destinationArray = new SqlSingle[capacity];
     if (this.values != null)
     {
         Array.Copy(this.values, 0, destinationArray, 0, Math.Min(capacity, this.values.Length));
     }
     this.values = destinationArray;
 }
示例#20
0
        public void Properties()
        {
            SqlSingle test  = new SqlSingle(5443e12f);
            SqlSingle test1 = new SqlSingle(1);

            Assert.True(SqlSingle.Null.IsNull);
            Assert.Equal(5443e12f, test.Value);
            Assert.Equal(1, test1.Value);
        }
示例#21
0
 public override void SetCapacity(int capacity)
 {
     SqlSingle[] newValues = new SqlSingle[capacity];
     if (null != _values)
     {
         Array.Copy(_values, newValues, Math.Min(capacity, _values.Length));
     }
     _values = newValues;
 }
示例#22
0
        public void Properties()
        {
            SqlSingle Test  = new SqlSingle(5443e12f);
            SqlSingle Test1 = new SqlSingle(1);

            Assert.IsTrue(SqlSingle.Null.IsNull, "#C01");
            Assert.AreEqual(5443e12f, Test.Value, "#C02");
            Assert.AreEqual((float)1, Test1.Value, "#C03");
        }
示例#23
0
        public void SqlSingleToSqlMoney()
        {
            SqlSingle testSingle  = new SqlSingle(1e10);
            SqlSingle testSingle2 = new SqlSingle(1e20);

            Assert.Equal(10000000000m, ((SqlMoney)testSingle).Value);

            Assert.Throws <OverflowException>(() => (SqlMoney)testSingle2);
        }
示例#24
0
        public virtual void SetSqlSingle(int ordinal, SqlSingle value)
        {
            // ******** OBSOLETING from SMI -- use ITypedSettersV3 method instead
            //  Intended to be removed prior to RTM.

            // Implement body with throw because there are only a couple of ways to get to this code:
            //  1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
            //  2) Server didn't implement V2- on some interface and negotiated V2-.
            throw System.Data.Common.ADP.InternalError(System.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
        }
示例#25
0
        public void Parse()
        {
            Assert.Throws <ArgumentNullException>(() => SqlSingle.Parse(null));

            Assert.Throws <FormatException>(() => SqlSingle.Parse("not-a-number"));

            Assert.Throws <OverflowException>(() => SqlSingle.Parse("9e44"));

            Assert.Equal(150, SqlSingle.Parse("150").Value);
        }
示例#26
0
        public void ArithmeticOperators()
        {
            SqlSingle Test0 = new SqlSingle(0);
            SqlSingle Test1 = new SqlSingle(24E+11);
            SqlSingle Test2 = new SqlSingle(64E+32);
            SqlSingle Test3 = new SqlSingle(12E+11);
            SqlSingle Test4 = new SqlSingle(1E+10);
            SqlSingle Test5 = new SqlSingle(2E+10);

            // "+"-operator
            Assert.AreEqual((SqlSingle)3E+10, Test4 + Test5, "#N01");

            try {
                SqlSingle test = SqlSingle.MaxValue + SqlSingle.MaxValue;
                Assert.Fail("#N02");
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#N03");
            }

            try {
                SqlSingle test = SqlSingle.MaxValue + SqlSingle.MaxValue;
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#N03a");
            }

            // "/"-operator
            Assert.AreEqual((SqlSingle)2, Test1 / Test3, "#N04");

            try {
                SqlSingle test = Test3 / Test0;
                Assert.Fail("#N05");
            } catch (Exception e) {
                Assert.AreEqual(typeof(DivideByZeroException), e.GetType(), "#N06");
            }

            // "*"-operator
            Assert.AreEqual((SqlSingle)2E+20, Test4 * Test5, "#N07");

            try {
                SqlSingle test = SqlSingle.MaxValue * Test1;
                Assert.Fail("#N08");
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#N09");
            }

            // "-"-operator
            Assert.AreEqual((SqlSingle)12e11, Test1 - Test3, "#N10");

            try {
                SqlSingle test = SqlSingle.MinValue - SqlSingle.MaxValue;
                Assert.Fail("#N11");
            } catch (Exception e) {
                Assert.AreEqual(typeof(OverflowException), e.GetType(), "#N12");
            }
        }
示例#27
0
        public void Create()
        {
            SqlSingle test  = new SqlSingle((float)34.87);
            SqlSingle test2 = 45.2f;

            Assert.Equal(34.87f, test.Value);
            Assert.Equal(45.2f, test2.Value);

            test = new SqlSingle(-9000.6543);
            Assert.Equal(-9000.6543f, test.Value);
        }
示例#28
0
        public void Create()
        {
            SqlSingle Test  = new SqlSingle((float)34.87);
            SqlSingle Test2 = 45.2f;

            Assert.AreEqual(34.87f, Test.Value, "#A01");
            Assert.AreEqual(45.2f, Test2.Value, "#A02");

            Test = new SqlSingle(-9000.6543);
            Assert.AreEqual(-9000.6543f, Test.Value, "#A03");
        }
示例#29
0
    public static void GetCounterData(object oCounterRawResults, out SqlSingle cntr_value, out SqlChars cntr_type, out SqlChars cntr_type_desc)
    {
        CounterRawResults counterRawResults = (CounterRawResults)oCounterRawResults;

        cntr_value     = new SqlSingle((double)counterRawResults.cntr_value);
        cntr_type      = new SqlChars(counterRawResults.cntr_type);
        cntr_type_desc = new SqlChars(counterRawResults.cntr_type_desc);

        //counter_base = new SqlChars(counterRawResults.counter_base);
        //counter_base_value = counterRawResults.counter_base_value.HasValue == true ? new SqlInt64((long)counterRawResults.counter_base_value) : new SqlInt64();
    }
示例#30
0
        public void InsertRepeat(SqlInt32 index, SqlSingle value, SqlInt32 count)
        {
            if (count.IsNull)
            {
                return;
            }

            int indexValue = !index.IsNull ? index.Value : _list.Count;

            _list.InsertRepeat(indexValue, value.IsNull ? default(Single?) : value.Value, count.Value);
        }
示例#31
0
 public static SqlBoolean NotEquals(SqlSingle x, SqlSingle y)
 {
     return (x != y);
 }
示例#32
0
 public int CompareTo(SqlSingle value)
 {
     return this.CompareSqlSingle(value);
 }
示例#33
0
        public void SqlTypes_SqlSingle()
        {
            NpgsqlParameter parameter;
            SqlSingle value = new SqlSingle(45f);

#if NET_2_0
            parameter = new NpgsqlParameter ();
            parameter.NpgsqlValue = value;
            Assert.AreEqual (NpgsqlDbType.Real, parameter.NpgsqlDbType, "#A:NpgsqlDbType");
            Assert.AreEqual (value, parameter.NpgsqlValue, "#A:NpgsqlValue");
            Assert.AreEqual (value, parameter.Value, "#A:Value");

            parameter = new NpgsqlParameter ();
            parameter.NpgsqlValue = SqlSingle.Null;
            Assert.AreEqual (NpgsqlDbType.Real, parameter.NpgsqlDbType, "#B:NpgsqlDbType");
            Assert.AreEqual (SqlSingle.Null, parameter.NpgsqlValue, "#B:NpgsqlValue");
            Assert.AreEqual (SqlSingle.Null, parameter.Value, "#B:Value");
#endif

            parameter = new NpgsqlParameter();
            parameter.Value = value;
            Assert.AreEqual(NpgsqlDbType.Real, parameter.NpgsqlDbType, "#C:NpgsqlDbType");
#if NET_2_0
            Assert.AreEqual (value, parameter.NpgsqlValue, "#C:NpgsqlValue");
#endif
            Assert.AreEqual(value, parameter.Value, "#C:Value");
        }
示例#34
0
 private int CompareSqlSingle(SqlSingle value)
 {
     if (value.IsNull)
     {
         return 1;
     }
     else
     {
         return this.value.CompareTo(value.Value);
     }
 }
示例#35
0
 public static SqlSingle Divide(SqlSingle x, SqlSingle y)
 {
     return (x/y);
 }
示例#36
0
        public static SqlBoolean op_Explicit(SqlSingle x)
        {
            if (x.IsNull)
                return SqlBoolean.Null;

            return new SqlBoolean(x.Value != 0.0F);
        }
示例#37
0
 public static SqlBoolean Equals(SqlSingle x, SqlSingle y)
 {
     return (x == y);
 }
示例#38
0
 public static SqlBoolean GreaterThanOrEqual(SqlSingle x, SqlSingle y)
 {
     return (x >= y);
 }
示例#39
0
 public static SqlBoolean LessThan(SqlSingle x, SqlSingle y)
 {
     return (x < y);
 }
示例#40
0
 public static SqlBoolean LessThanOrEqual(SqlSingle x, SqlSingle y)
 {
     return (x <= y);
 }
示例#41
0
 public static SqlSingle Add(SqlSingle x, SqlSingle y)
 {
     return (x + y);
 }
示例#42
0
 public static SqlSingle Multiply(SqlSingle x, SqlSingle y)
 {
     return (x*y);
 }
示例#43
0
 public static SqlBoolean GreaterThan(SqlSingle x, SqlSingle y)
 {
     return (x > y);
 }
示例#44
0
 public static SqlSingle Subtract(SqlSingle x, SqlSingle y)
 {
     return (x - y);
 }