(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestCommentSorting(t *testing.T) { |
| 28 | sampleComments := []*comment.Comment{ |
| 29 | &comment.Comment{ |
| 30 | Timestamp: "012400", |
| 31 | Description: "Fourth", |
| 32 | }, |
| 33 | &comment.Comment{ |
| 34 | Timestamp: "012400", |
| 35 | Description: "Fifth", |
| 36 | }, |
| 37 | &comment.Comment{ |
| 38 | Timestamp: "012346", |
| 39 | Description: "Second", |
| 40 | }, |
| 41 | &comment.Comment{ |
| 42 | Timestamp: "012345", |
| 43 | Description: "First", |
| 44 | }, |
| 45 | &comment.Comment{ |
| 46 | Timestamp: "012347", |
| 47 | Description: "Third", |
| 48 | }, |
| 49 | } |
| 50 | sort.Stable(commentsByTimestamp(sampleComments)) |
| 51 | descriptions := []string{} |
| 52 | for _, comment := range sampleComments { |
| 53 | descriptions = append(descriptions, comment.Description) |
| 54 | } |
| 55 | if !(descriptions[0] == "First" && descriptions[1] == "Second" && descriptions[2] == "Third" && descriptions[3] == "Fourth" && descriptions[4] == "Fifth") { |
| 56 | t.Fatalf("Comment ordering failed. Got %v", sampleComments) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestThreadSorting(t *testing.T) { |
| 61 | sampleThreads := []CommentThread{ |
nothing calls this directly
no test coverage detected