作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !3
@@ -125,8 +125,8 @@ var ( @@ -125,8 +125,8 @@ var (
125 Int SQLType = "INT" 125 Int SQLType = "INT"
126 BigInt SQLType = "BIGINT" 126 BigInt SQLType = "BIGINT"
127 Float SQLType = "FLOAT" 127 Float SQLType = "FLOAT"
128 - DECIMALV2 SQLType = "DECIMAL(20,15)" //"DECIMALV2"  
129 - DECIMAL279 SQLType = "DECIMAL(20,15)" 128 + DECIMALV2 SQLType = "DECIMAL(35,15)" //"DECIMALV2"
  129 + DECIMAL279 SQLType = "DECIMAL(35,15)"
130 Date SQLType = "DATE" 130 Date SQLType = "DATE"
131 Datetime SQLType = "DATETIME" 131 Datetime SQLType = "DATETIME"
132 ) 132 )
@@ -250,7 +250,7 @@ func RoundFieldValue(f *Field, v string) string { @@ -250,7 +250,7 @@ func RoundFieldValue(f *Field, v string) string {
250 if err != nil { 250 if err != nil {
251 return v 251 return v
252 } 252 }
253 - return fmt.Sprintf("%v", fv) 253 + return utils.AssertString(fv) //fmt.Sprintf("%v", fv)
254 } 254 }
255 return v 255 return v
256 //if f.SQLType != DECIMALV2.ToString() { 256 //if f.SQLType != DECIMALV2.ToString() {
@@ -269,7 +269,7 @@ func RoundValue(v string) string { @@ -269,7 +269,7 @@ func RoundValue(v string) string {
269 if err != nil { 269 if err != nil {
270 return v 270 return v
271 } 271 }
272 - return fmt.Sprintf("%v", fv) 272 + return utils.AssertString(fv) //fmt.Sprintf("%v", fv)
273 } 273 }
274 274
275 func GripData(data []map[string]string, total int64) map[string]interface{} { 275 func GripData(data []map[string]string, total int64) map[string]interface{} {
@@ -15,19 +15,24 @@ func TestRoundFieldValue(t *testing.T) { @@ -15,19 +15,24 @@ func TestRoundFieldValue(t *testing.T) {
15 want string 15 want string
16 }{ 16 }{
17 { 17 {
18 - v: "0.12359999999999999", 18 + v: "0.123599999999999",
19 f: floatFiled, 19 f: floatFiled,
20 - want: "0.1236", 20 + want: "0.123599999999999",
21 }, 21 },
22 { 22 {
23 - v: "0.12360000000000001", 23 + v: "0.123600000000001",
24 f: floatFiled, 24 f: floatFiled,
25 - want: "0.1236", 25 + want: "0.123600000000001",
26 }, 26 },
27 { 27 {
28 - v: "0.12359999999999995", 28 + v: "0.12359990000000",
29 f: floatFiled, 29 f: floatFiled,
30 - want: "0.1236", 30 + want: "0.1235999",
  31 + },
  32 + {
  33 + v: "18749465132.256",
  34 + f: floatFiled,
  35 + want: "18749465132.256",
31 }, 36 },
32 } 37 }
33 for _, input := range inputs { 38 for _, input := range inputs {
@@ -35,3 +40,39 @@ func TestRoundFieldValue(t *testing.T) { @@ -35,3 +40,39 @@ func TestRoundFieldValue(t *testing.T) {
35 assert.Equal(t, input.want, got) 40 assert.Equal(t, input.want, got)
36 } 41 }
37 } 42 }
  43 +
  44 +func TestRoundValue(t *testing.T) {
  45 + floatFiled := &Field{
  46 + SQLType: Float.ToString(),
  47 + }
  48 + inputs := []struct {
  49 + v string
  50 + f *Field
  51 + want string
  52 + }{
  53 + {
  54 + v: "0.123599999999999",
  55 + f: floatFiled,
  56 + want: "0.123599999999999",
  57 + },
  58 + {
  59 + v: "0.123600000000001",
  60 + f: floatFiled,
  61 + want: "0.123600000000001",
  62 + },
  63 + {
  64 + v: "0.123599999999995",
  65 + f: floatFiled,
  66 + want: "0.123599999999995",
  67 + },
  68 + {
  69 + v: "18749465132.256",
  70 + f: floatFiled,
  71 + want: "18749465132.256",
  72 + },
  73 + }
  74 + for _, input := range inputs {
  75 + got := RoundValue(input.v)
  76 + assert.Equal(t, input.want, got)
  77 + }
  78 +}