X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Frmrendpointlist_test.go;h=b85c1a682ad28885c63c365040ab192110a4eaf2;hb=refs%2Fchanges%2F12%2F8912%2F1;hp=cbef96e2482737d391755cb7f9e6331135d0d5c8;hpb=622bae3417eaaacfb798a82d530363f3c278e993;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/rmrendpointlist_test.go b/pkg/xapp/rmrendpointlist_test.go old mode 100644 new mode 100755 index cbef96e..b85c1a6 --- a/pkg/xapp/rmrendpointlist_test.go +++ b/pkg/xapp/rmrendpointlist_test.go @@ -20,13 +20,59 @@ package xapp import ( + "fmt" "testing" ) +func TestRmrEndpoint1(t *testing.T) { + addr := "127.0.0.1" + port := uint16(8080) + str := fmt.Sprintf("%s:%d", addr, port) + Logger.Info("CASE: TestRmrEndpoint1 %s", str) + ep := NewRmrEndpoint(str) + if ep == nil || ep.Addr != addr || ep.Port != port { + t.Errorf("NewRmrEndpoint: %s failed", str) + } +} + +func TestRmrEndpoint2(t *testing.T) { + addr := "[2001:2003:fb69:ea00:c894:288b:4582:b5c/64]" + port := uint16(8080) + str := fmt.Sprintf("%s:%d", addr, port) + Logger.Info("CASE: TestRmrEndpoint2 %s", str) + ep := NewRmrEndpoint(str) + if ep == nil || ep.Addr != addr || ep.Port != port { + t.Errorf("NewRmrEndpoint: %s failed", str) + } +} + +func TestRmrEndpoint3(t *testing.T) { + addr := "127.0.0.1" + str := fmt.Sprintf("%s:port", addr) + Logger.Info("CASE: TestRmrEndpoint3 %s", str) + ep := NewRmrEndpoint(str) + if ep != nil { + t.Errorf("NewRmrEndpoint: %s successful while should fail", str) + } +} + +func TestRmrEndpoint4(t *testing.T) { + addr := "127.0.0.1" + str := fmt.Sprintf("%s:port", addr) + Logger.Info("CASE: TestRmrEndpoint4 %s", str) + ep := &RmrEndpoint{} + if ep.Set(str) == true { + t.Errorf("NewRmrEndpoint: Set %s successful while should fail", str) + } + if ep.Addr != "" || ep.Port != 0 { + t.Errorf("NewRmrEndpoint: Values %s successful while should fail", str) + } +} + func TestRmrEndpointList(t *testing.T) { Logger.Info("CASE: TestRmrEndpointList") - epl := &RmrEndpointList{} + epl := NewRmrEndpointList() // Simple add / has / delete if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false { @@ -41,6 +87,9 @@ func TestRmrEndpointList(t *testing.T) { if epl.HasEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false { t.Errorf("RmrEndpointList: 8081 has failed") } + + Logger.Info("%+v -- %+v -- %d", epl.String(), epl.StringList(), epl.Size()) + if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false { t.Errorf("RmrEndpointList: 8081 del failed") }