mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
first timespans compress test
This commit is contained in:
@@ -185,6 +185,7 @@ func (tss TimeSpans) Decompress() {
|
||||
incrs = append(incrs, cIncr.Clone())
|
||||
}
|
||||
}
|
||||
ts.Increments = incrs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1491,3 +1491,55 @@ func TestOverlapWithTimeSpansOne(t *testing.T) {
|
||||
t.Error("Error overlaping with timespans timespans: ", tss)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTSCompressDecompress(t *testing.T) {
|
||||
tss := TimeSpans{
|
||||
&TimeSpan{
|
||||
Increments: Increments{
|
||||
&Increment{
|
||||
Duration: time.Minute,
|
||||
Cost: 10.4,
|
||||
BalanceInfo: &BalanceInfo{"1", "2", "3"},
|
||||
BalanceRateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
|
||||
MinuteInfo: &MinuteInfo{"1", 2.3},
|
||||
},
|
||||
&Increment{
|
||||
Duration: time.Minute,
|
||||
Cost: 10.4,
|
||||
BalanceInfo: &BalanceInfo{"1", "2", "3"},
|
||||
BalanceRateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
|
||||
MinuteInfo: &MinuteInfo{"1", 2.3},
|
||||
},
|
||||
&Increment{
|
||||
Duration: time.Minute,
|
||||
Cost: 10.4,
|
||||
BalanceInfo: &BalanceInfo{"1", "2", "3"},
|
||||
BalanceRateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
|
||||
MinuteInfo: &MinuteInfo{"1", 2.3},
|
||||
},
|
||||
&Increment{
|
||||
Duration: time.Minute,
|
||||
Cost: 10.4,
|
||||
BalanceInfo: &BalanceInfo{"1", "2", "3"},
|
||||
BalanceRateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 1111 * time.Second, RateUnit: time.Second}}}},
|
||||
MinuteInfo: &MinuteInfo{"1", 2.3},
|
||||
},
|
||||
&Increment{
|
||||
Duration: time.Minute,
|
||||
Cost: 10.4,
|
||||
BalanceInfo: &BalanceInfo{"1", "2", "3"},
|
||||
BalanceRateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
|
||||
MinuteInfo: &MinuteInfo{"1", 2.3},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
tss.Compress()
|
||||
if len(tss[0].Increments) != 3 {
|
||||
t.Error("Error compressing timespan: ", tss[0].Increments)
|
||||
}
|
||||
tss.Decompress()
|
||||
if len(tss[0].Increments) != 5 {
|
||||
t.Error("Error decompressing timespans: ", tss[0].Increments)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user