Exemplo n.º 1
0
// Test union sets of SeriesIDs.
func Test_SeriesIDs_Union(t *testing.T) {
	// Test all branches of if-else, exit loop because of 'j < len(r)', and append remainder from left.
	ids1 := tsdb.SeriesIDs{1, 2, 3, 7}
	ids2 := tsdb.SeriesIDs{1, 3, 4, 5, 6}
	exp := tsdb.SeriesIDs{1, 2, 3, 4, 5, 6, 7}
	got := ids1.Union(ids2)

	if !exp.Equals(got) {
		t.Fatalf("exp=%v, got=%v", exp, got)
	}

	// Test exit because of 'i < len(l)' and append remainder from right.
	ids1 = tsdb.SeriesIDs{1}
	ids2 = tsdb.SeriesIDs{1, 2}
	exp = tsdb.SeriesIDs{1, 2}
	got = ids1.Union(ids2)

	if !exp.Equals(got) {
		t.Fatalf("exp=%v, got=%v", exp, got)
	}
}