-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 290_explainability_public_ip_grouping
- Loading branch information
Showing
19 changed files
with
1,279 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_main(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
args string | ||
}{ | ||
{"drawio_multi_vpc", "-output-file aaa.drawio -vpc-config ../../pkg/ibmvpc/examples/input_multiple_vpcs.json -format drawio"}, | ||
{"txt_multi_vpc", "-output-file aaa.txt -vpc-config ../../pkg/ibmvpc/examples/input_multiple_vpcs.json -format txt"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if err := _main(strings.Split(tt.args, " ")); err != nil { | ||
t.Errorf("_main(), name %s, error = %v", tt.name, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
// a genericSet is a generic implementation of a set. | ||
// the main functionality of genericSet is asKey() - conversion to a string. | ||
// asKey() is needed for using genericSet as a key of a map | ||
// ////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
type GenericSet[T comparable] map[T]bool | ||
type SetAsKey string | ||
|
||
func (s GenericSet[T]) AsKey() SetAsKey { | ||
ss := []string{} | ||
for i := range s { | ||
key := "" | ||
rv := reflect.ValueOf(i) | ||
if rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Interface { | ||
key = fmt.Sprintf("%x", rv.Pointer()) | ||
} else { | ||
key = fmt.Sprint(i) | ||
} | ||
ss = append(ss, key) | ||
} | ||
sort.Strings(ss) | ||
return SetAsKey(strings.Join(ss, ",")) | ||
} | ||
|
||
func (s GenericSet[T]) AsList() []T { | ||
keys := make([]T, len(s)) | ||
i := 0 | ||
for k := range s { | ||
keys[i] = k | ||
i++ | ||
} | ||
return keys | ||
} | ||
|
||
func (s GenericSet[T]) IsIntersect(s2 GenericSet[T]) bool { | ||
for i := range s { | ||
if (s2)[i] { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.