2 // SqlInt64Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt64
5 // Ville Palo (vi64pa@koti.soon.fi)
6 // Martin Willemoes Hansen (mwh@sysrq.dk)
9 // (C) 2003 Martin Willemoes Hansen
12 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using NUnit.Framework;
36 using System.Data.SqlTypes;
38 using DivideByZeroException = System.ArithmeticException;
41 namespace MonoTests.System.Data.SqlTypes
44 public class SqlInt64Test
51 SqlInt64 TestLong = new SqlInt64 (29);
52 Assert.AreEqual ((long)29, TestLong.Value, "#A01");
54 TestLong = new SqlInt64 (-9000);
55 Assert.AreEqual ((long)-9000, TestLong.Value, "#A02");
60 public void PublicFields()
62 Assert.AreEqual ((long)9223372036854775807, SqlInt64.MaxValue.Value, "#B01");
63 Assert.AreEqual ((long)(-9223372036854775808), SqlInt64.MinValue.Value, "#B02");
64 Assert.IsTrue (SqlInt64.Null.IsNull, "#B03");
65 Assert.AreEqual ((long)0, SqlInt64.Zero.Value, "#B04");
70 public void Properties()
72 SqlInt64 Test5443 = new SqlInt64 (5443);
73 SqlInt64 Test1 = new SqlInt64 (1);
75 Assert.IsTrue (SqlInt64.Null.IsNull, "#C01");
76 Assert.AreEqual ((long)5443, Test5443.Value, "#C02");
77 Assert.AreEqual ((long)1, Test1.Value, "#C03");
83 public void ArithmeticMethods()
85 SqlInt64 Test64 = new SqlInt64 (64);
86 SqlInt64 Test0 = new SqlInt64 (0);
87 SqlInt64 Test164 = new SqlInt64 (164);
88 SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
91 Assert.AreEqual ((long)64, SqlInt64.Add (Test64, Test0).Value, "#D01");
92 Assert.AreEqual ((long)228, SqlInt64.Add (Test64, Test164).Value, "#D02");
93 Assert.AreEqual ((long)164, SqlInt64.Add (Test0, Test164).Value, "#D03");
94 Assert.AreEqual ((long)SqlInt64.MaxValue, SqlInt64.Add (TestMax, Test0).Value, "#D04");
97 SqlInt64.Add (TestMax, Test64);
99 } catch (Exception e) {
100 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D06");
104 Assert.AreEqual ((long)2, SqlInt64.Divide (Test164, Test64).Value, "#D07");
105 Assert.AreEqual ((long)0, SqlInt64.Divide (Test64, Test164).Value, "#D08");
108 SqlInt64.Divide(Test64, Test0);
109 Assert.Fail ("#D09");
110 } catch(Exception e) {
111 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "#D10");
115 Assert.AreEqual ((SqlInt64)36, SqlInt64.Mod (Test164, Test64), "#D11");
116 Assert.AreEqual ((SqlInt64)64, SqlInt64.Mod (Test64, Test164), "#D12");
119 Assert.AreEqual ((long)10496, SqlInt64.Multiply (Test64, Test164).Value, "#D13");
120 Assert.AreEqual ((long)0, SqlInt64.Multiply (Test64, Test0).Value, "#D14");
123 SqlInt64.Multiply (TestMax, Test64);
124 Assert.Fail ("#D15");
125 } catch(Exception e) {
126 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D16");
130 Assert.AreEqual ((long)100, SqlInt64.Subtract (Test164, Test64).Value, "#D17");
133 SqlInt64.Subtract (SqlInt64.MinValue, Test164);
134 Assert.Fail ("#D18");
135 } catch(Exception e) {
136 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D19");
141 Assert.AreEqual ((SqlInt64)36, SqlInt64.Modulus (Test164, Test64), "#D20");
142 Assert.AreEqual ((SqlInt64)64, SqlInt64.Modulus (Test64, Test164), "#D21");
147 public void BitwiseMethods()
149 long MaxValue = SqlInt64.MaxValue.Value;
150 SqlInt64 TestInt = new SqlInt64 (0);
151 SqlInt64 TestIntMax = new SqlInt64 (MaxValue);
152 SqlInt64 TestInt2 = new SqlInt64 (10922);
153 SqlInt64 TestInt3 = new SqlInt64 (21845);
156 Assert.AreEqual ((long)21845, SqlInt64.BitwiseAnd (TestInt3, TestIntMax).Value, "#E01");
157 Assert.AreEqual ((long)0, SqlInt64.BitwiseAnd (TestInt2, TestInt3).Value, "#E02");
158 Assert.AreEqual ((long)10922, SqlInt64.BitwiseAnd (TestInt2, TestIntMax).Value, "#E03");
161 Assert.AreEqual ((long)21845, SqlInt64.BitwiseOr (TestInt, TestInt3).Value, "#E04");
162 Assert.AreEqual ((long)MaxValue, SqlInt64.BitwiseOr (TestIntMax, TestInt2).Value, "#E05");
166 public void CompareTo()
168 SqlInt64 TestInt4000 = new SqlInt64 (4000);
169 SqlInt64 TestInt4000II = new SqlInt64 (4000);
170 SqlInt64 TestInt10 = new SqlInt64 (10);
171 SqlInt64 TestInt10000 = new SqlInt64 (10000);
172 SqlString TestString = new SqlString ("This is a test");
174 Assert.IsTrue (TestInt4000.CompareTo (TestInt10) > 0, "#F01");
175 Assert.IsTrue (TestInt10.CompareTo (TestInt4000) < 0, "#F02");
176 Assert.IsTrue (TestInt4000II.CompareTo (TestInt4000) == 0, "#F03");
177 Assert.IsTrue (TestInt4000II.CompareTo (SqlInt64.Null) > 0, "#F04");
180 TestInt10.CompareTo (TestString);
182 } catch(Exception e) {
183 Assert.AreEqual (typeof (ArgumentException), e.GetType (), "#F06");
188 public void EqualsMethod()
190 SqlInt64 Test0 = new SqlInt64 (0);
191 SqlInt64 Test158 = new SqlInt64 (158);
192 SqlInt64 Test180 = new SqlInt64 (180);
193 SqlInt64 Test180II = new SqlInt64 (180);
195 Assert.IsTrue (!Test0.Equals (Test158), "#G01");
196 Assert.IsTrue (!Test158.Equals (Test180), "#G01");
197 Assert.IsTrue (!Test180.Equals (new SqlString ("TEST")), "#G03");
198 Assert.IsTrue (Test180.Equals (Test180II), "#G04");
202 public void StaticEqualsMethod()
204 SqlInt64 Test34 = new SqlInt64 (34);
205 SqlInt64 Test34II = new SqlInt64 (34);
206 SqlInt64 Test15 = new SqlInt64 (15);
208 Assert.IsTrue (SqlInt64.Equals (Test34, Test34II).Value, "#H01");
209 Assert.IsTrue (!SqlInt64.Equals (Test34, Test15).Value, "#H02");
210 Assert.IsTrue (!SqlInt64.Equals (Test15, Test34II).Value, "#H03");
214 public void GetHashCodeTest()
216 SqlInt64 Test15 = new SqlInt64 (15);
218 // FIXME: Better way to test HashCode
219 Assert.AreEqual ((int)15, Test15.GetHashCode (), "#I01");
223 public void GetTypeTest()
225 SqlInt64 Test = new SqlInt64 (84);
226 Assert.AreEqual ("System.Data.SqlTypes.SqlInt64", Test.GetType ().ToString (), "#J01");
230 public void Greaters()
232 SqlInt64 Test10 = new SqlInt64 (10);
233 SqlInt64 Test10II = new SqlInt64 (10);
234 SqlInt64 Test110 = new SqlInt64 (110);
237 Assert.IsTrue (!SqlInt64.GreaterThan (Test10, Test110).Value, "#K01");
238 Assert.IsTrue (SqlInt64.GreaterThan (Test110, Test10).Value, "#K02");
239 Assert.IsTrue (!SqlInt64.GreaterThan (Test10II, Test10).Value, "#K03");
241 // GreaterTharOrEqual ()
242 Assert.IsTrue (!SqlInt64.GreaterThanOrEqual (Test10, Test110).Value, "#K04");
243 Assert.IsTrue (SqlInt64.GreaterThanOrEqual (Test110, Test10).Value, "#K05");
244 Assert.IsTrue (SqlInt64.GreaterThanOrEqual (Test10II, Test10).Value, "#K06");
248 public void Lessers()
250 SqlInt64 Test10 = new SqlInt64 (10);
251 SqlInt64 Test10II = new SqlInt64 (10);
252 SqlInt64 Test110 = new SqlInt64 (110);
255 Assert.IsTrue (SqlInt64.LessThan (Test10, Test110).Value, "#L01");
256 Assert.IsTrue (!SqlInt64.LessThan (Test110, Test10).Value, "#L02");
257 Assert.IsTrue (!SqlInt64.LessThan (Test10II, Test10).Value, "#L03");
259 // LessThanOrEqual ()
260 Assert.IsTrue (SqlInt64.LessThanOrEqual (Test10, Test110).Value, "#L04");
261 Assert.IsTrue (!SqlInt64.LessThanOrEqual (Test110, Test10).Value, "#L05");
262 Assert.IsTrue (SqlInt64.LessThanOrEqual (Test10II, Test10).Value, "#L06");
263 Assert.IsTrue (SqlInt64.LessThanOrEqual (Test10II, SqlInt64.Null).IsNull, "#L07");
267 public void NotEquals()
269 SqlInt64 Test12 = new SqlInt64 (12);
270 SqlInt64 Test128 = new SqlInt64 (128);
271 SqlInt64 Test128II = new SqlInt64 (128);
273 Assert.IsTrue (SqlInt64.NotEquals (Test12, Test128).Value, "#M01");
274 Assert.IsTrue (SqlInt64.NotEquals (Test128, Test12).Value, "#M02");
275 Assert.IsTrue (SqlInt64.NotEquals (Test128II, Test12).Value, "#M03");
276 Assert.IsTrue (!SqlInt64.NotEquals (Test128II, Test128).Value, "#M04");
277 Assert.IsTrue (!SqlInt64.NotEquals (Test128, Test128II).Value, "#M05");
278 Assert.IsTrue (SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull, "#M06");
279 Assert.IsTrue (SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull, "#M07");
283 public void OnesComplement()
285 SqlInt64 Test12 = new SqlInt64(12);
286 SqlInt64 Test128 = new SqlInt64(128);
288 Assert.AreEqual ((SqlInt64)(-13), SqlInt64.OnesComplement (Test12), "#N01");
289 Assert.AreEqual ((SqlInt64)(-129), SqlInt64.OnesComplement (Test128), "#N02");
296 SqlInt64.Parse (null);
297 Assert.Fail ("#O01");
298 } catch (Exception e) {
299 Assert.AreEqual (typeof (ArgumentNullException), e.GetType (), "#O02");
303 SqlInt64.Parse ("not-a-number");
304 Assert.Fail ("#O03");
305 } catch (Exception e) {
306 Assert.AreEqual (typeof (FormatException), e.GetType (), "#O04");
310 SqlInt64.Parse ("1000000000000000000000000000");
311 Assert.Fail ("#O05");
312 } catch (Exception e) {
313 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#O06");
316 Assert.AreEqual((long)150, SqlInt64.Parse ("150").Value, "#O07");
320 public void Conversions()
322 SqlInt64 Test12 = new SqlInt64 (12);
323 SqlInt64 Test0 = new SqlInt64 (0);
324 SqlInt64 TestNull = SqlInt64.Null;
325 SqlInt64 Test1000 = new SqlInt64 (1000);
326 SqlInt64 Test288 = new SqlInt64(288);
329 Assert.IsTrue (Test12.ToSqlBoolean ().Value, "#P01");
330 Assert.IsTrue (!Test0.ToSqlBoolean ().Value, "#P02");
331 Assert.IsTrue (TestNull.ToSqlBoolean ().IsNull, "#P03");
334 Assert.AreEqual ((byte)12, Test12.ToSqlByte ().Value, "#P04");
335 Assert.AreEqual ((byte)0, Test0.ToSqlByte ().Value, "#P05");
338 SqlByte b = (byte)Test1000.ToSqlByte ();
339 Assert.Fail ("#P06");
340 } catch (Exception e) {
341 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#P07");
345 Assert.AreEqual ((decimal)12, Test12.ToSqlDecimal ().Value, "#P08");
346 Assert.AreEqual ((decimal)0, Test0.ToSqlDecimal ().Value, "#P09");
347 Assert.AreEqual ((decimal)288, Test288.ToSqlDecimal ().Value, "#P10");
350 Assert.AreEqual ((double)12, Test12.ToSqlDouble ().Value, "#P11");
351 Assert.AreEqual ((double)0, Test0.ToSqlDouble ().Value, "#P12");
352 Assert.AreEqual ((double)1000, Test1000.ToSqlDouble ().Value, "#P13");
355 Assert.AreEqual ((int)12, Test12.ToSqlInt32 ().Value, "#P14");
356 Assert.AreEqual ((int)0, Test0.ToSqlInt32 ().Value, "#P15");
357 Assert.AreEqual ((int)288, Test288.ToSqlInt32().Value, "#P16");
360 Assert.AreEqual ((short)12, Test12.ToSqlInt16 ().Value, "#P17");
361 Assert.AreEqual ((short)0, Test0.ToSqlInt16 ().Value, "#P18");
362 Assert.AreEqual ((short)288, Test288.ToSqlInt16 ().Value, "#P19");
365 Assert.AreEqual (12.0000M, Test12.ToSqlMoney ().Value, "#P20");
366 Assert.AreEqual ((decimal)0, Test0.ToSqlMoney ().Value, "#P21");
367 Assert.AreEqual (288.0000M, Test288.ToSqlMoney ().Value, "#P22");
370 Assert.AreEqual ((float)12, Test12.ToSqlSingle ().Value, "#P23");
371 Assert.AreEqual ((float)0, Test0.ToSqlSingle ().Value, "#P24");
372 Assert.AreEqual ((float)288, Test288.ToSqlSingle().Value, "#P25");
375 Assert.AreEqual ("12", Test12.ToSqlString ().Value, "#P26");
376 Assert.AreEqual ("0", Test0.ToSqlString ().Value, "#P27");
377 Assert.AreEqual ("288", Test288.ToSqlString ().Value, "#P28");
380 Assert.AreEqual ("12", Test12.ToString (), "#P29");
381 Assert.AreEqual ("0", Test0.ToString (), "#P30");
382 Assert.AreEqual ("288", Test288.ToString (), "#P31");
388 SqlInt64 Test14 = new SqlInt64 (14);
389 SqlInt64 Test58 = new SqlInt64 (58);
390 SqlInt64 Test130 = new SqlInt64 (130);
391 SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
392 SqlInt64 Test0 = new SqlInt64 (0);
394 Assert.AreEqual ((long)52, SqlInt64.Xor (Test14, Test58).Value, "#Q01");
395 Assert.AreEqual ((long)140, SqlInt64.Xor (Test14, Test130).Value, "#Q02");
396 Assert.AreEqual ((long)184, SqlInt64.Xor (Test58, Test130).Value, "#Q03");
397 Assert.AreEqual ((long)0, SqlInt64.Xor (TestMax, TestMax).Value, "#Q04");
398 Assert.AreEqual (TestMax.Value, SqlInt64.Xor (TestMax, Test0).Value, "#Q05");
404 public void ArithmeticOperators()
406 SqlInt64 Test24 = new SqlInt64 (24);
407 SqlInt64 Test64 = new SqlInt64 (64);
408 SqlInt64 Test2550 = new SqlInt64 (2550);
409 SqlInt64 Test0 = new SqlInt64 (0);
412 Assert.AreEqual ((SqlInt64)2614,Test2550 + Test64, "#R01");
414 SqlInt64 result = Test64 + SqlInt64.MaxValue;
415 Assert.Fail ("#R02");
416 } catch (Exception e) {
417 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#R03");
421 Assert.AreEqual ((SqlInt64)39, Test2550 / Test64, "#R04");
422 Assert.AreEqual ((SqlInt64)0, Test24 / Test64, "#R05");
425 SqlInt64 result = Test2550 / Test0;
426 Assert.Fail ("#R06");
427 } catch (Exception e) {
428 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "#R07");
432 Assert.AreEqual ((SqlInt64)1536, Test64 * Test24, "#R08");
435 SqlInt64 test = (SqlInt64.MaxValue * Test64);
436 Assert.Fail ("TestC#2");
437 } catch (Exception e) {
438 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#R08");
442 Assert.AreEqual ((SqlInt64)2526, Test2550 - Test24, "#R09");
445 SqlInt64 test = SqlInt64.MinValue - Test64;
446 Assert.Fail ("#R10");
447 } catch (Exception e) {
448 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#R11");
452 Assert.AreEqual ((SqlInt64)54, Test2550 % Test64, "#R12");
453 Assert.AreEqual ((SqlInt64)24, Test24 % Test64, "#R13");
454 Assert.AreEqual ((SqlInt64)0, new SqlInt64 (100) % new SqlInt64 (10), "#R14");
458 public void BitwiseOperators()
460 SqlInt64 Test2 = new SqlInt64 (2);
461 SqlInt64 Test4 = new SqlInt64 (4);
463 SqlInt64 Test2550 = new SqlInt64 (2550);
466 Assert.AreEqual ((SqlInt64)0, Test2 & Test4, "#S01");
467 Assert.AreEqual ((SqlInt64)2, Test2 & Test2550, "#S02");
468 Assert.AreEqual ((SqlInt64)0, SqlInt64.MaxValue & SqlInt64.MinValue, "#S03");
471 Assert.AreEqual ((SqlInt64)6,Test2 | Test4, "#S04");
472 Assert.AreEqual ((SqlInt64)2550, Test2 | Test2550, "#S05");
473 Assert.AreEqual ((SqlInt64)(-1), SqlInt64.MinValue | SqlInt64.MaxValue, "#S06");
476 Assert.AreEqual((SqlInt64)2546, (Test2550 ^ Test4), "#S07");
477 Assert.AreEqual((SqlInt64)6, (Test2 ^ Test4), "#S08");
481 public void ThanOrEqualOperators()
483 SqlInt64 Test165 = new SqlInt64 (165);
484 SqlInt64 Test100 = new SqlInt64 (100);
485 SqlInt64 Test100II = new SqlInt64 (100);
486 SqlInt64 Test255 = new SqlInt64 (2550);
489 Assert.IsTrue ((Test100 == Test100II).Value, "#T01");
490 Assert.IsTrue (!(Test165 == Test100).Value, "#T02");
491 Assert.IsTrue ((Test165 == SqlInt64.Null).IsNull, "#T03");
494 Assert.IsTrue (!(Test100 != Test100II).Value, "#T04");
495 Assert.IsTrue ((Test100 != Test255).Value, "#T05");
496 Assert.IsTrue ((Test165 != Test255).Value, "#T06");
497 Assert.IsTrue ((Test165 != SqlInt64.Null).IsNull, "#T07");
500 Assert.IsTrue ((Test165 > Test100).Value, "#T08");
501 Assert.IsTrue (!(Test165 > Test255).Value, "#T09");
502 Assert.IsTrue (!(Test100 > Test100II).Value, "#T10");
503 Assert.IsTrue ((Test165 > SqlInt64.Null).IsNull, "#T11");
506 Assert.IsTrue (!(Test165 >= Test255).Value, "#T12");
507 Assert.IsTrue ((Test255 >= Test165).Value, "#T13");
508 Assert.IsTrue ((Test100 >= Test100II).Value, "#T14");
509 Assert.IsTrue ((Test165 >= SqlInt64.Null).IsNull, "#T15");
512 Assert.IsTrue (!(Test165 < Test100).Value, "#T16");
513 Assert.IsTrue ((Test165 < Test255).Value, "#T17");
514 Assert.IsTrue (!(Test100 < Test100II).Value, "#T18");
515 Assert.IsTrue ((Test165 < SqlInt64.Null).IsNull, "#T19");
518 Assert.IsTrue ((Test165 <= Test255).Value, "#T20");
519 Assert.IsTrue (!(Test255 <= Test165).Value, "#T21");
520 Assert.IsTrue ((Test100 <= Test100II).Value, "#T22");
521 Assert.IsTrue ((Test165 <= SqlInt64.Null).IsNull, "#T23");
525 public void OnesComplementOperator()
527 SqlInt64 Test12 = new SqlInt64 (12);
528 SqlInt64 Test128 = new SqlInt64 (128);
530 Assert.AreEqual ((SqlInt64)(-13), ~Test12, "#V01");
531 Assert.AreEqual ((SqlInt64)(-129), ~Test128, "#V02");
532 Assert.AreEqual (SqlInt64.Null, ~SqlInt64.Null, "#V03");
536 public void UnaryNegation()
538 SqlInt64 Test = new SqlInt64 (2000);
539 SqlInt64 TestNeg = new SqlInt64 (-3000);
541 SqlInt64 Result = -Test;
542 Assert.AreEqual ((long)(-2000), Result.Value, "#W01");
545 Assert.AreEqual ((long)3000, Result.Value, "#W02");
549 public void SqlBooleanToSqlInt64()
551 SqlBoolean TestBoolean = new SqlBoolean (true);
554 Result = (SqlInt64)TestBoolean;
556 Assert.AreEqual ((long)1, Result.Value, "#X01");
558 Result = (SqlInt64)SqlBoolean.Null;
559 Assert.IsTrue (Result.IsNull, "#X02");
563 public void SqlDecimalToSqlInt64()
565 SqlDecimal TestDecimal64 = new SqlDecimal (64);
566 SqlDecimal TestDecimal900 = new SqlDecimal (90000);
568 Assert.AreEqual((long)64, ((SqlInt64)TestDecimal64).Value, "#Y01");
569 Assert.AreEqual(SqlInt64.Null, ((SqlInt64)SqlDecimal.Null), "#Y02");
572 SqlInt64 test = (SqlInt64)SqlDecimal.MaxValue;
574 } catch (Exception e) {
575 Assert.AreEqual(typeof(OverflowException), e.GetType(), "#Y04");
580 public void SqlDoubleToSqlInt64()
582 SqlDouble TestDouble64 = new SqlDouble (64);
583 SqlDouble TestDouble900 = new SqlDouble (90000);
585 Assert.AreEqual ((long)64, ((SqlInt64)TestDouble64).Value, "#Z01");
586 Assert.AreEqual (SqlInt64.Null, ((SqlInt64)SqlDouble.Null), "#Z02");
589 SqlInt64 test = (SqlInt64)SqlDouble.MaxValue;
590 Assert.Fail ("#Z03");
591 } catch (Exception e) {
592 Assert.AreEqual(typeof (OverflowException), e.GetType (), "#Z04");
597 public void Sql64IntToInt64()
599 SqlInt64 Test = new SqlInt64 (12);
600 Int64 Result = (Int64)Test;
601 Assert.AreEqual ((long)12, Result, "#AA01");
605 public void SqlInt32ToSqlInt64()
607 SqlInt32 Test64 = new SqlInt32 (64);
608 Assert.AreEqual ((long)64, ((SqlInt64)Test64).Value, "#AB01");
612 public void SqlInt16ToSqlInt64()
614 SqlInt16 Test64 = new SqlInt16 (64);
615 Assert.AreEqual ((long)64, ((SqlInt64)Test64).Value, "#AC01");
619 public void SqlMoneyToSqlInt64()
621 SqlMoney TestMoney64 = new SqlMoney(64);
622 Assert.AreEqual ((long)64, ((SqlInt64)TestMoney64).Value, "#AD01");
626 public void SqlSingleToSqlInt64()
628 SqlSingle TestSingle64 = new SqlSingle (64);
629 Assert.AreEqual ((long)64, ((SqlInt64)TestSingle64).Value, "#AE01");
633 public void SqlStringToSqlInt64()
635 SqlString TestString = new SqlString ("Test string");
636 SqlString TestString100 = new SqlString ("100");
637 SqlString TestString1000 = new SqlString ("1000000000000000000000");
639 Assert.AreEqual ((long)100, ((SqlInt64)TestString100).Value, "#AF01");
642 SqlInt64 test = (SqlInt64)TestString1000;
643 Assert.Fail ("#AF02");
644 } catch(Exception e) {
645 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#AF03");
649 SqlInt64 test = (SqlInt64)TestString;
650 Assert.Fail ("#AF03");
651 } catch(Exception e) {
652 Assert.AreEqual (typeof (FormatException), e.GetType (), "#AF04");
657 public void ByteToSqlInt64()
659 short TestShort = 14;
660 Assert.AreEqual ((long)14, ((SqlInt64)TestShort).Value, "#G01");