@@ -230,3 +230,44 @@ func TestGetMin(t *testing.T) {
230
230
}
231
231
}
232
232
}
233
+
234
+ type tcURLList struct {
235
+ in string
236
+ out bool
237
+ }
238
+
239
+ func TestValidURL (t * testing.T ) {
240
+ testcases := []tcURLList {
241
+ {"https://ssoTestURL.okta.com" , true },
242
+ {"https://ssoTestURL.okta.com:8080" , true },
243
+ {"https://ssoTestURL.okta.com/testpathvalue" , true },
244
+ {"-a calculator" , false },
245
+ {"This is a random test" , false },
246
+ {"file://TestForFile" , false },
247
+ }
248
+ for _ , test := range testcases {
249
+ result := isValidURL (test .in )
250
+ if test .out != result {
251
+ t .Errorf ("Failed to validate URL, input :%v, expected: %v, got: %v" , test .in , test .out , result )
252
+ }
253
+ }
254
+ }
255
+
256
+ type tcEncodeList struct {
257
+ in string
258
+ out string
259
+ }
260
+
261
+ func TestEncodeURL (t * testing.T ) {
262
+ testcases := []tcEncodeList {
263
+ {"Hello @World" , "Hello+%40World" },
264
+ {"Test//String" , "Test%2F%2FString" },
265
+ }
266
+
267
+ for _ , test := range testcases {
268
+ result := urlEncode (test .in )
269
+ if test .out != result {
270
+ t .Errorf ("Failed to encode string, input %v, expected: %v, got: %v" , test .in , test .out , result )
271
+ }
272
+ }
273
+ }
0 commit comments