Skip to content

Commit

Permalink
Test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibiscum committed May 4, 2024
1 parent 49f58fc commit 4858617
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Chapter03/Example03.02/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func main() {
//var list []int
var list []int8
for i := 0; i < 100000; i++ {
for i := 0; i < 1000000; i++ {
list = append(list, 100)
}
fmt.Println(len(list))
Expand Down
3 changes: 1 addition & 2 deletions Chapter03/Exercise03.01/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ func passwordChecker(pw string) bool {
if unicode.IsNumber(v) {
hasNumber = true
}
if unicode.IsPunct(v) || unicode.IsSymbol(v) {
if unicode.IsPunct(v) || unicode.IsSymbol(v) {
hasSymbol = true
}
}
return hasUpper && hasLower && hasNumber && hasSymbol
}


func main() {
if passwordChecker("") {
fmt.Println("password good")
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion Chapter04/Exercise04.01/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ func defineArray() [10]int {
func main() {
fmt.Printf("%#v\n", defineArray())
}

2 changes: 1 addition & 1 deletion Chapter04/Exercise04.10/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "testing"

func TestMessage(t *testing.T) {
m := `First : 1 [1] [1]
Last : 9 [9] [9]
Last : 9 [9]
First 5 : [1 2 3 4 5]
Last 4 : [6 7 8 9]
Middle 5: [3 4 5 6 7]
Expand Down
2 changes: 1 addition & 1 deletion Chapter15/Activity15.03/a15.03_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Test_anonymous(t *testing.T) {
}
actual := make([]byte, rsp.ContentLength)
_, err = rsp.Body.Read(actual)
if err != nil {
if err != io.EOF {
t.Error(err)
}
if string(actual) != string(expected) {
Expand Down
11 changes: 6 additions & 5 deletions Chapter15/Exercise15.03/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ func TestHello(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, `/?name="john"`, strings.NewReader(""))
w := httptest.NewRecorder()

Hello(w,r)
Hello(w, r)

exp := `Hello "john"`
// exp := `Hello "john"`
exp := `Hello &#34;john&#34;`

if w.Body.String() != exp {
t.Errorf("Expected '%s' but received '%s'", exp, w.Body.String())
Expand All @@ -29,9 +30,9 @@ func TestHello_Fail(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/", strings.NewReader(""))
w := httptest.NewRecorder()

Hello(w,r)
Hello(w, r)

exp := `Missing name`
exp := `Missing name`

if w.Body.String() != exp {
t.Errorf("Expected '%s' but received '%s'", exp, w.Body.String())
Expand All @@ -41,4 +42,4 @@ func TestHello_Fail(t *testing.T) {
t.Errorf("We expected a status code of %d but we received %d", http.StatusBadRequest, w.Code)
}

}
}
3 changes: 2 additions & 1 deletion Chapter15/Exercise15.06/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"io"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -25,7 +26,7 @@ func Test_something(t *testing.T) {

actual := make([]byte, rsp.ContentLength)
_, err = rsp.Body.Read(actual)
if err != nil {
if err != io.EOF {
t.Error(err)
}
if string(actual) != string(expected) {
Expand Down
3 changes: 2 additions & 1 deletion Chapter15/Exercise15.07/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -38,7 +39,7 @@ func Test_posted(t *testing.T) {

actual := make([]byte, rsp.ContentLength)
_, err = rsp.Body.Read(actual)
if err != nil {
if err != io.EOF {
t.Error(err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/payroll/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestManagerPay(t *testing.T) {
inputLast: "Smith",
inputSalary: 150000,
inputCommissionRate: .10,
wantedFullName: "Cayden Jackson",
wantedFullName: "Celina Smith",
wantedPay: 165000,
},
}
Expand Down
6 changes: 3 additions & 3 deletions internal/shape/shape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestTriangleName(t *testing.T) {
}{
{
name: "Triangle Name Scenario 1",
wanted: "triangle",
wanted: "Triangle",
},
}

Expand Down Expand Up @@ -90,7 +90,7 @@ func TestRectangleName(t *testing.T) {
}{
{
name: "Rectangle Name Scenario 1",
wanted: "rectangle",
wanted: "Rectangle",
},
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func TestSquareName(t *testing.T) {
}{
{
name: "Square Name Scenario 1",
wanted: "square",
wanted: "Square",
},
}

Expand Down

0 comments on commit 4858617

Please sign in to comment.