Ejemplo n.º 1
0
func TestResolvedOverlaps(t *testing.T) {
	reject := false
	accept := true

	blankComment := comment.Comment{
		Timestamp: "012345",
		Author:    "*****@*****.**",
		Resolved:  &reject,
	}

	blankComment2 := comment.Comment{
		Timestamp: "012345",
		Author:    "*****@*****.**",
		Resolved:  &accept,
	}

	// should not overlap because resolved bits are set for both
	// and different even though with same timestamp
	if Overlaps(blankComment, blankComment2) {
		t.Errorf("%v and %v  overlap", blankComment, blankComment2)
	}

	blankComment2.Resolved = &reject
	// should overlap because resolved bits are set for both and the same with the same timestamp
	if !Overlaps(blankComment, blankComment2) {
		t.Errorf("%v and %v  do not overlap", blankComment, blankComment2)
	}

	blankComment2.Resolved = &accept
	// should not overlap because resolved bits are set for both and the timestamps are different
	if Overlaps(blankComment, blankComment2) {
		t.Errorf("%v and %v  overlap", blankComment, blankComment2)
	}

	blankComment2.Timestamp = "012345"
	blankComment2.Resolved = nil
	// should not overlap because resolved bit is nil for one
	if Overlaps(blankComment, blankComment2) {
		t.Errorf("%v and %v  overlap", blankComment, blankComment2)
	}

	blankComment.Resolved = nil
	// should overlap because resolved bit is nil for both and there is no other descriptor
	// seperating them apart
	if !Overlaps(blankComment, blankComment2) {
		t.Errorf("%v and %v do not overlap", blankComment, blankComment2)
	}
}