@@ -7,36 +7,36 @@ import (
77
88func TestNewBlogPost (t * testing.T ) {
99 testCases := []struct {
10- id int
10+ id string
1111 title string
1212 author string
1313 publishDate string
1414 content string
1515 }{
16- {1 , "hello" , "world" , "2025-09-20" , "hello world" },
17- {2 , "test" , "test-author" , "2025-09-20" , "this is a test" },
18- {3 , "test-1" , "test-author-1" , "2025-09-20" , "this is a test and even more..." },
16+ {"1" , "hello" , "world" , "2025-09-20" , "hello world" },
17+ {"2" , "test" , "test-author" , "2025-09-20" , "this is a test" },
18+ {"3" , "test-1" , "test-author-1" , "2025-09-20" , "this is a test and even more..." },
1919 }
2020 for _ , tc := range testCases {
2121 post := NewBlogPost (tc .id , tc .title , tc .publishDate , tc .author , tc .content )
2222 if tc .author != post .Author || tc .id != post .Id || tc .content != post .Content || tc .publishDate != post .PublishingDate {
23- t .Errorf ("Expecting BlogPost{Id: %d , Author: %s, Content: %s, PublishingDate: %s, Title: %s}, got BlogPost{Id: %d , Author: %s, Content: %s, PublishingDate: %s, Title: %s}" , tc .id , tc .author , tc .content , tc .publishDate , tc .title , post .Id , post .Author , post .Content , post .PublishingDate , post .Title )
23+ t .Errorf ("Expecting BlogPost{Id: %s , Author: %s, Content: %s, PublishingDate: %s, Title: %s}, got BlogPost{Id: %s , Author: %s, Content: %s, PublishingDate: %s, Title: %s}" , tc .id , tc .author , tc .content , tc .publishDate , tc .title , post .Id , post .Author , post .Content , post .PublishingDate , post .Title )
2424 }
2525 }
2626}
2727
2828func TestSortBlogPosts (t * testing.T ) {
2929 testCases := []struct {
3030 startingList []* BlogPost
31- expected []int
31+ expected []string
3232 }{
33- {[]* BlogPost {NewBlogPost (1 , "" , "" , "" , "" ), NewBlogPost (4 , "" , "" , "" , "" ), NewBlogPost (2 , "" , "" , "" , "" ), NewBlogPost (3 , "" , "" , "" , "" )}, []int { 4 , 3 , 2 , 1 }},
34- {[]* BlogPost {NewBlogPost (5 , "" , "" , "" , "" ), NewBlogPost (3 , "" , "" , "" , "" ), NewBlogPost (2 , "" , "" , "" , "" ), NewBlogPost (1 , "" , "" , "" , "" )}, []int { 5 , 3 , 2 , 1 }},
35- {[]* BlogPost {NewBlogPost (5 , "" , "" , "" , "" ), NewBlogPost (3 , "" , "" , "" , "" ), NewBlogPost (1 , "" , "" , "" , "" ), NewBlogPost (1 , "" , "" , "" , "" )}, []int { 5 , 3 , 1 , 1 }},
33+ {[]* BlogPost {NewBlogPost ("1" , "" , "" , "" , "" ), NewBlogPost ("4" , "" , "" , "" , "" ), NewBlogPost ("2" , "" , "" , "" , "" ), NewBlogPost ("3" , "" , "" , "" , "" )}, []string { "4" , "3" , "2" , "1" }},
34+ {[]* BlogPost {NewBlogPost ("5" , "" , "" , "" , "" ), NewBlogPost ("3" , "" , "" , "" , "" ), NewBlogPost ("2" , "" , "" , "" , "" ), NewBlogPost ("1" , "" , "" , "" , "" )}, []string { "5" , "3" , "2" , "1" }},
35+ {[]* BlogPost {NewBlogPost ("5" , "" , "" , "" , "" ), NewBlogPost ("3" , "" , "" , "" , "" ), NewBlogPost ("1" , "" , "" , "" , "" ), NewBlogPost ("1" , "" , "" , "" , "" )}, []string { "5" , "3" , "1" , "1" }},
3636 }
3737 for _ , tc := range testCases {
3838 blogs := SortBlogPosts (tc .startingList )
39- blogIds := make ([]int , len (blogs ))
39+ blogIds := make ([]string , len (blogs ))
4040 for i , blog := range blogs {
4141 blogIds [i ] = blog .Id
4242 }
0 commit comments