Skip to content

Commit

Permalink
Fixed assert equals parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Akos0628 committed Dec 14, 2023
1 parent 7374a8e commit 1b40498
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion 01-getting-started/01-hello-world/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import (
)

func TestHelloWorld(t *testing.T) {
assert.Equal(t, helloWorld(), "{{index . "text"}}", "hello world in {{index . "language"}}")
assert.Equal(t, "{{index . "text"}}", helloWorld(), "hello world in {{index . "language"}}")
}
6 changes: 3 additions & 3 deletions 03-variables/01-repaint/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

func TestRepaintColor(t *testing.T) {
c, err := repaintColor("{{index . "primary"}}")
assert.Equal(t, c, "{{index . "complementary"}}")
assert.Equal(t, "{{index . "complementary"}}", c)
assert.NoError(t, err)

c, err = repaintColor("{{index . "complementary"}}")
assert.Equal(t, c, "{{index . "primary"}}")
assert.Equal(t, "{{index . "primary"}}", c)
assert.NoError(t, err)

c, err = repaintColor("xxx")
assert.Equal(t, c, "")
assert.Equal(t, "", c)
assert.Error(t, err)
}
10 changes: 5 additions & 5 deletions 03-variables/02-path-split/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

func TestSplitPath(t *testing.T) {
assert.Equal(t, splitPath("{{index . "tests" 0 "fullpath"}}"), "{{index . "tests" 0 "output"}}")
assert.Equal(t, splitPath("{{index . "tests" 1 "fullpath"}}"), "{{index . "tests" 1 "output"}}")
assert.Equal(t, splitPath("{{index . "tests" 2 "fullpath"}}"), "{{index . "tests" 2 "output"}}")
assert.Equal(t, splitPath("{{index . "tests" 3 "fullpath"}}"), "{{index . "tests" 3 "output"}}")
assert.Equal(t, splitPath("{{index . "tests" 4 "fullpath"}}"), "{{index . "tests" 4 "output"}}")
assert.Equal(t, "{{index . "tests" 0 "output"}}", splitPath("{{index . "tests" 0 "fullpath"}}"))
assert.Equal(t, "{{index . "tests" 1 "output"}}", splitPath("{{index . "tests" 1 "fullpath"}}"))
assert.Equal(t, "{{index . "tests" 2 "output"}}", splitPath("{{index . "tests" 2 "fullpath"}}"))
assert.Equal(t, "{{index . "tests" 3 "output"}}", splitPath("{{index . "tests" 3 "fullpath"}}"))
assert.Equal(t, "{{index . "tests" 4 "output"}}", splitPath("{{index . "tests" 4 "fullpath"}}"))
}
2 changes: 1 addition & 1 deletion 06-switch/01-richter-scale/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import (

func TestDescribeEarthquake(t *testing.T) {
{{range index . "tests"}}
assert.Equal(t, describeEarthquake({{index . "magnitude"}}), "{{index . "description"}}")
assert.Equal(t, "{{index . "description"}}", describeEarthquake({{index . "magnitude"}}))
{{end}}
}
6 changes: 3 additions & 3 deletions 08-arrays/01-message_queue/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestMessageQueue(t *testing.T) {
x := messageQueue("Hello", "World", "Again")
assert.Equal(t, x[0], "{{index . "text" 0}}")
assert.Equal(t, x[1], "{{index . "text" 1}}")
assert.Equal(t, x[2], "{{index . "text" 2}}")
assert.Equal(t, "{{index . "text" 0}}", x[0])
assert.Equal(t, "{{index . "text" 1}}", x[1])
assert.Equal(t, "{{index . "text" 2}}", x[2])
}
52 changes: 26 additions & 26 deletions 19-structs/01-basics/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@ import (
func TestNewGame(t *testing.T) {
g := newGame({{index .new "id"}}, "{{index .new "name"}}", {{index .new "price"}}, "{{index .new "genre"}}")

assert.Equal(t, g.id, {{index . "new" "id"}}, "id")
assert.Equal(t, g.name, "{{index . "new" "name"}}", "name")
assert.Equal(t, g.price, {{index . "new" "price"}}, "price")
assert.Equal(t, g.genre, "{{index . "new" "genre"}}", "genre")
assert.Equal(t, {{index . "new" "id"}}, g.id, "id")
assert.Equal(t, "{{index . "new" "name"}}", g.name, "name")
assert.Equal(t, {{index . "new" "price"}}, g.price, "price")
assert.Equal(t, "{{index . "new" "genre"}}", g.genre, "genre")
}

func TestString(t *testing.T) {
g := newGame({{index . "string" "id"}}, "{{index . "string" "name"}}", {{index . "string" "price"}}, "{{index . "string" "genre"}}")

assert.Equal(t, g.item.String(), "{{index . "string" "item_result"}}", "item string")
assert.Equal(t, g.String(), "{{index . "string" "game_result"}}", "game string")
assert.Equal(t, "{{index . "string" "item_result"}}", g.item.String(), "item string")
assert.Equal(t, "{{index . "string" "game_result"}}", g.String(), "game string")
}

func TestList(t *testing.T) {
games := newGameList()

assert.Len(t, games, 3, "gamelist len")

assert.Equal(t, games[0].id, {{index . "list" 0 "id"}}, "game 0 id")
assert.Equal(t, games[0].name, "{{index . "list" 0 "name"}}", "game 0 name")
assert.Equal(t, games[0].price, {{index . "list" 0 "price"}}, "game 0 price")
assert.Equal(t, games[0].genre, "{{index . "list" 0 "genre"}}", "game 0 genre")
assert.Equal(t, {{index . "list" 0 "id"}}, games[0].id, "game 0 id")
assert.Equal(t, "{{index . "list" 0 "name"}}", games[0].name, "game 0 name")
assert.Equal(t, {{index . "list" 0 "price"}}, games[0].price, "game 0 price")
assert.Equal(t, "{{index . "list" 0 "genre"}}", games[0].genre, "game 0 genre")

assert.Equal(t, games[1].id, {{index . "list" 1 "id"}}, "game 1 id")
assert.Equal(t, games[1].name, "{{index . "list" 1 "name"}}", "game 1 name")
assert.Equal(t, games[1].price, {{index . "list" 1 "price"}}, "game 1 price")
assert.Equal(t, games[1].genre, "{{index . "list" 1 "genre"}}", "game 1 genre")
assert.Equal(t, {{index . "list" 1 "id"}}, games[1].id, "game 1 id")
assert.Equal(t, "{{index . "list" 1 "name"}}", games[1].name, "game 1 name")
assert.Equal(t, {{index . "list" 1 "price"}}, games[1].price, "game 1 price")
assert.Equal(t, "{{index . "list" 1 "genre"}}", games[1].genre, "game 1 genre")

assert.Equal(t, games[2].id, {{index . "list" 2 "id"}}, "game 2 id")
assert.Equal(t, games[2].name, "{{index . "list" 2 "name"}}", "game 2 name")
assert.Equal(t, games[2].price, {{index . "list" 2 "price"}}, "game 2 price")
assert.Equal(t, games[2].genre, "{{index . "list" 2 "genre"}}", "game 2 genre")
assert.Equal(t, {{index . "list" 2 "id"}}, games[2].id, "game 2 id")
assert.Equal(t, "{{index . "list" 2 "name"}}", games[2].name, "game 2 name")
assert.Equal(t, {{index . "list" 2 "price"}}, games[2].price, "game 2 price")
assert.Equal(t, "{{index . "list" 2 "genre"}}", games[2].genre, "game 2 genre")
}

func TestById(t *testing.T) {
g, err := queryById(newGameList(), {{index . "by_id" "id"}})
assert.NoError(t, err, "no error")
assert.Equal(t, g.id, {{index . "by_id" "result" "id"}}, "game id")
assert.Equal(t, g.name, "{{index . "by_id" "result" "name"}}", "game name")
assert.Equal(t, g.price, {{index . "by_id" "result" "price"}}, "game price")
assert.Equal(t, g.genre, "{{index . "by_id" "result" "genre"}}", "game genre")
assert.Equal(t, {{index . "by_id" "result" "id"}}, g.id, "game id")
assert.Equal(t, "{{index . "by_id" "result" "name"}}", g.name, "game name")
assert.Equal(t, {{index . "by_id" "result" "price"}}, g.price, "game price")
assert.Equal(t, "{{index . "by_id" "result" "genre"}}", g.genre, "game genre")

g, err = queryById(newGameList(), 11)
assert.EqualError(t, err, "No such game", "error")
Expand All @@ -60,16 +60,16 @@ func TestNameByPrice(t *testing.T) {

assert.Len(t, names, {{index .name_by_price "result" "size"}}, "namelist len")
if {{index .name_by_price "result" "size"}} > 0 {
assert.Equal(t, names[0], "{{index .name_by_price "result" "list" 0}}", "names 1")
assert.Equal(t, "{{index .name_by_price "result" "list" 0}}", names[0], "names 1")
}
if {{index .name_by_price "result" "size"}} > 1 {
assert.Equal(t, names[1], "{{index .name_by_price "result" "list" 1}}", "names 2")
assert.Equal(t, "{{index .name_by_price "result" "list" 1}}", names[1], "names 2")
}
if {{index .name_by_price "result" "size"}} > 2 {
assert.Equal(t, names[2], "{{index .name_by_price "result" "list" 2}}", "names 3")
assert.Equal(t, "{{index .name_by_price "result" "list" 2}}", names[2], "names 3")
}
if {{index .name_by_price "result" "size"}} > 3 {
assert.Equal(t, names[3], "{{index .name_by_price "result" "list" 3}}", "names 4")
assert.Equal(t, "{{index .name_by_price "result" "list" 3}}", names[3], "names 4")
}
}

2 changes: 1 addition & 1 deletion 22-goroutines/03-sleep-sort/.exercise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import (
func TestSleepSort(t *testing.T) {
input := []uint{{index . "input"}}
result := []uint{{index . "result"}}
assert.Equal(t, {{index . "funcName"}}(input), result, "{{index . "dir"}} sleep-sort")
assert.Equal(t, result, {{index . "funcName"}}(input), "{{index . "dir"}} sleep-sort")
}

0 comments on commit 1b40498

Please sign in to comment.