diff options
Diffstat (limited to 'flat_test.go')
-rw-r--r-- | flat_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/flat_test.go b/flat_test.go new file mode 100644 index 0000000..2ac3ddb --- /dev/null +++ b/flat_test.go @@ -0,0 +1,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) + } +} |