Skip to content

Commit

Permalink
Reflect inf/dec changes in integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6e6562 committed Feb 25, 2014
1 parent ea4ac4e commit cc2dfe7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package gocql
import (
"bytes"
"flag"
"math/big"
"reflect"
"sort"
"speter.net/go/exp/math/dec/inf"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -303,7 +303,7 @@ type Page struct {
Views int64
Protected bool
Modified time.Time
Rating *big.Rat
Rating *inf.Dec
Tags []string
Attachments map[string]Attachment
}
Expand All @@ -315,7 +315,7 @@ var pageTestData = []*Page{
Title: "Frontpage",
RevId: TimeUUID(),
Body: "Welcome to this wiki page!",
Rating: big.NewRat(871298379, 243),
Rating: inf.NewDec(871298379, 243),
Modified: time.Date(2013, time.August, 13, 9, 52, 3, 0, time.UTC),
Tags: []string{"start", "important", "test"},
Attachments: map[string]Attachment{
Expand Down
3 changes: 3 additions & 0 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ func marshalDecimal(info *TypeInfo, value interface{}) ([]byte, error) {
}

unscaled := v.UnscaledBig().Bytes()
if len(unscaled) == 0 {
unscaled = []byte{0}
}
scale := v.Scale()
buf := make([]byte, 4+len(unscaled))
binary.BigEndian.PutUint32(buf, uint32(scale))
Expand Down
2 changes: 1 addition & 1 deletion marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var marshalTests = []struct {
{
&TypeInfo{Type: TypeDecimal},
[]byte("\x00\x00\x00\x00\x00"),
inf.NewDec(0, 1),
inf.NewDec(0, 0),
},
{
&TypeInfo{Type: TypeTimestamp},
Expand Down

0 comments on commit cc2dfe7

Please sign in to comment.