aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/jpillora/longestcommon/lc_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-04-29 21:19:14 +0200
committerStefan Majewsky <majewsky@gmx.net>2018-04-30 10:04:36 +0200
commit0df55a731aa3330f82d22b010a7a2a4d66521972 (patch)
tree9e207f01dbb52afb0de83f95e63ecfc771e809c6 /vendor/github.com/jpillora/longestcommon/lc_test.go
parent1f3fcfa9366e49b371c7be2b5c90b957ce93b8dd (diff)
downloadgo-schwift-0df55a731aa3330f82d22b010a7a2a4d66521972.tar.gz
initial support for large objects
This has gone through a lot of iterations on my branch, and I'm quite happy with the parts of the API that exist now. Test coverage can still be better, and will get better in the following commits. The API is not yet finished: I want to add Options arguments to Object.Upload(), Object.Copy(), Object.Move() and Object.Delete() that specify how each of these operations affect existing segments (and, later, also existing symlinks). For Upload(), uploading in segments shall become as easy as flipping a single switch.
Diffstat (limited to 'vendor/github.com/jpillora/longestcommon/lc_test.go')
-rw-r--r--vendor/github.com/jpillora/longestcommon/lc_test.go111
1 files changed, 111 insertions, 0 deletions
diff --git a/vendor/github.com/jpillora/longestcommon/lc_test.go b/vendor/github.com/jpillora/longestcommon/lc_test.go
new file mode 100644
index 0000000..136e3ff
--- /dev/null
+++ b/vendor/github.com/jpillora/longestcommon/lc_test.go
@@ -0,0 +1,111 @@
+package longestcommon
+
+import (
+ "strings"
+ "testing"
+)
+
+func doTest(t *testing.T, lines, pre, suf string) {
+ strs := []string{}
+ if lines != "" {
+ strs = strings.Split(lines, "\n")
+ }
+ p := Prefix(strs)
+ if p != pre {
+ t.Fatalf("fail: expected prefix '%s', got '%s'", pre, p)
+ }
+ s := Suffix(strs)
+ if s != suf {
+ t.Fatalf("fail: expected suffix '%s', got '%s'", suf, s)
+ }
+}
+
+func TestXFix1(t *testing.T) {
+ doTest(t, ``, "", "")
+}
+
+func TestXFix2(t *testing.T) {
+ doTest(t, `single`, "single", "single")
+}
+
+func TestXFix3(t *testing.T) {
+ doTest(t, "single\ndouble", "", "le")
+}
+
+func TestXFix4(t *testing.T) {
+ doTest(t, "flower\nflow\nfleet", "fl", "")
+}
+
+func TestXFix5(t *testing.T) {
+ doTest(t, `My Awesome Album - 01.mp3
+My Awesome Album - 11.mp3
+My Awesome Album - 03.mp3
+My Awesome Album - 04.mp3
+My Awesome Album - 05.mp3
+My Awesome Album - 06.mp3
+My Awesome Album - 07.mp3
+My Awesome Album - 08.mp3
+My Awesome Album - 09.mp3
+My Awesome Album - 10.mp3
+My Awesome Album - 11.mp3
+My Awesome Album - 12.mp3
+My Awesome Album - 13.mp3
+My Awesome Album - 14.mp3
+My Awesome Album - 15.mp3
+My Awesome Album - 16.mp3
+My Awesome Album - 17.mp3
+My Awesome Album - 18.mp3
+My Awesome Album - 19.mp3
+My Awesome Album - 20.mp3
+My Awesome Album - 21.mp3
+My Awesome Album - 22.mp3
+My Awesome Album - 23.mp3
+My Awesome Album - 24.mp3
+My Awesome Album - 25.mp3
+My Awesome Album - 26.mp3
+My Awesome Album - 27.mp3
+My Awesome Album - 28.mp3
+My Awesome Album - 29.mp3
+My Awesome Album - 30.mp3
+My Awesome Album - 31.mp3
+My Awesome Album - 32.mp3
+My Awesome Album - 33.mp3
+My Awesome Album - 34.mp3
+My Awesome Album - 35.mp3
+My Awesome Album - 36.mp3
+My Awesome Album - 37.mp3
+My Awesome Album - 38.mp3
+My Awesome Album - 39.mp3`, "My Awesome Album - ", ".mp3")
+}
+
+func TestTrimPrefix1(t *testing.T) {
+ strs := []string{"flower", "flow", "fleet"}
+ TrimPrefix(strs)
+ if strs[0] != "ower" {
+ t.Fatalf("fail: expected result string to be 'ower', got '%s'", strs[0])
+ }
+}
+
+func TestTrimPrefix2(t *testing.T) {
+ strs := []string{"flower", "tree"}
+ TrimPrefix(strs) //no common prefix
+ if strs[0] != "flower" {
+ t.Fatalf("fail: expected result string to be 'flower', got '%s'", strs[0])
+ }
+}
+
+func TestTrimSuffix1(t *testing.T) {
+ strs := []string{"flower", "power"}
+ TrimSuffix(strs)
+ if strs[0] != "fl" {
+ t.Fatalf("fail: expected result string to be 'fl', got '%s'", strs[0])
+ }
+}
+
+func TestTrimSuffix2(t *testing.T) {
+ strs := []string{"flower", "tree"}
+ TrimSuffix(strs) //no common suffix
+ if strs[0] != "flower" {
+ t.Fatalf("fail: expected result string to be 'flower', got '%s'", strs[0])
+ }
+}