本文整理汇总了Golang中github.com/jbowles/money.Money.StringD方法的典型用法代码示例。如果您正苦于以下问题:Golang Money.StringD方法的具体用法?Golang Money.StringD怎么用?Golang Money.StringD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jbowles/money.Money
的用法示例。
在下文中一共展示了Money.StringD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMoneyNegNotMutable
// Neg value make sure 'val' is not updated
func TestMoneyNegNotMutable(t *testing.T) {
val := money.Money{M: 123456}
neg := val.Neg()
if val.Valuei() != int64(123456) {
t.Error("val should be int64 '123456'", val.Valuei())
}
if val.Valuef() != float64(1234.56) {
t.Error("val should be int64 '1234.56'", val.Valuef())
}
if neg.Valuei() != int64(-123456) {
t.Error("neg.Valuei should be int64 '-123456'", neg.Valuei())
}
if neg.Valuef() != float64(-1234.56) {
t.Error("neg.Valuef should be float64 '-1234.56'", neg.Valuef())
}
if val.StringD() != "1234.56" {
t.Error("val.StringD() should be '1234.56'", val.StringD())
}
// TODO oddity for negative money values!!!!
if neg.StringD() != "-1234.56" {
t.Error("neg.StringD() should be '-1234.56'", neg.StringD())
}
}
示例2: TestMoneyStringWithUpdate
func TestMoneyStringWithUpdate(t *testing.T) {
m := money.Money{M: 67}
if m.StringD() != "0.67" {
t.Error("wanted to see '0.67' cents but got: ", m.StringD())
}
var val2 int64 = 6700
m.Updatei(val2)
if m.StringD() != "67.00" {
t.Error("wanted to see '67.00' dollars but got: ", m.StringD())
}
}
示例3: TestMoneyValueIntAndFloat
func TestMoneyValueIntAndFloat(t *testing.T) {
val := money.Money{M: 123456}
if val.Valuei() != int64(123456) {
t.Error("Valuei() should be int64 '123456'", val.Valuei())
}
if val.Valuef() != float64(1234.56) {
t.Error("Valuef() should be float64 '123456'", val.Valuef())
}
if val.ValueiTrunc() != int64(1234) {
t.Error("ValueiTrunc() should be int64 '1234'", val.ValueiTrunc())
}
if val.StringD() != "1234.56" {
t.Error("money struct init StringD() should be value '1234.56'", val.StringD())
}
if val.StringC() != "1234,56" {
t.Error("money struct init StringC() should be value '1234,56'", val.StringC())
}
}