|
| 1 | +/* |
| 2 | + * The contents of this file are subject to the Initial |
| 3 | + * Developer's Public License Version 1.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the |
| 5 | + * License. You may obtain a copy of the License at |
| 6 | + * https://github.com/FirebirdSQL/NETProvider/blob/master/license.txt. |
| 7 | + * |
| 8 | + * Software distributed under the License is distributed on |
| 9 | + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either |
| 10 | + * express or implied. See the License for the specific |
| 11 | + * language governing rights and limitations under the License. |
| 12 | + * |
| 13 | + * All Rights Reserved. |
| 14 | + */ |
| 15 | + |
| 16 | +//$Authors = Jiri Cincura ([email protected]) |
| 17 | + |
| 18 | +using System.Numerics; |
| 19 | +using FirebirdSql.Data.Types; |
| 20 | +using NUnit.Framework; |
| 21 | + |
| 22 | +namespace FirebirdSql.Data.FirebirdClient.Tests |
| 23 | +{ |
| 24 | + public class FbDecFloatTests |
| 25 | + { |
| 26 | + static readonly object[] SimpleEqualityTrueSource = new object[] |
| 27 | + { |
| 28 | + new object[] { new FbDecFloat(0), new FbDecFloat(0) }, |
| 29 | + new object[] { new FbDecFloat(10, 0), new FbDecFloat(10, 0) }, |
| 30 | + new object[] { new FbDecFloat(6, 3), new FbDecFloat(6, 3) }, |
| 31 | + new object[] { new FbDecFloat(6, -3), new FbDecFloat(6, -3) }, |
| 32 | + new object[] { new FbDecFloat(-6, 3), new FbDecFloat(-6, 3) }, |
| 33 | + new object[] { new FbDecFloat(-6, -3), new FbDecFloat(-6, -3) }, |
| 34 | + new object[] { new FbDecFloat(BigInteger.Parse("986767875675879890678765756798079808709"), 1), new FbDecFloat(BigInteger.Parse("986767875675879890678765756798079808709"), 1) }, |
| 35 | + new object[] { new FbDecFloat(10, 3), new FbDecFloat(100, 2) }, |
| 36 | + new object[] { new FbDecFloat(-10, 3), new FbDecFloat(-100, 2) }, |
| 37 | + new object[] { new FbDecFloat(10, -3), new FbDecFloat(1, -2) }, |
| 38 | + new object[] { new FbDecFloat(-10, -3), new FbDecFloat(-1, -2) }, |
| 39 | + new object[] { FbDecFloat.PositiveInfinity, FbDecFloat.PositiveInfinity }, |
| 40 | + new object[] { FbDecFloat.NegativeInfinity, FbDecFloat.NegativeInfinity }, |
| 41 | + new object[] { FbDecFloat.PositiveNaN, FbDecFloat.PositiveNaN }, |
| 42 | + }; |
| 43 | + [TestCaseSource(nameof(SimpleEqualityTrueSource))] |
| 44 | + public void EqualityTrue(FbDecFloat expected, FbDecFloat actual) |
| 45 | + { |
| 46 | + Assert.AreEqual(expected, actual); |
| 47 | + } |
| 48 | + |
| 49 | + static readonly object[] SimpleEqualityFalseSource = new object[] |
| 50 | + { |
| 51 | + new object[] { new FbDecFloat(0), new FbDecFloat(BigInteger.Parse("986767875675879890678765756798079808709")) }, |
| 52 | + new object[] { new FbDecFloat(6, 3), new FbDecFloat(-6, 3) }, |
| 53 | + new object[] { new FbDecFloat(6, 3), new FbDecFloat(6, -3) }, |
| 54 | + new object[] { FbDecFloat.PositiveInfinity, FbDecFloat.NegativeInfinity }, |
| 55 | + new object[] { FbDecFloat.PositiveNaN, FbDecFloat.NegativeNaN }, |
| 56 | + new object[] { FbDecFloat.PositiveInfinity, FbDecFloat.PositiveNaN }, |
| 57 | + new object[] { FbDecFloat.NegativeInfinity, FbDecFloat.NegativeNaN }, |
| 58 | + }; |
| 59 | + [TestCaseSource(nameof(SimpleEqualityFalseSource))] |
| 60 | + public void EqualityFalse(FbDecFloat expected, FbDecFloat actual) |
| 61 | + { |
| 62 | + Assert.AreNotEqual(expected, actual); |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments