You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/05/25 16:00:21 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #6852: Move duplicate rand functionality to test rand

ocket8888 commented on code in PR #6852:
URL: https://github.com/apache/trafficcontrol/pull/6852#discussion_r881829451


##########
traffic_ops/traffic_ops_golang/test/rand.go:
##########
@@ -36,3 +38,68 @@ func RandStrArray() []string {
 	}
 	return sArray
 }
+
+func RandBool() *bool {
+	b := rand.Int()%2 == 0
+	return &b
+}
+
+func RandInt() *int {
+	i := rand.Int()
+	return &i
+}
+func RandInt64() *int64 {
+	i := rand.Int63()
+	return &i
+}
+
+func RandUint64() *uint64 {
+	i := uint64(rand.Int63())
+	return &i
+}
+
+func RandUint() *uint {
+	i := uint(rand.Int())
+	return &i
+}
+
+func RandIntn(n int) *int {
+	i := rand.Intn(n)
+	return &i
+}
+
+func RandFloat64() *float64 {
+	f := rand.Float64()
+	return &f
+}
+
+func RandomIPv4() *string {
+	first := rand.Int31n(256)
+	second := rand.Int31n(256)
+	third := rand.Int31n(256)
+	fourth := rand.Int31n(256)
+	str := fmt.Sprintf("%d.%d.%d.%d", first, second, third, fourth)
+	return &str
+}
+
+func RandomIPv6() *string {
+	ip := net.IP([]byte{
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+		uint8(rand.Int31n(256)),
+	}).String()
+	return &ip
+}

Review Comment:
   GoDocs?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org