| 9 | public class TestDecimal |
| 10 | { |
| 11 | private decimal VerifyDecimal(int low, int mid, int high, bool negative, byte scale) |
| 12 | { |
| 13 | var value1 = new decimal(low, mid, high, negative, scale); |
| 14 | int[] bits = System.Decimal.GetBits(value1); |
| 15 | |
| 16 | if ((bits[0] != low) || (bits[1] != mid) || (bits[2] != high) || (negative ? (bits[3] != (int)((scale << 16) | 0x80000000)) : (bits[3] != (scale << 16)))) |
| 17 | throw new Exception("Invalid decimal bits!"); |
| 18 | |
| 19 | var model = new com.chronoxor.FBE.FieldModelDecimal(new com.chronoxor.FBE.Buffer(new byte[16]), 0); |
| 20 | model.Set(value1); |
| 21 | model.Get(out var value2); |
| 22 | if (value1 != value2) |
| 23 | throw new Exception("Invalid decimal serialization!"); |
| 24 | |
| 25 | var final = new com.chronoxor.FBE.FinalModelDecimal(new com.chronoxor.FBE.Buffer(new byte[16]), 0); |
| 26 | final.Set(value1); |
| 27 | final.Get(out var value3); |
| 28 | if (value1 != value3) |
| 29 | throw new Exception("Invalid decimal final serialization!"); |
| 30 | |
| 31 | return value1; |
| 32 | } |
| 33 | |
| 34 | [Fact(DisplayName = "Decimal tests")] |
| 35 | public void DecimalTests() |