Updated engine tests after replacing MapStorage

This commit is contained in:
adragusin
2019-11-20 16:17:20 +02:00
committed by Dan Christian Bogos
parent 6d5e7d125d
commit d3522ef2e7
10 changed files with 258 additions and 25 deletions

View File

@@ -44,6 +44,48 @@ func (cfs CounterFilters) HasCounter(cf *CounterFilter) bool {
return false
}
// Clone clones *UnitCounter
func (uc *UnitCounter) Clone() (newUnit *UnitCounter) {
if uc == nil {
return
}
newUnit = &UnitCounter{
CounterType: uc.CounterType,
Counters: make(CounterFilters, len(uc.Counters)),
}
for i, counter := range uc.Counters {
newUnit.Counters[i] = counter.Clone()
}
return newUnit
}
// Clone clones *CounterFilter
func (cfs *CounterFilter) Clone() *CounterFilter {
if cfs == nil {
return nil
}
return &CounterFilter{
Value: cfs.Value,
Filter: cfs.Filter.Clone(),
}
}
// Clone clones *UnitCounters
func (ucs UnitCounters) Clone() UnitCounters {
if ucs == nil {
return nil
}
newUnitCounters := make(UnitCounters)
for key, unitCounter := range ucs {
newal := make([]*UnitCounter, len(unitCounter))
for i, uc := range unitCounter {
newal[i] = uc.Clone()
}
newUnitCounters[key] = newal
}
return newUnitCounters
}
// Returns true if the counters were of the same type
// Copies the value from old balances
func (uc *UnitCounter) CopyCounterValues(oldUc *UnitCounter) bool {