mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add unit tests on utils
This commit is contained in:
committed by
Dan Christian Bogos
parent
044e56a6a4
commit
b4f889247f
@@ -29,6 +29,7 @@ import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/cgrates/rpcclient"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestGetStartTime(t *testing.T) {
|
||||
@@ -1820,3 +1821,36 @@ func TestCoreUtilsFibDurationSeqNrOverflow(t *testing.T) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", math.MaxInt, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreUtilsMapStringSlicePointer(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input map[string][]string
|
||||
expected *map[string][]string
|
||||
}{
|
||||
{
|
||||
name: "Empty map",
|
||||
input: map[string][]string{},
|
||||
expected: &map[string][]string{},
|
||||
},
|
||||
{
|
||||
name: "Non-empty map",
|
||||
input: map[string][]string{
|
||||
"key1": {"value1", "value2"},
|
||||
"key2": {"value3"},
|
||||
},
|
||||
expected: &map[string][]string{
|
||||
"key1": {"value1", "value2"},
|
||||
"key2": {"value3"},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
result := MapStringSlicePointer(test.input)
|
||||
if diff := cmp.Diff(result, test.expected); diff != "" {
|
||||
t.Errorf("Test case %q failed: (-got +want)\n%s", test.name, diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user