Commit a9757a14 authored by santiaago's avatar santiaago
Browse files

add xtriangles test #55

parent 7b9c1c1d
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -231,3 +231,25 @@ func TestXSquares(t *testing.T) {
		}
	}
}

func TestXTriangles(t *testing.T) {
	tests := []struct {
		title string
		url   string
		xt    int
	}{
		{"test wrong input", "http://www.tg.c?xt=hello", 50},
		{"test no input", "http://www.tg.c", 50},
		{"test good input", "http://www.tg.c?xt=4", 4},
	}

	for _, test := range tests {
		t.Log(test.title)
		r := &http.Request{Method: "GET"}
		r.URL, _ = url.Parse(test.url)
		xt := XTriangles(r)
		if xt != test.xt {
			t.Errorf("expected %d got %d", test.xt, xt)
		}
	}
}