diff options
| author | Felix Hanley <felix@userspace.com.au> | 2018-01-08 12:56:47 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2018-01-08 12:56:47 +0000 |
| commit | aa3ae997bbed64d6f06f549bfbf5d9ae4f5e84a3 (patch) | |
| tree | 7e7fcfeda1ed29a305765f9043cb2d16efc2cc01 /infohash_test.go | |
| parent | 2d82d5e7251769eb878901e15ed595c840984195 (diff) | |
| download | dhtsearch-aa3ae997bbed64d6f06f549bfbf5d9ae4f5e84a3.tar.gz dhtsearch-aa3ae997bbed64d6f06f549bfbf5d9ae4f5e84a3.tar.bz2 | |
WIP start on worker implementations
Diffstat (limited to 'infohash_test.go')
| -rw-r--r-- | infohash_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/infohash_test.go b/infohash_test.go new file mode 100644 index 0000000..b62f3e2 --- /dev/null +++ b/infohash_test.go @@ -0,0 +1,43 @@ +package dhtsearch + +import ( + "testing" +) + +var hashes = []struct { + s string + valid bool +}{ + {"59066769b9ad42da2e508611c33d7c4480b3857b", true}, + {"59066769b9ad42da2e508611c33d7c4480b3857", false}, + {"59066769b9ad42da2e508611c33d7c4480b385", false}, + {"59066769b9ad42da2e508611c33d7c4480b3857k", false}, + {"5906676b99a4d2d2ae506811c33d7c4480b8357b", true}, +} + +func TestGenNeighbour(t *testing.T) { + for _, test := range hashes { + r := genNeighbour(test.s) + if r != test.valid { + t.Errorf("isValidInfoHash(%q) => %v expected %v", test.s, r, test.valid) + } + } +} + +func TestIsValidInfoHash(t *testing.T) { + for _, test := range hashes { + r := isValidInfoHash(test.s) + if r != test.valid { + t.Errorf("isValidInfoHash(%q) => %v, expected %v", test.s, r, test.valid) + } + } +} + +func TestDecodeInfoHash(t *testing.T) { + for _, test := range hashes { + _, err := decodeInfoHash(test.s) + if (err == nil) != test.valid { + t.Errorf("decodeInfoHash(%q) => %v expected %v", test.s, err, test.valid) + } + } +} |
