1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:30:06 -07:00

net/http/httputil: adds tests for singleJoiningSlash.

These changes add tests for the unexported function singleJoiningSlash.
This commit is contained in:
Bobby DeSimone 2018-12-03 16:52:54 -08:00
parent 58ffe5059f
commit ed6f86f619
No known key found for this signature in database
GPG Key ID: AEE4CF12FE86D07E

View File

@ -7,23 +7,23 @@
package httputil
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
"strconv"
"strings"
"sync"
"testing"
"time"
"reflect"
"io"
"strings"
"bufio"
"sync"
"strconv"
"bytes"
"errors"
"fmt"
"os"
)
const fakeHopHeader = "X-Fake-Hop-Header-For-Test"
@ -1078,3 +1078,26 @@ func TestUnannouncedTrailer(t *testing.T) {
}
}
func TestSingleJoinSlash(t *testing.T) {
tests := []struct {
slasha string
slashb string
expected string
}{
{"https://www.google.com/", "/favicon.ico", "https://www.google.com/favicon.ico"},
{"https://www.google.com", "/favicon.ico", "https://www.google.com/favicon.ico"},
{"https://www.google.com", "favicon.ico", "https://www.google.com/favicon.ico"},
{"https://www.google.com", "", "https://www.google.com/"},
{"", "favicon.ico", "/favicon.ico"},
}
for _, tt := range tests {
if got := singleJoiningSlash(tt.slasha, tt.slashb); got != tt.expected {
t.Errorf("singleJoiningSlash(%s,%s) want %s got %s",
tt.slasha,
tt.slashb,
tt.expected,
got)
}
}
}