mirror of
https://github.com/ManyakRus/starter.git
synced 2025-11-23 22:45:11 +02:00
сделал humanize
This commit is contained in:
@@ -2,8 +2,8 @@ package humanize
|
||||
|
||||
import "github.com/dustin/go-humanize"
|
||||
|
||||
// StringFromFloat64_underline - преобразование float64 в строку, с разделителями тысяч
|
||||
func StringFromFloat64_underline(f float64) string {
|
||||
// StringFromFloat64_underline_dimension2 - преобразование float64 в строку, с разделителями тысяч
|
||||
func StringFromFloat64_underline_dimension2(f float64) string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = humanize.FormatFloat("#_###.##", f)
|
||||
@@ -11,8 +11,8 @@ func StringFromFloat64_underline(f float64) string {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// StringFromFloat32_underline - преобразование float64 в строку, с разделителями тысяч
|
||||
func StringFromFloat32_underline(f float32) string {
|
||||
// StringFromFloat32_underline_dimension2 - преобразование float64 в строку, с разделителями тысяч
|
||||
func StringFromFloat32_underline_dimension2(f float32) string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = humanize.FormatFloat("#_###.##", float64(f))
|
||||
@@ -20,6 +20,24 @@ func StringFromFloat32_underline(f float32) string {
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// StringFromFloat64_underline_dimension0 - преобразование float64 в строку, с разделителями тысяч
|
||||
func StringFromFloat64_underline_dimension0(f float64) string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = humanize.FormatFloat("#_###.", f)
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// StringFromFloat32_underline_dimension0 - преобразование float64 в строку, с разделителями тысяч
|
||||
func StringFromFloat32_underline_dimension0(f float32) string {
|
||||
Otvet := ""
|
||||
|
||||
Otvet = humanize.FormatFloat("#_###.", float64(f))
|
||||
|
||||
return Otvet
|
||||
}
|
||||
|
||||
// StringFromInt_underline - преобразование int в строку, с разделителями тысяч
|
||||
func StringFromInt_underline(i int) string {
|
||||
Otvet := ""
|
||||
|
||||
@@ -2,22 +2,38 @@ package humanize
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestStringFromFloat64_underline(t *testing.T) {
|
||||
func TestStringFromFloat64_underline_dimension2(t *testing.T) {
|
||||
|
||||
Otvet := StringFromFloat64_underline(1123.456)
|
||||
Otvet := StringFromFloat64_underline_dimension2(1123.456)
|
||||
if Otvet != "1_123.46" {
|
||||
t.Error("Error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringFromFloat32_underline(t *testing.T) {
|
||||
func TestStringFromFloat32_underline_dimension2(t *testing.T) {
|
||||
|
||||
Otvet := StringFromFloat32_underline(1123.456)
|
||||
Otvet := StringFromFloat32_underline_dimension2(1123.456)
|
||||
if Otvet != "1_123.46" {
|
||||
t.Error("Error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringFromFloat64_underline_dimension0(t *testing.T) {
|
||||
|
||||
Otvet := StringFromFloat64_underline_dimension0(1123.456)
|
||||
if Otvet != "1_123" {
|
||||
t.Error("Error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringFromFloat32_underline_dimension0(t *testing.T) {
|
||||
|
||||
Otvet := StringFromFloat32_underline_dimension0(1123.456)
|
||||
if Otvet != "1_123" {
|
||||
t.Error("Error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringFromInt_underline(t *testing.T) {
|
||||
Otvet := StringFromInt_underline(1123)
|
||||
if Otvet != "1_123" {
|
||||
|
||||
Reference in New Issue
Block a user