put reference of the slices in array not slice ref value

This commit is contained in:
Radu Ioan Fericean
2013-04-14 15:13:04 +03:00
parent 660b7a5d3f
commit 52b1358e9a
3 changed files with 38 additions and 5 deletions

22
cache2go/.gitignore vendored Normal file
View File

@@ -0,0 +1,22 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe

View File

@@ -158,7 +158,7 @@ func (m *Mediator) parseCSV(cdrfn string) (err error) {
w := bufio.NewWriter(fout)
for record, ok := csvReader.Read(); ok == nil; record, ok = csvReader.Read() {
//t, _ := time.Parse("2012-05-21 17:48:20", record[5])
//t, _ := time.Parse("2006-01-02 15:04:05", record[5])
var cc *rater.CallCost
for runIdx, idxVal := range m.subjectIndexs { // Query costs for every run index given by subject
if idxVal == -1 { // -1 as subject means use database to get previous set price

View File

@@ -30,8 +30,8 @@ func TestIndexLoadEmpty(t *testing.T) {
func TestIndexLengthSame(t *testing.T) {
m := new(Mediator)
objs := []mediatorFieldIdxs{m.directionIndexs, m.torIndexs, m.tenantIndexs, m.subjectIndexs,
m.accountIndexs, m.destinationIndexs, m.timeStartIndexs, m.durationIndexs, m.uuidIndexs}
objs := []*mediatorFieldIdxs{&m.directionIndexs, &m.torIndexs, &m.tenantIndexs, &m.subjectIndexs,
&m.accountIndexs, &m.destinationIndexs, &m.timeStartIndexs, &m.durationIndexs, &m.uuidIndexs}
for _, o := range objs {
o.Load("1,2,3")
}
@@ -42,8 +42,8 @@ func TestIndexLengthSame(t *testing.T) {
func TestIndexLengthDifferent(t *testing.T) {
m := new(Mediator)
objs := []mediatorFieldIdxs{m.directionIndexs, m.torIndexs, m.tenantIndexs, m.subjectIndexs,
m.accountIndexs, m.timeStartIndexs, m.durationIndexs, m.uuidIndexs}
objs := []*mediatorFieldIdxs{&m.directionIndexs, &m.torIndexs, &m.tenantIndexs, &m.subjectIndexs,
&m.accountIndexs, &m.timeStartIndexs, &m.durationIndexs, &m.uuidIndexs}
for _, o := range objs {
o.Load("1,2,3")
}
@@ -52,3 +52,14 @@ func TestIndexLengthDifferent(t *testing.T) {
t.Error("Error checking length")
}
}
func TestLoad(t *testing.T) {
m := new(Mediator)
objs := []*mediatorFieldIdxs{&m.directionIndexs}
for _, o := range objs {
o.Load("1,2,3")
}
if len(m.directionIndexs) != 3 {
t.Errorf("Expected %v was %v", 3, len(m.directionIndexs))
}
}