github.com/condensat/bank-core@v0.1.0/database/model/utils_test.go (about) 1 // Copyright 2020 Condensat Tech. All rights reserved. 2 // Use of this source code is governed by a MIT 3 // license that can be found in the LICENSE file. 4 5 package model 6 7 import "testing" 8 9 func TestToFixedFloat(t *testing.T) { 10 type args struct { 11 value Float 12 } 13 tests := []struct { 14 name string 15 args args 16 want Float 17 }{ 18 {"zero", args{0.0}, 0.0}, 19 {"piMax", args{3.14159265358979}, 3.14159265359}, 20 {"piOverflow", args{3.14159265358979}, 3.14159265359}, 21 {"roundFloor", args{0.1234567890121}, 0.123456789012}, 22 {"roundCeil", args{0.1234567890129}, 0.123456789013}, 23 24 {"roundBig", args{2.1e+11}, 2.1e+11}, 25 {"roundSmall", args{2.1e-11}, 2.1e-11}, 26 } 27 for _, tt := range tests { 28 t.Run(tt.name, func(t *testing.T) { 29 if got := ToFixedFloat(tt.args.value); got != tt.want { 30 t.Errorf("ToFixedFloat() = %v, want %v", got, tt.want) 31 } 32 }) 33 } 34 }