mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http/httputil: add tests for singleJoiningSlash.
These changes add tests for the unexported function singleJoiningSlash.
Change-Id: I107905aac4a3c2544be309098b67e970ea5b542c
GitHub-Last-Rev: ed6f86f619
GitHub-Pull-Request: golang/go#29088
Reviewed-on: https://go-review.googlesource.com/c/152337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
b0a53d2202
commit
ea509c95e9
1 changed files with 33 additions and 10 deletions
|
|
@ -7,23 +7,23 @@
|
||||||
package httputil
|
package httputil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"reflect"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
"bufio"
|
|
||||||
"sync"
|
|
||||||
"strconv"
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const fakeHopHeader = "X-Fake-Hop-Header-For-Test"
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue