func TestRebalance(t *testing.T) {
	defer disableCoalesce()()

	for _, orig := range rebalanceTestRopes {
		origStr := orig.String()
		rebalanced := orig.Rebalance()
		rebalancedStr := rebalanced.String()

		//~ pretty.Println(orig, "(", orig.isBalanced(), ") ==> (", rebalanced.isBalanced(), ")", rebalanced)

		assert.Equal(t, origStr, rebalancedStr)
		if rebalanced.node != nil && orig.node != nil {
			assert.True(t, rebalanced.node.depth() <= orig.node.depth())
		}
		assert.True(t, rebalanced.isBalanced())
	}
}
func TestReadAt(t *testing.T) {
	want := treeR.Bytes()

	buf := make([]byte, len(want)+1)

	for start := 0; start < len(buf); start++ {
		for end := start; end <= len(buf); end++ {
			length := end - start
			b := buf[0:length]
			n, err := treeR.ReadAt(b, int64(start))

			// Basic io.ReaderAt contract
			assert.True(t, n <= length)
			if n < length {
				assert.Equal(t, io.EOF, err)
			}

			// Expected actual end and length
			eEnd := end
			if eEnd > len(want) {
				eEnd = len(want)
			}
			eLen := eEnd - start

			// Check for correctness
			assert.Equal(t, eLen, n)
			if eLen < length {
				assert.Equal(t, io.EOF, err)
			} else if eLen > length {
				assert.Nil(t, err)
			} else {
				assert.True(t, err == nil || err == io.EOF)
			}

			assert.Equal(t, want[start:eEnd], b[:n])
		}
	}
}
func TestWalk(t *testing.T) {
	defer disableCoalesce()()

	for _, r := range []Rope{Rope{}, emptyRope} {
		r.Walk(func(_ string) error {
			t.Error("call to empty Rope's Walk parameter")
			return nil
		})
	}

	for _, r := range []Rope{
		New("abc").AppendString("def").AppendString("ghi"),
	} {
		str := r.String()
		err := r.Walk(func(part string) error {
			assert.Equal(t, str[:len(part)], part)
			str = str[len(part):]
			return nil
		})
		assert.Nil(t, err)
		assert.Equal(t, "", str)
	}

	for _, r := range []Rope{
		New("abc").AppendString("def").AppendString("ghi"),
	} {
		str := r.String()
		err := r.Walk(func(part string) error {
			assert.Equal(t, str[:len(part)], part)
			str = str[len(part):]
			if len(str) < 4 {
				return errors.New("stop now")
			}
			return nil
		})
		assert.Equal(t, err, errors.New("stop now"))
		assert.True(t, 0 < len(str) && len(str) < 4)
	}

}
Exemple #4
0
func TestParseWebHooks(t *testing.T) {
	assert.True(t, true)
}
Exemple #5
0
func TriggerWebHooks(t *testing.T) {
	assert.True(t, true)
}
Exemple #6
0
func TestPostWebHook(t *testing.T) {
	assert.True(t, true)
}
Exemple #7
0
func TestParseLocalHooks(t *testing.T) {
	assert.True(t, true)
}
Exemple #8
0
func TriggerLocalHooks(t *testing.T) {
	assert.True(t, true)
}
Exemple #9
0
func TestPostLocalHook(t *testing.T) {
	assert.True(t, true)
}
Exemple #10
0
func TestParseHooksFile(t *testing.T) {
	assert.True(t, true)
}