* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Data / Test / System.Data.SqlTypes / SqlSingleTest.cs
1 //
2 // SqlSingleTest.cs - NUnit Test Cases for System.Data.SqlTypes.SqlSingle
3 //
4 // Authors:
5 //   Ville Palo (vi64pa@koti.soon.fi)
6 //   Martin Willemoes Hansen (mwh@sysrq.dk)
7 //
8 // (C) 2002 Ville Palo
9 // (C) 2003 Martin Willemoes Hansen
10 // 
11
12 //
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
14 //
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 // 
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 // 
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 //
34
35 using NUnit.Framework;
36 using System;
37 using System.Data.SqlTypes;
38 using System.Threading;
39 using System.Globalization;
40
41 namespace MonoTests.System.Data.SqlTypes
42 {
43         [TestFixture]
44         public class SqlSingleTest
45         {
46
47                 [SetUp]
48                 public void GetReady() 
49                 {
50                         Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
51                 }
52
53                 // Test constructor
54                 [Test]
55                 public void Create()
56                 {
57                         SqlSingle Test= new SqlSingle ((float)34.87);
58                         SqlSingle Test2 = 45.2f;
59                         
60                         Assert.AreEqual (34.87f, Test.Value, "#A01");
61                         Assert.AreEqual (45.2f, Test2.Value, "#A02");
62
63                         Test = new SqlSingle (-9000.6543);
64                         Assert.AreEqual (-9000.6543f, Test.Value, "#A03");
65                 }
66
67                 // Test public fields
68                 [Test]
69                 public void PublicFields()
70                 {
71                         Assert.AreEqual (3.40282346638528859E+38f, 
72                                       SqlSingle.MaxValue.Value, "#B01");
73                         Assert.AreEqual (-3.40282346638528859E+38f, 
74                                       SqlSingle.MinValue.Value, "#B02");
75                         Assert.IsTrue (SqlSingle.Null.IsNull, "#B03");
76                         Assert.AreEqual (0f, SqlSingle.Zero.Value, "#B04");
77                 }
78
79                 // Test properties
80                 [Test]
81                 public void Properties()
82                 {
83                         SqlSingle Test = new SqlSingle (5443e12f);
84                         SqlSingle Test1 = new SqlSingle (1);
85
86                         Assert.IsTrue (SqlSingle.Null.IsNull, "#C01");
87                         Assert.AreEqual (5443e12f, Test.Value, "#C02");
88                         Assert.AreEqual ((float)1, Test1.Value, "#C03");
89                 }
90
91                 // PUBLIC METHODS
92
93                 [Test]
94                 public void ArithmeticMethods()
95                 {
96                         SqlSingle Test0 = new SqlSingle (0);
97                         SqlSingle Test1 = new SqlSingle (15E+18);
98                         SqlSingle Test2 = new SqlSingle (-65E+6);
99                         SqlSingle Test3 = new SqlSingle (5E+30);
100                         SqlSingle Test4 = new SqlSingle (5E+18);
101                         SqlSingle TestMax = new SqlSingle (SqlSingle.MaxValue.Value);
102
103                         // Add()
104                         Assert.AreEqual (15E+18f, SqlSingle.Add (Test1, Test0).Value, "#D01A");
105                         Assert.AreEqual (1.5E+19f, SqlSingle.Add (Test1, Test2).Value, "#D02A");
106
107                         try {                     
108                                 SqlSingle test = SqlSingle.Add (SqlSingle.MaxValue, 
109                                                          SqlSingle.MaxValue);
110                                 Assert.Fail ("#D03A");
111                         } catch (Exception e) {
112                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D04A");
113                         }
114                         
115                         // Divide()
116                         Assert.AreEqual ((SqlSingle)3, SqlSingle.Divide (Test1, Test4), "#D01B");
117                         Assert.AreEqual (-1.3E-23f, SqlSingle.Divide (Test2, Test3).Value, "#D02B");
118
119                         try {
120                                 SqlSingle test = SqlSingle.Divide(Test1, Test0).Value;
121                                 Assert.Fail ("#D03B");
122                         } catch(Exception e) {
123                                 Assert.AreEqual (typeof (DivideByZeroException), 
124                                               e.GetType (), "#D04B");
125                         }
126
127                         // Multiply()
128                         Assert.AreEqual ((float)(7.5E+37), 
129                                       SqlSingle.Multiply (Test1, Test4).Value, "#D01D");
130                         Assert.AreEqual ((float)0, SqlSingle.Multiply (Test1, Test0).Value, "#D02D");
131
132                         try {
133                                 SqlSingle test = SqlSingle.Multiply (TestMax, Test1);
134                                 Assert.Fail ("#D03D");
135                         } catch (Exception e) {
136                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D04D");
137                         }
138                                 
139
140                         // Subtract()
141                         Assert.AreEqual ((float)(-5E+30), 
142                                       SqlSingle.Subtract (Test1, Test3).Value, "#D01F");
143
144                         try {
145                                 SqlSingle test = SqlSingle.Subtract(
146                                         SqlSingle.MinValue, SqlSingle.MaxValue);
147                                 Assert.Fail ("D02F");
148                         } catch (Exception e) {                 
149                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D03F");
150                         }                      
151                 }
152
153                 [Test]
154                 public void CompareTo()
155                 {
156                         SqlSingle Test1 = new SqlSingle (4E+30);
157                         SqlSingle Test11 = new SqlSingle (4E+30);
158                         SqlSingle Test2 = new SqlSingle (-9E+30);
159                         SqlSingle Test3 = new SqlSingle (10000);
160                         SqlString TestString = new SqlString ("This is a test");
161
162                         Assert.IsTrue (Test1.CompareTo (Test3) > 0, "#E01");
163                         Assert.IsTrue (Test2.CompareTo (Test3) < 0, "#E02");
164                         Assert.IsTrue (Test1.CompareTo (Test11) == 0, "#E03");
165                         Assert.IsTrue (Test11.CompareTo (SqlSingle.Null) > 0, "#E04");
166
167                         try {
168                                 Test1.CompareTo (TestString);
169                                 Assert.Fail("#E05");
170                         } catch(Exception e) {
171                                 Assert.AreEqual (typeof (ArgumentException), e.GetType (), "#E06");
172                         }
173                 }
174
175                 [Test]
176                 public void EqualsMethods()
177                 {
178                         SqlSingle Test0 = new SqlSingle (0);
179                         SqlSingle Test1 = new SqlSingle (1.58e30);
180                         SqlSingle Test2 = new SqlSingle (1.8e32);
181                         SqlSingle Test22 = new SqlSingle (1.8e32);
182
183                         Assert.IsTrue (!Test0.Equals (Test1), "#F01");
184                         Assert.IsTrue (!Test1.Equals (Test2), "#F02");
185                         Assert.IsTrue (!Test2.Equals (new SqlString ("TEST")), "#F03");
186                         Assert.IsTrue (Test2.Equals (Test22), "#F04");
187
188                         // Static Equals()-method
189                         Assert.IsTrue (SqlSingle.Equals (Test2, Test22).Value, "#F05");
190                         Assert.IsTrue (!SqlSingle.Equals (Test1, Test2).Value, "#F06");
191                 }
192
193                 [Test]
194                 public void GetHashCodeTest()
195                 {
196                         SqlSingle Test15 = new SqlSingle (15);
197
198                         // FIXME: Better way to test HashCode
199                         Assert.AreEqual (Test15.GetHashCode (), Test15.GetHashCode (), "#G01");
200                 }
201
202                 [Test]
203                 public void GetTypeTest()
204                 {
205                         SqlSingle Test = new SqlSingle (84);
206                         Assert.AreEqual ("System.Data.SqlTypes.SqlSingle", 
207                                       Test.GetType ().ToString (), "#H01");
208                         Assert.AreEqual ("System.Single", Test.Value.GetType ().ToString (), "#H02");
209                 }
210
211                 [Test]
212                 public void Greaters()
213                 {
214                         SqlSingle Test1 = new SqlSingle (1e10);
215                         SqlSingle Test11 = new SqlSingle (1e10);
216                         SqlSingle Test2 = new SqlSingle (64e14);
217
218                         // GreateThan ()
219                         Assert.IsTrue (!SqlSingle.GreaterThan (Test1, Test2).Value, "#I01");
220                         Assert.IsTrue (SqlSingle.GreaterThan (Test2, Test1).Value, "#I02");
221                         Assert.IsTrue (!SqlSingle.GreaterThan (Test1, Test11).Value, "#I03");
222
223                         // GreaterTharOrEqual ()
224                         Assert.IsTrue (!SqlSingle.GreaterThanOrEqual (Test1, Test2).Value, "#I04");
225                         Assert.IsTrue (SqlSingle.GreaterThanOrEqual (Test2, Test1).Value, "#I05");
226                         Assert.IsTrue (SqlSingle.GreaterThanOrEqual (Test1, Test11).Value, "#I06");
227                 }
228
229                 [Test]
230                 public void Lessers()
231                 {
232                         SqlSingle Test1 = new SqlSingle(1.8e10);
233                         SqlSingle Test11 = new SqlSingle (1.8e10);
234                         SqlSingle Test2 = new SqlSingle (64e14);
235
236                         // LessThan()
237                         Assert.IsTrue (!SqlSingle.LessThan (Test1, Test11).Value, "#J01");
238                         Assert.IsTrue (!SqlSingle.LessThan (Test2, Test1).Value, "#J02");
239                         Assert.IsTrue (SqlSingle.LessThan (Test11, Test2).Value, "#J03");
240
241                         // LessThanOrEqual ()
242                         Assert.IsTrue (SqlSingle.LessThanOrEqual (Test1, Test2).Value, "#J04");
243                         Assert.IsTrue (!SqlSingle.LessThanOrEqual (Test2, Test1).Value, "#J05");
244                         Assert.IsTrue (SqlSingle.LessThanOrEqual (Test11, Test1).Value, "#J06");
245                         Assert.IsTrue (SqlSingle.LessThanOrEqual (Test11, SqlSingle.Null).IsNull, "#J07");
246                 }
247
248                 [Test]
249                 public void NotEquals()
250                 {
251                         SqlSingle Test1 = new SqlSingle (12800000000001);
252                         SqlSingle Test2 = new SqlSingle (128e10);
253                         SqlSingle Test22 = new SqlSingle (128e10);
254
255                         Assert.IsTrue (SqlSingle.NotEquals (Test1, Test2).Value, "#K01");
256                         Assert.IsTrue (SqlSingle.NotEquals (Test2, Test1).Value, "#K02");
257                         Assert.IsTrue (SqlSingle.NotEquals (Test22, Test1).Value, "#K03");
258                         Assert.IsTrue (!SqlSingle.NotEquals (Test22, Test2).Value, "#K04");
259                         Assert.IsTrue (!SqlSingle.NotEquals (Test2, Test22).Value, "#K05");
260                         Assert.IsTrue (SqlSingle.NotEquals (SqlSingle.Null, Test22).IsNull, "#K06");
261                         Assert.IsTrue (SqlSingle.NotEquals (SqlSingle.Null, Test22).IsNull, "#K07");
262                 }
263
264                 [Test]
265                 public void Parse()
266                 {
267                         try {
268                                 SqlSingle.Parse (null);
269                                 Assert.Fail ("#L01");
270                         } catch (Exception e) {
271                                 Assert.AreEqual (typeof (ArgumentNullException), e.GetType (), "#L02");
272                         }
273
274                         try {
275                                 SqlSingle.Parse ("not-a-number");
276                                 Assert.Fail ("#L03");
277                         } catch (Exception e) {
278                                 Assert.AreEqual (typeof (FormatException), e.GetType (), "#L04");
279                         }
280
281                          try {
282                                 SqlSingle.Parse ("9e44");
283                                 Assert.Fail ("#L05");
284                         } catch (Exception e) {
285                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#L06");
286                         }
287
288                         Assert.AreEqual((float)150, SqlSingle.Parse ("150").Value, "#L07");
289                 }
290
291                 [Test]
292                 public void Conversions()
293                 {
294                         SqlSingle Test0 = new SqlSingle (0);
295                         SqlSingle Test1 = new SqlSingle (250);
296                         SqlSingle Test2 = new SqlSingle (64E+16);
297                         SqlSingle Test3 = new SqlSingle (64E+30);
298                         SqlSingle TestNull = SqlSingle.Null;
299
300                         // ToSqlBoolean ()
301                         Assert.IsTrue (Test1.ToSqlBoolean ().Value, "#M01A");
302                         Assert.IsTrue (!Test0.ToSqlBoolean ().Value, "#M02A");
303                         Assert.IsTrue (TestNull.ToSqlBoolean ().IsNull, "#M03A");
304
305                         // ToSqlByte ()
306                         Assert.AreEqual ((byte)250, Test1.ToSqlByte ().Value, "#M01B");
307                         Assert.AreEqual ((byte)0, Test0.ToSqlByte ().Value, "#M02B");
308
309                         try {
310                                 SqlByte b = (byte)Test2.ToSqlByte ();
311                                 Assert.Fail ("#M03B");
312                         } catch (Exception e) {
313                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04B");
314                         }
315
316                         // ToSqlDecimal ()
317                         Assert.AreEqual (250.00000000000000M, Test1.ToSqlDecimal ().Value, "#M01C");
318                         Assert.AreEqual ((decimal)0, Test0.ToSqlDecimal ().Value, "#M02C");
319
320                         try {
321                                 SqlDecimal test = Test3.ToSqlDecimal ().Value;
322                                 Assert.Fail ("#M03C");
323                         } catch (Exception e) {
324                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04C");
325                         }      
326
327                         // ToSqlInt16 ()
328                         Assert.AreEqual ((short)250, Test1.ToSqlInt16 ().Value, "#M01D");
329                         Assert.AreEqual ((short)0, Test0.ToSqlInt16 ().Value, "#M02D");
330
331                         try {
332                                 SqlInt16 test = Test2.ToSqlInt16().Value;
333                                 Assert.Fail ("#M03D");
334                         } catch (Exception e) {
335                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04D");
336                         }        
337
338                         // ToSqlInt32 ()
339                         Assert.AreEqual ((int)250, Test1.ToSqlInt32 ().Value, "#M01E");
340                         Assert.AreEqual ((int)0, Test0.ToSqlInt32 ().Value, "#M02E");
341
342                         try {
343                                 SqlInt32 test = Test2.ToSqlInt32 ().Value;
344                                 Assert.Fail ("#M03E");
345                         } catch (Exception e) { 
346                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04E");
347                         }
348
349                         // ToSqlInt64 ()
350                         Assert.AreEqual ((long)250, Test1.ToSqlInt64 ().Value, "#M01F");
351                         Assert.AreEqual ((long)0, Test0.ToSqlInt64 ().Value, "#M02F");
352
353                         try {        
354                                 SqlInt64 test = Test3.ToSqlInt64 ().Value;
355                                 Assert.Fail ("#M03F");
356                         } catch (Exception e) {
357                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04F");
358                         }        
359
360                         // ToSqlMoney ()
361                         Assert.AreEqual (250.0000M, Test1.ToSqlMoney ().Value, "#M01G");
362                         Assert.AreEqual ((decimal)0, Test0.ToSqlMoney ().Value, "#M02G");
363
364                         try {
365                                 SqlMoney test = Test3.ToSqlMoney ().Value;
366                                 Assert.Fail ("#M03G");
367                         } catch (Exception e) {
368                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04G");
369                         }        
370
371
372                         // ToSqlString ()
373                         Assert.AreEqual ("250", Test1.ToSqlString ().Value, "#M01H");
374                         Assert.AreEqual ("0", Test0.ToSqlString ().Value, "#M02H");
375                         Assert.AreEqual ("6.4E+17", Test2.ToSqlString ().Value, "#M03H");
376
377                         // ToString ()
378                         Assert.AreEqual ("250", Test1.ToString (), "#M01I");
379                         Assert.AreEqual ("0", Test0.ToString (), "#M02I");
380                         Assert.AreEqual ("6.4E+17", Test2.ToString (), "#M03I");
381                 }
382
383                 // OPERATORS
384
385                 [Test]
386                 public void ArithmeticOperators()
387                 {
388                         SqlSingle Test0 = new SqlSingle (0);
389                         SqlSingle Test1 = new SqlSingle (24E+11);
390                         SqlSingle Test2 = new SqlSingle (64E+32);
391                         SqlSingle Test3 = new SqlSingle (12E+11);
392                         SqlSingle Test4 = new SqlSingle (1E+10);
393                         SqlSingle Test5 = new SqlSingle (2E+10);
394
395                         // "+"-operator
396                         Assert.AreEqual ((SqlSingle)3E+10, Test4 + Test5, "#N01");
397      
398                         try {
399                                 SqlSingle test = SqlSingle.MaxValue + SqlSingle.MaxValue;
400                                 Assert.Fail ("#N02");
401                         } catch (Exception e) {
402                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N03");
403                         }
404
405                         try {
406                                 SqlSingle test = SqlSingle.MaxValue + SqlSingle.MaxValue;
407                         } catch (Exception e) {
408                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N03a");
409                         }
410
411                         // "/"-operator
412                         Assert.AreEqual ((SqlSingle)2, Test1 / Test3, "#N04");
413
414                         try {
415                                 SqlSingle test = Test3 / Test0;
416                                 Assert.Fail ("#N05");
417                         } catch (Exception e) {
418                                 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "#N06");
419                         }
420
421                         // "*"-operator
422                         Assert.AreEqual ((SqlSingle)2E+20, Test4 * Test5, "#N07");
423
424                         try {
425                                 SqlSingle test = SqlSingle.MaxValue * Test1;
426                                 Assert.Fail ("#N08");
427                         } catch (Exception e) {
428                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N09");
429                         }
430
431                         // "-"-operator
432                         Assert.AreEqual ((SqlSingle)12e11, Test1 - Test3, "#N10");
433
434                         try {
435                                 SqlSingle test = SqlSingle.MinValue - SqlSingle.MaxValue;
436                                 Assert.Fail ("#N11");
437                         } catch  (Exception e) {
438                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N12");
439                         }
440                 }
441
442                 [Test]
443                 public void ThanOrEqualOperators()
444                 {
445                         SqlSingle Test1 = new SqlSingle (1.0E+14f);
446                         SqlSingle Test2 = new SqlSingle (9.7E+11);
447                         SqlSingle Test22 = new SqlSingle (9.7E+11);
448                         SqlSingle Test3 = new SqlSingle (2.0E+22f);
449
450                         // == -operator
451                         Assert.IsTrue ((Test2 == Test22).Value, "#O01");
452                         Assert.IsTrue (!(Test1 == Test2).Value, "#O02");
453                         Assert.IsTrue ((Test1 == SqlSingle.Null).IsNull, "#O03");
454                         
455                         // != -operator
456                         Assert.IsTrue (!(Test2 != Test22).Value, "#O04");
457                         Assert.IsTrue ((Test2 != Test3).Value, "#O05");
458                         Assert.IsTrue ((Test1 != Test3).Value, "#O06");
459                         Assert.IsTrue ((Test1 != SqlSingle.Null).IsNull, "#O07");
460
461                         // > -operator
462                         Assert.IsTrue ((Test1 > Test2).Value, "#O08");
463                         Assert.IsTrue (!(Test1 > Test3).Value, "#O09");
464                         Assert.IsTrue (!(Test2 > Test22).Value, "#O10");
465                         Assert.IsTrue ((Test1 > SqlSingle.Null).IsNull, "#O11");
466
467                         // >=  -operator
468                         Assert.IsTrue (!(Test1 >= Test3).Value, "#O12");
469                         Assert.IsTrue ((Test3 >= Test1).Value, "#O13");
470                         Assert.IsTrue ((Test2 >= Test22).Value, "#O14");
471                         Assert.IsTrue ((Test1 >= SqlSingle.Null).IsNull, "#O15");
472
473                         // < -operator
474                         Assert.IsTrue (!(Test1 < Test2).Value, "#O16");
475                         Assert.IsTrue ((Test1 < Test3).Value, "#O17");
476                         Assert.IsTrue (!(Test2 < Test22).Value, "#O18");
477                         Assert.IsTrue ((Test1 < SqlSingle.Null).IsNull, "#O19");
478
479                         // <= -operator
480                         Assert.IsTrue ((Test1 <= Test3).Value, "#O20");
481                         Assert.IsTrue (!(Test3 <= Test1).Value, "#O21");
482                         Assert.IsTrue ((Test2 <= Test22).Value, "#O22");
483                         Assert.IsTrue ((Test1 <= SqlSingle.Null).IsNull, "#O23");
484                 }
485
486                 [Test]
487                 public void UnaryNegation()
488                 {
489                         SqlSingle Test = new SqlSingle (2000000001);
490                         SqlSingle TestNeg = new SqlSingle (-3000);
491
492                         SqlSingle Result = -Test;
493                         Assert.AreEqual ((float)(-2000000001), Result.Value, "#P01");
494
495                         Result = -TestNeg;
496                         Assert.AreEqual ((float)3000, Result.Value, "#P02");
497                 }
498
499                 [Test]
500                 public void SqlBooleanToSqlSingle()
501                 {
502                         SqlBoolean TestBoolean = new SqlBoolean (true);
503                         SqlSingle Result;
504
505                         Result = (SqlSingle)TestBoolean;
506
507                         Assert.AreEqual ((float)1, Result.Value, "#Q01");
508
509                         Result = (SqlSingle)SqlBoolean.Null;
510                         Assert.IsTrue (Result.IsNull, "#Q02");
511                 }
512
513                 [Test]
514                 public void SqlDoubleToSqlSingle()
515                 {
516                         SqlDouble Test = new SqlDouble (12e12);
517                         SqlSingle TestSqlSingle = (SqlSingle)Test;
518                         Assert.AreEqual (12e12f, TestSqlSingle.Value, "R01");
519                 }
520
521                 [Test]
522                 public void SqlSingleToSingle()
523                 {
524                         SqlSingle Test = new SqlSingle (12e12);
525                         Single Result = (Single)Test;
526                         Assert.AreEqual (12e12f, Result, "#S01");
527                 }
528
529                 [Test]
530                 public void SqlStringToSqlSingle()
531                 {
532                         SqlString TestString = new SqlString ("Test string");
533                         SqlString TestString100 = new SqlString ("100");
534
535                         Assert.AreEqual ((float)100, ((SqlSingle)TestString100).Value, "#T01");
536
537                         try {
538                                 SqlSingle test = (SqlSingle)TestString;
539                                 Assert.Fail ("#T02");
540                         } catch(Exception e) {
541                                 Assert.AreEqual (typeof (FormatException), e.GetType (), "#T03");
542                         }
543                 }
544
545                 [Test]
546                 public void ByteToSqlSingle()
547                 {
548                         short TestShort = 14;
549                         Assert.AreEqual ((float)14, ((SqlSingle)TestShort).Value, "#U01");
550                 }
551                 
552                 [Test]
553                 public void SqlDecimalToSqlSingle()
554                 {
555                         SqlDecimal TestDecimal64 = new SqlDecimal (64);
556
557                         Assert.AreEqual ((float)64, ((SqlSingle)TestDecimal64).Value, "#V01");
558                         Assert.AreEqual (SqlSingle.Null, ((SqlSingle)SqlDecimal.Null), "#V02");
559                 }
560
561                 [Test]
562                 public void SqlIntToSqlSingle()
563                 {
564                         SqlInt16 Test64 = new SqlInt16 (64);
565                         SqlInt32 Test640 = new SqlInt32 (640);
566                         SqlInt64 Test64000 = new SqlInt64 (64000);
567                         Assert.AreEqual ((float)64, ((SqlSingle)Test64).Value, "#W01");
568                         Assert.AreEqual ((float)640, ((SqlSingle)Test640).Value, "#W02");
569                         Assert.AreEqual ((float)64000, ((SqlSingle)Test64000).Value, "#W03");
570                 }
571
572                 [Test]
573                 public void SqlMoneyToSqlSingle()
574                 {
575                         SqlMoney TestMoney64 = new SqlMoney(64);
576                         Assert.AreEqual ((float)64, ((SqlSingle)TestMoney64).Value, "#X01");
577                 }
578
579                 [Test]
580                 public void SingleToSqlSingle()
581                 {
582                         Single TestSingle64 = 64;
583                         Assert.AreEqual ((float)64, ((SqlSingle)TestSingle64).Value, "#Y01");
584                 }
585         }
586 }
587