From 96bcc15d6e3e820309c874fe39df11cb88b30af2 Mon Sep 17 00:00:00 2001 From: Dmitry Ilvokhin Date: Sat, 1 Mar 2025 20:10:26 +0000 Subject: Split logic to multiple files --- flat_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 flat_test.go (limited to 'flat_test.go') 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) + } +} -- cgit v1.2.3-70-g09d2