1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package main
import (
"testing"
)
func TestURL(t *testing.T) {
f := flat{ID: 0, Price: "£1,000"}
got := f.URL()
want := "https://rightmove.co.uk/properties/0"
if got != want {
t.Errorf("URL call failed: got: %v, want: %v", got, want)
}
}
func TestCompareID(t *testing.T) {
a := flat{ID: 0, Price: "£3,000"}
b := flat{ID: 1, Price: "£1,000"}
got := compareID(a, b)
if got != -1 {
t.Errorf("Wrong compare result: got: %v, want: %v", got, -1)
}
got = compareID(b, a)
if got != 1 {
t.Errorf("Wrong compare result: got: %v, want: %v", got, 1)
}
got = compareID(a, a)
if got != 0 {
t.Errorf("Wrong compare result: got: %v, want: %v", got, 0)
}
}
|