Update how isZero handles Pointers (#181)
* Update how isZero handles Pointers
This commit modifies the isZero function so it checks to see if
a pointer is actually set rather than if it points to a zero value.
* Adding a loop to BuildQueryString to efficiently determine parameter type
* Moving reflect.Ptr to top of BuildQueryString loop
diff --git a/testing/params_test.go b/testing/params_test.go
index 90f3fad..937ff8b 100644
--- a/testing/params_test.go
+++ b/testing/params_test.go
@@ -35,6 +35,7 @@
func TestBuildQueryString(t *testing.T) {
type testVar string
+ iFalse := false
opts := struct {
J int `q:"j"`
R string `q:"r,required"`
@@ -42,6 +43,7 @@
S []string `q:"s"`
TS []testVar `q:"ts"`
TI []int `q:"ti"`
+ F *bool `q:"f"`
}{
J: 2,
R: "red",
@@ -49,8 +51,9 @@
S: []string{"one", "two", "three"},
TS: []testVar{"a", "b"},
TI: []int{1, 2},
+ F: &iFalse,
}
- expected := &url.URL{RawQuery: "c=true&j=2&r=red&s=one&s=two&s=three&ti=1&ti=2&ts=a&ts=b"}
+ expected := &url.URL{RawQuery: "c=true&f=false&j=2&r=red&s=one&s=two&s=three&ti=1&ti=2&ts=a&ts=b"}
actual, err := gophercloud.BuildQueryString(&opts)
if err != nil {
t.Errorf("Error building query string: %v", err)
@@ -64,6 +67,7 @@
S []string `q:"s"`
TS []testVar `q:"ts"`
TI []int `q:"ti"`
+ F *bool `q:"f"`
}{
J: 2,
C: true,