From 821bff0922ab34ead0a777927267fa6a0dc8b430 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Thu, 9 Apr 2015 09:11:50 +0200 Subject: [PATCH 1/3] Update travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3fadf53..687dc5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.3 + - 1.4 - tip matrix: From 343f99deeb222947dc9e28258cb10f770379026a Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Thu, 9 Apr 2015 09:19:49 +0200 Subject: [PATCH 2/3] Use Godep to manage dependencies properly --- Godeps/Godeps.json | 10 + Godeps/Readme | 5 + Godeps/_workspace/.gitignore | 2 + .../stretchr/testify/assert/assertions.go | 805 ++++++++++++++++++ .../testify/assert/assertions_test.go | 768 +++++++++++++++++ .../github.com/stretchr/testify/assert/doc.go | 150 ++++ .../stretchr/testify/assert/errors.go | 10 + .../testify/assert/forward_assertions.go | 262 ++++++ .../testify/assert/forward_assertions_test.go | 526 ++++++++++++ .../testify/assert/http_assertions.go | 157 ++++ .../testify/assert/http_assertions_test.go | 86 ++ 11 files changed, 2781 insertions(+) create mode 100644 Godeps/Godeps.json create mode 100644 Godeps/Readme create mode 100644 Godeps/_workspace/.gitignore create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions_test.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/errors.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions_test.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go create mode 100644 Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions_test.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json new file mode 100644 index 0000000..9f6b801 --- /dev/null +++ b/Godeps/Godeps.json @@ -0,0 +1,10 @@ +{ + "ImportPath": "github.com/ariejan/i6502", + "GoVersion": "go1.4.2", + "Deps": [ + { + "ImportPath": "github.com/stretchr/testify/assert", + "Rev": "e4ec8152c15fc46bd5056ce65997a07c7d415325" + } + ] +} diff --git a/Godeps/Readme b/Godeps/Readme new file mode 100644 index 0000000..4cdaa53 --- /dev/null +++ b/Godeps/Readme @@ -0,0 +1,5 @@ +This directory tree is generated automatically by godep. + +Please do not edit. + +See https://github.com/tools/godep for more information. diff --git a/Godeps/_workspace/.gitignore b/Godeps/_workspace/.gitignore new file mode 100644 index 0000000..f037d68 --- /dev/null +++ b/Godeps/_workspace/.gitignore @@ -0,0 +1,2 @@ +/pkg +/bin diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go new file mode 100644 index 0000000..58e1781 --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions.go @@ -0,0 +1,805 @@ +package assert + +import ( + "bufio" + "bytes" + "fmt" + "reflect" + "regexp" + "runtime" + "strings" + "time" +) + +// TestingT is an interface wrapper around *testing.T +type TestingT interface { + Errorf(format string, args ...interface{}) +} + +// Comparison a custom function that returns true on success and false on failure +type Comparison func() (success bool) + +/* + Helper functions +*/ + +// ObjectsAreEqual determines if two objects are considered equal. +// +// This function does no assertion of any kind. +func ObjectsAreEqual(expected, actual interface{}) bool { + + if expected == nil || actual == nil { + return expected == actual + } + + if reflect.DeepEqual(expected, actual) { + return true + } + + // Last ditch effort + if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) { + return true + } + + return false + +} + +func ObjectsAreEqualValues(expected, actual interface{}) bool { + if ObjectsAreEqual(expected, actual) { + return true + } + + actualType := reflect.TypeOf(actual) + expectedValue := reflect.ValueOf(expected) + if expectedValue.Type().ConvertibleTo(actualType) { + // Attempt comparison after type conversion + if reflect.DeepEqual(actual, expectedValue.Convert(actualType).Interface()) { + return true + } + } + + return false +} + +/* CallerInfo is necessary because the assert functions use the testing object +internally, causing it to print the file:line of the assert method, rather than where +the problem actually occured in calling code.*/ + +// CallerInfo returns a string containing the file and line number of the assert call +// that failed. +func CallerInfo() string { + + file := "" + line := 0 + ok := false + + for i := 0; ; i++ { + _, file, line, ok = runtime.Caller(i) + if !ok { + return "" + } + parts := strings.Split(file, "/") + dir := parts[len(parts)-2] + file = parts[len(parts)-1] + if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { + break + } + } + + return fmt.Sprintf("%s:%d", file, line) +} + +// getWhitespaceString returns a string that is long enough to overwrite the default +// output from the go testing framework. +func getWhitespaceString() string { + + _, file, line, ok := runtime.Caller(1) + if !ok { + return "" + } + parts := strings.Split(file, "/") + file = parts[len(parts)-1] + + return strings.Repeat(" ", len(fmt.Sprintf("%s:%d: ", file, line))) + +} + +func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { + if len(msgAndArgs) == 0 || msgAndArgs == nil { + return "" + } + if len(msgAndArgs) == 1 { + return msgAndArgs[0].(string) + } + if len(msgAndArgs) > 1 { + return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) + } + return "" +} + +// Indents all lines of the message by appending a number of tabs to each line, in an output format compatible with Go's +// test printing (see inner comment for specifics) +func indentMessageLines(message string, tabs int) string { + outBuf := new(bytes.Buffer) + + for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ { + if i != 0 { + outBuf.WriteRune('\n') + } + for ii := 0; ii < tabs; ii++ { + outBuf.WriteRune('\t') + // Bizarrely, all lines except the first need one fewer tabs prepended, so deliberately advance the counter + // by 1 prematurely. + if ii == 0 && i > 0 { + ii++ + } + } + outBuf.WriteString(scanner.Text()) + } + + return outBuf.String() +} + +// Fail reports a failure through +func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { + + message := messageFromMsgAndArgs(msgAndArgs...) + + if len(message) > 0 { + t.Errorf("\r%s\r\tLocation:\t%s\n"+ + "\r\tError:%s\n"+ + "\r\tMessages:\t%s\n\r", + getWhitespaceString(), + CallerInfo(), + indentMessageLines(failureMessage, 2), + message) + } else { + t.Errorf("\r%s\r\tLocation:\t%s\n"+ + "\r\tError:%s\n\r", + getWhitespaceString(), + CallerInfo(), + indentMessageLines(failureMessage, 2)) + } + + return false +} + +// Implements asserts that an object is implemented by the specified interface. +// +// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject") +func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { + + interfaceType := reflect.TypeOf(interfaceObject).Elem() + + if !reflect.TypeOf(object).Implements(interfaceType) { + return Fail(t, fmt.Sprintf("Object must implement %v", interfaceType), msgAndArgs...) + } + + return true + +} + +// IsType asserts that the specified objects are of the same type. +func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { + + if !ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType)) { + return Fail(t, fmt.Sprintf("Object expected to be of type %v, but was %v", reflect.TypeOf(expectedType), reflect.TypeOf(object)), msgAndArgs...) + } + + return true +} + +// Equal asserts that two objects are equal. +// +// assert.Equal(t, 123, 123, "123 and 123 should be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + + if !ObjectsAreEqual(expected, actual) { + return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+ + " != %#v (actual)", expected, actual), msgAndArgs...) + } + + return true + +} + +// EqualValues asserts that two objects are equal or convertable to the same types +// and equal. +// +// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + + if !ObjectsAreEqualValues(expected, actual) { + return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+ + " != %#v (actual)", expected, actual), msgAndArgs...) + } + + return true + +} + +// Exactly asserts that two objects are equal is value and type. +// +// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + + aType := reflect.TypeOf(expected) + bType := reflect.TypeOf(actual) + + if aType != bType { + return Fail(t, "Types expected to match exactly", "%v != %v", aType, bType) + } + + return Equal(t, expected, actual, msgAndArgs...) + +} + +// NotNil asserts that the specified object is not nil. +// +// assert.NotNil(t, err, "err should be something") +// +// Returns whether the assertion was successful (true) or not (false). +func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + + success := true + + if object == nil { + success = false + } else { + value := reflect.ValueOf(object) + kind := value.Kind() + if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() { + success = false + } + } + + if !success { + Fail(t, "Expected not to be nil.", msgAndArgs...) + } + + return success +} + +// isNil checks if a specified object is nil or not, without Failing. +func isNil(object interface{}) bool { + if object == nil { + return true + } + + value := reflect.ValueOf(object) + kind := value.Kind() + if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() { + return true + } + + return false +} + +// Nil asserts that the specified object is nil. +// +// assert.Nil(t, err, "err should be nothing") +// +// Returns whether the assertion was successful (true) or not (false). +func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if isNil(object) { + return true + } + return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...) +} + +var zeros = []interface{}{ + int(0), + int8(0), + int16(0), + int32(0), + int64(0), + uint(0), + uint8(0), + uint16(0), + uint32(0), + uint64(0), + float32(0), + float64(0), +} + +// isEmpty gets whether the specified object is considered empty or not. +func isEmpty(object interface{}) bool { + + if object == nil { + return true + } else if object == "" { + return true + } else if object == false { + return true + } + + for _, v := range zeros { + if object == v { + return true + } + } + + objValue := reflect.ValueOf(object) + + switch objValue.Kind() { + case reflect.Map: + fallthrough + case reflect.Slice, reflect.Chan: + { + return (objValue.Len() == 0) + } + case reflect.Ptr: + { + switch object.(type) { + case *time.Time: + return object.(*time.Time).IsZero() + default: + return false + } + } + } + return false +} + +// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// assert.Empty(t, obj) +// +// Returns whether the assertion was successful (true) or not (false). +func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + + pass := isEmpty(object) + if !pass { + Fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...) + } + + return pass + +} + +// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if assert.NotEmpty(t, obj) { +// assert.Equal(t, "two", obj[1]) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + + pass := !isEmpty(object) + if !pass { + Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...) + } + + return pass + +} + +// getLen try to get length of object. +// return (false, 0) if impossible. +func getLen(x interface{}) (ok bool, length int) { + v := reflect.ValueOf(x) + defer func() { + if e := recover(); e != nil { + ok = false + } + }() + return true, v.Len() +} + +// Len asserts that the specified object has specific length. +// Len also fails if the object has a type that len() not accept. +// +// assert.Len(t, mySlice, 3, "The size of slice is not 3") +// +// Returns whether the assertion was successful (true) or not (false). +func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { + ok, l := getLen(object) + if !ok { + return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...) + } + + if l != length { + return Fail(t, fmt.Sprintf("\"%s\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) + } + return true +} + +// True asserts that the specified value is true. +// +// assert.True(t, myBool, "myBool should be true") +// +// Returns whether the assertion was successful (true) or not (false). +func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { + + if value != true { + return Fail(t, "Should be true", msgAndArgs...) + } + + return true + +} + +// False asserts that the specified value is true. +// +// assert.False(t, myBool, "myBool should be false") +// +// Returns whether the assertion was successful (true) or not (false). +func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { + + if value != false { + return Fail(t, "Should be false", msgAndArgs...) + } + + return true + +} + +// NotEqual asserts that the specified values are NOT equal. +// +// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + + if ObjectsAreEqual(expected, actual) { + return Fail(t, "Should not be equal", msgAndArgs...) + } + + return true + +} + +// containsElement try loop over the list check if the list includes the element. +// return (false, false) if impossible. +// return (true, false) if element was not found. +// return (true, true) if element was found. +func includeElement(list interface{}, element interface{}) (ok, found bool) { + + listValue := reflect.ValueOf(list) + elementValue := reflect.ValueOf(element) + defer func() { + if e := recover(); e != nil { + ok = false + found = false + } + }() + + if reflect.TypeOf(list).Kind() == reflect.String { + return true, strings.Contains(listValue.String(), elementValue.String()) + } + + for i := 0; i < listValue.Len(); i++ { + if ObjectsAreEqual(listValue.Index(i).Interface(), element) { + return true, true + } + } + return true, false + +} + +// Contains asserts that the specified string or list(array, slice...) contains the +// specified substring or element. +// +// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'") +// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'") +// +// Returns whether the assertion was successful (true) or not (false). +func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { + + ok, found := includeElement(s, contains) + if !ok { + return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) + } + if !found { + return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", s, contains), msgAndArgs...) + } + + return true + +} + +// NotContains asserts that the specified string or list(array, slice...) does NOT contain the +// specified substring or element. +// +// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'") +// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'") +// +// Returns whether the assertion was successful (true) or not (false). +func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { + + ok, found := includeElement(s, contains) + if !ok { + return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) + } + if found { + return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...) + } + + return true + +} + +// Condition uses a Comparison to assert a complex condition. +func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool { + result := comp() + if !result { + Fail(t, "Condition failed!", msgAndArgs...) + } + return result +} + +// PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics +// methods, and represents a simple func that takes no arguments, and returns nothing. +type PanicTestFunc func() + +// didPanic returns true if the function passed to it panics. Otherwise, it returns false. +func didPanic(f PanicTestFunc) (bool, interface{}) { + + didPanic := false + var message interface{} + func() { + + defer func() { + if message = recover(); message != nil { + didPanic = true + } + }() + + // call the target function + f() + + }() + + return didPanic, message + +} + +// Panics asserts that the code inside the specified PanicTestFunc panics. +// +// assert.Panics(t, func(){ +// GoCrazy() +// }, "Calling GoCrazy() should panic") +// +// Returns whether the assertion was successful (true) or not (false). +func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { + + if funcDidPanic, panicValue := didPanic(f); !funcDidPanic { + return Fail(t, fmt.Sprintf("func %#v should panic\n\r\tPanic value:\t%v", f, panicValue), msgAndArgs...) + } + + return true +} + +// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// assert.NotPanics(t, func(){ +// RemainCalm() +// }, "Calling RemainCalm() should NOT panic") +// +// Returns whether the assertion was successful (true) or not (false). +func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { + + if funcDidPanic, panicValue := didPanic(f); funcDidPanic { + return Fail(t, fmt.Sprintf("func %#v should not panic\n\r\tPanic value:\t%v", f, panicValue), msgAndArgs...) + } + + return true +} + +// WithinDuration asserts that the two times are within duration delta of each other. +// +// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s") +// +// Returns whether the assertion was successful (true) or not (false). +func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { + + dt := expected.Sub(actual) + if dt < -delta || dt > delta { + return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...) + } + + return true +} + +func toFloat(x interface{}) (float64, bool) { + var xf float64 + xok := true + + switch xn := x.(type) { + case uint8: + xf = float64(xn) + case uint16: + xf = float64(xn) + case uint32: + xf = float64(xn) + case uint64: + xf = float64(xn) + case int: + xf = float64(xn) + case int8: + xf = float64(xn) + case int16: + xf = float64(xn) + case int32: + xf = float64(xn) + case int64: + xf = float64(xn) + case float32: + xf = float64(xn) + case float64: + xf = float64(xn) + default: + xok = false + } + + return xf, xok +} + +// InDelta asserts that the two numerals are within delta of each other. +// +// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) +// +// Returns whether the assertion was successful (true) or not (false). +func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + + af, aok := toFloat(expected) + bf, bok := toFloat(actual) + + if !aok || !bok { + return Fail(t, fmt.Sprintf("Parameters must be numerical"), msgAndArgs...) + } + + dt := af - bf + if dt < -delta || dt > delta { + return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...) + } + + return true +} + +// min(|expected|, |actual|) * epsilon +func calcEpsilonDelta(expected, actual interface{}, epsilon float64) float64 { + af, aok := toFloat(expected) + bf, bok := toFloat(actual) + + if !aok || !bok { + // invalid input + return 0 + } + + if af < 0 { + af = -af + } + if bf < 0 { + bf = -bf + } + var delta float64 + if af < bf { + delta = af * epsilon + } else { + delta = bf * epsilon + } + return delta +} + +// InEpsilon asserts that expected and actual have a relative error less than epsilon +// +// Returns whether the assertion was successful (true) or not (false). +func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { + delta := calcEpsilonDelta(expected, actual, epsilon) + + return InDelta(t, expected, actual, delta, msgAndArgs...) +} + +/* + Errors +*/ + +// NoError asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if assert.NoError(t, err) { +// assert.Equal(t, actualObj, expectedObj) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { + if isNil(err) { + return true + } + + return Fail(t, fmt.Sprintf("No error is expected but got %v", err), msgAndArgs...) +} + +// Error asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if assert.Error(t, err, "An error was expected") { +// assert.Equal(t, err, expectedError) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { + + message := messageFromMsgAndArgs(msgAndArgs...) + return NotNil(t, err, "An error is expected but got nil. %s", message) + +} + +// EqualError asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// if assert.Error(t, err, "An error was expected") { +// assert.Equal(t, err, expectedError) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool { + + message := messageFromMsgAndArgs(msgAndArgs...) + if !NotNil(t, theError, "An error is expected but got nil. %s", message) { + return false + } + s := "An error with value \"%s\" is expected but got \"%s\". %s" + return Equal(t, theError.Error(), errString, + s, errString, theError.Error(), message) +} + +// matchRegexp return true if a specified regexp matches a string. +func matchRegexp(rx interface{}, str interface{}) bool { + + var r *regexp.Regexp + if rr, ok := rx.(*regexp.Regexp); ok { + r = rr + } else { + r = regexp.MustCompile(fmt.Sprint(rx)) + } + + return (r.FindStringIndex(fmt.Sprint(str)) != nil) + +} + +// Regexp asserts that a specified regexp matches a string. +// +// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") +// assert.Regexp(t, "start...$", "it's not starting") +// +// Returns whether the assertion was successful (true) or not (false). +func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + + match := matchRegexp(rx, str) + + if !match { + Fail(t, fmt.Sprintf("Expect \"%v\" to match \"%v\"", str, rx), msgAndArgs...) + } + + return match +} + +// NotRegexp asserts that a specified regexp does not match a string. +// +// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") +// assert.NotRegexp(t, "^start", "it's not starting") +// +// Returns whether the assertion was successful (true) or not (false). +func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + match := matchRegexp(rx, str) + + if match { + Fail(t, fmt.Sprintf("Expect \"%v\" to NOT match \"%v\"", str, rx), msgAndArgs...) + } + + return !match + +} diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions_test.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions_test.go new file mode 100644 index 0000000..2cb58db --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertions_test.go @@ -0,0 +1,768 @@ +package assert + +import ( + "errors" + "regexp" + "testing" + "time" +) + +// AssertionTesterInterface defines an interface to be used for testing assertion methods +type AssertionTesterInterface interface { + TestMethod() +} + +// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface +type AssertionTesterConformingObject struct { +} + +func (a *AssertionTesterConformingObject) TestMethod() { +} + +// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface +type AssertionTesterNonConformingObject struct { +} + +func TestObjectsAreEqual(t *testing.T) { + + if !ObjectsAreEqual("Hello World", "Hello World") { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual(123, 123) { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual(123.5, 123.5) { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual([]byte("Hello World"), []byte("Hello World")) { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual(nil, nil) { + t.Error("objectsAreEqual should return true") + } + if ObjectsAreEqual(map[int]int{5: 10}, map[int]int{10: 20}) { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual('x', "x") { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual("x", 'x') { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual(0, 0.1) { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual(0.1, 0) { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual(uint32(10), int32(10)) { + t.Error("objectsAreEqual should return false") + } + if !ObjectsAreEqualValues(uint32(10), int32(10)) { + t.Error("ObjectsAreEqualValues should return true") + } + +} + +func TestImplements(t *testing.T) { + + mockT := new(testing.T) + + if !Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) { + t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface") + } + if Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) { + t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface") + } + +} + +func TestIsType(t *testing.T) { + + mockT := new(testing.T) + + if !IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { + t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject") + } + if IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) { + t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject") + } + +} + +func TestEqual(t *testing.T) { + + mockT := new(testing.T) + + if !Equal(mockT, "Hello World", "Hello World") { + t.Error("Equal should return true") + } + if !Equal(mockT, 123, 123) { + t.Error("Equal should return true") + } + if !Equal(mockT, 123.5, 123.5) { + t.Error("Equal should return true") + } + if !Equal(mockT, []byte("Hello World"), []byte("Hello World")) { + t.Error("Equal should return true") + } + if !Equal(mockT, nil, nil) { + t.Error("Equal should return true") + } + if !Equal(mockT, int32(123), int32(123)) { + t.Error("Equal should return true") + } + if !Equal(mockT, uint64(123), uint64(123)) { + t.Error("Equal should return true") + } + funcA := func() int { return 42 } + if !Equal(mockT, funcA, funcA) { + t.Error("Equal should return true") + } + +} + +func TestNotNil(t *testing.T) { + + mockT := new(testing.T) + + if !NotNil(mockT, new(AssertionTesterConformingObject)) { + t.Error("NotNil should return true: object is not nil") + } + if NotNil(mockT, nil) { + t.Error("NotNil should return false: object is nil") + } + +} + +func TestNil(t *testing.T) { + + mockT := new(testing.T) + + if !Nil(mockT, nil) { + t.Error("Nil should return true: object is nil") + } + if Nil(mockT, new(AssertionTesterConformingObject)) { + t.Error("Nil should return false: object is not nil") + } + +} + +func TestTrue(t *testing.T) { + + mockT := new(testing.T) + + if !True(mockT, true) { + t.Error("True should return true") + } + if True(mockT, false) { + t.Error("True should return false") + } + +} + +func TestFalse(t *testing.T) { + + mockT := new(testing.T) + + if !False(mockT, false) { + t.Error("False should return true") + } + if False(mockT, true) { + t.Error("False should return false") + } + +} + +func TestExactly(t *testing.T) { + + mockT := new(testing.T) + + a := float32(1) + b := float64(1) + c := float32(1) + d := float32(2) + + if Exactly(mockT, a, b) { + t.Error("Exactly should return false") + } + if Exactly(mockT, a, d) { + t.Error("Exactly should return false") + } + if !Exactly(mockT, a, c) { + t.Error("Exactly should return true") + } + + if Exactly(mockT, nil, a) { + t.Error("Exactly should return false") + } + if Exactly(mockT, a, nil) { + t.Error("Exactly should return false") + } + +} + +func TestNotEqual(t *testing.T) { + + mockT := new(testing.T) + + if !NotEqual(mockT, "Hello World", "Hello World!") { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, 123, 1234) { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, 123.5, 123.55) { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, []byte("Hello World"), []byte("Hello World!")) { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, nil, new(AssertionTesterConformingObject)) { + t.Error("NotEqual should return true") + } + funcA := func() int { return 23 } + funcB := func() int { return 42 } + if !NotEqual(mockT, funcA, funcB) { + t.Error("NotEqual should return true") + } + + if NotEqual(mockT, "Hello World", "Hello World") { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, 123, 123) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, 123.5, 123.5) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, []byte("Hello World"), []byte("Hello World")) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { + t.Error("NotEqual should return false") + } +} + +type A struct { + Name, Value string +} + +func TestContains(t *testing.T) { + + mockT := new(testing.T) + list := []string{"Foo", "Bar"} + complexList := []*A{ + {"b", "c"}, + {"d", "e"}, + {"g", "h"}, + {"j", "k"}, + } + + if !Contains(mockT, "Hello World", "Hello") { + t.Error("Contains should return true: \"Hello World\" contains \"Hello\"") + } + if Contains(mockT, "Hello World", "Salut") { + t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"") + } + + if !Contains(mockT, list, "Bar") { + t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Bar\"") + } + if Contains(mockT, list, "Salut") { + t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"") + } + if !Contains(mockT, complexList, &A{"g", "h"}) { + t.Error("Contains should return true: complexList contains {\"g\", \"h\"}") + } + if Contains(mockT, complexList, &A{"g", "e"}) { + t.Error("Contains should return false: complexList contains {\"g\", \"e\"}") + } +} + +func TestNotContains(t *testing.T) { + + mockT := new(testing.T) + list := []string{"Foo", "Bar"} + + if !NotContains(mockT, "Hello World", "Hello!") { + t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"") + } + if NotContains(mockT, "Hello World", "Hello") { + t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"") + } + + if !NotContains(mockT, list, "Foo!") { + t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"") + } + if NotContains(mockT, list, "Foo") { + t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") + } + +} + +func Test_includeElement(t *testing.T) { + + list1 := []string{"Foo", "Bar"} + list2 := []int{1, 2} + + ok, found := includeElement("Hello World", "World") + True(t, ok) + True(t, found) + + ok, found = includeElement(list1, "Foo") + True(t, ok) + True(t, found) + + ok, found = includeElement(list1, "Bar") + True(t, ok) + True(t, found) + + ok, found = includeElement(list2, 1) + True(t, ok) + True(t, found) + + ok, found = includeElement(list2, 2) + True(t, ok) + True(t, found) + + ok, found = includeElement(list1, "Foo!") + True(t, ok) + False(t, found) + + ok, found = includeElement(list2, 3) + True(t, ok) + False(t, found) + + ok, found = includeElement(list2, "1") + True(t, ok) + False(t, found) + + ok, found = includeElement(1433, "1") + False(t, ok) + False(t, found) + +} + +func TestCondition(t *testing.T) { + mockT := new(testing.T) + + if !Condition(mockT, func() bool { return true }, "Truth") { + t.Error("Condition should return true") + } + + if Condition(mockT, func() bool { return false }, "Lie") { + t.Error("Condition should return false") + } + +} + +func TestDidPanic(t *testing.T) { + + if funcDidPanic, _ := didPanic(func() { + panic("Panic!") + }); !funcDidPanic { + t.Error("didPanic should return true") + } + + if funcDidPanic, _ := didPanic(func() { + }); funcDidPanic { + t.Error("didPanic should return false") + } + +} + +func TestPanics(t *testing.T) { + + mockT := new(testing.T) + + if !Panics(mockT, func() { + panic("Panic!") + }) { + t.Error("Panics should return true") + } + + if Panics(mockT, func() { + }) { + t.Error("Panics should return false") + } + +} + +func TestNotPanics(t *testing.T) { + + mockT := new(testing.T) + + if !NotPanics(mockT, func() { + }) { + t.Error("NotPanics should return true") + } + + if NotPanics(mockT, func() { + panic("Panic!") + }) { + t.Error("NotPanics should return false") + } + +} + +func TestEqual_Funcs(t *testing.T) { + + type f func() int + f1 := func() int { return 1 } + f2 := func() int { return 2 } + + f1Copy := f1 + + Equal(t, f1Copy, f1, "Funcs are the same and should be considered equal") + NotEqual(t, f1, f2, "f1 and f2 are different") + +} + +func TestNoError(t *testing.T) { + + mockT := new(testing.T) + + // start with a nil error + var err error + + True(t, NoError(mockT, err), "NoError should return True for nil arg") + + // now set an error + err = errors.New("some error") + + False(t, NoError(mockT, err), "NoError with error should return False") + +} + +func TestError(t *testing.T) { + + mockT := new(testing.T) + + // start with a nil error + var err error + + False(t, Error(mockT, err), "Error should return False for nil arg") + + // now set an error + err = errors.New("some error") + + True(t, Error(mockT, err), "Error with error should return True") + +} + +func TestEqualError(t *testing.T) { + mockT := new(testing.T) + + // start with a nil error + var err error + False(t, EqualError(mockT, err, ""), + "EqualError should return false for nil arg") + + // now set an error + err = errors.New("some error") + False(t, EqualError(mockT, err, "Not some error"), + "EqualError should return false for different error string") + True(t, EqualError(mockT, err, "some error"), + "EqualError should return true") +} + +func Test_isEmpty(t *testing.T) { + + chWithValue := make(chan struct{}, 1) + chWithValue <- struct{}{} + + True(t, isEmpty("")) + True(t, isEmpty(nil)) + True(t, isEmpty([]string{})) + True(t, isEmpty(0)) + True(t, isEmpty(int32(0))) + True(t, isEmpty(int64(0))) + True(t, isEmpty(false)) + True(t, isEmpty(map[string]string{})) + True(t, isEmpty(new(time.Time))) + True(t, isEmpty(make(chan struct{}))) + False(t, isEmpty("something")) + False(t, isEmpty(errors.New("something"))) + False(t, isEmpty([]string{"something"})) + False(t, isEmpty(1)) + False(t, isEmpty(true)) + False(t, isEmpty(map[string]string{"Hello": "World"})) + False(t, isEmpty(chWithValue)) + +} + +func TestEmpty(t *testing.T) { + + mockT := new(testing.T) + chWithValue := make(chan struct{}, 1) + chWithValue <- struct{}{} + + True(t, Empty(mockT, ""), "Empty string is empty") + True(t, Empty(mockT, nil), "Nil is empty") + True(t, Empty(mockT, []string{}), "Empty string array is empty") + True(t, Empty(mockT, 0), "Zero int value is empty") + True(t, Empty(mockT, false), "False value is empty") + True(t, Empty(mockT, make(chan struct{})), "Channel without values is empty") + + False(t, Empty(mockT, "something"), "Non Empty string is not empty") + False(t, Empty(mockT, errors.New("something")), "Non nil object is not empty") + False(t, Empty(mockT, []string{"something"}), "Non empty string array is not empty") + False(t, Empty(mockT, 1), "Non-zero int value is not empty") + False(t, Empty(mockT, true), "True value is not empty") + False(t, Empty(mockT, chWithValue), "Channel with values is not empty") +} + +func TestNotEmpty(t *testing.T) { + + mockT := new(testing.T) + chWithValue := make(chan struct{}, 1) + chWithValue <- struct{}{} + + False(t, NotEmpty(mockT, ""), "Empty string is empty") + False(t, NotEmpty(mockT, nil), "Nil is empty") + False(t, NotEmpty(mockT, []string{}), "Empty string array is empty") + False(t, NotEmpty(mockT, 0), "Zero int value is empty") + False(t, NotEmpty(mockT, false), "False value is empty") + False(t, NotEmpty(mockT, make(chan struct{})), "Channel without values is empty") + + True(t, NotEmpty(mockT, "something"), "Non Empty string is not empty") + True(t, NotEmpty(mockT, errors.New("something")), "Non nil object is not empty") + True(t, NotEmpty(mockT, []string{"something"}), "Non empty string array is not empty") + True(t, NotEmpty(mockT, 1), "Non-zero int value is not empty") + True(t, NotEmpty(mockT, true), "True value is not empty") + True(t, NotEmpty(mockT, chWithValue), "Channel with values is not empty") +} + +func Test_getLen(t *testing.T) { + falseCases := []interface{}{ + nil, + 0, + true, + false, + 'A', + struct{}{}, + } + for _, v := range falseCases { + ok, l := getLen(v) + False(t, ok, "Expected getLen fail to get length of %#v", v) + Equal(t, 0, l, "getLen should return 0 for %#v", v) + } + + ch := make(chan int, 5) + ch <- 1 + ch <- 2 + ch <- 3 + trueCases := []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 3}, + {[...]int{1, 2, 3}, 3}, + {"ABC", 3}, + {map[int]int{1: 2, 2: 4, 3: 6}, 3}, + {ch, 3}, + + {[]int{}, 0}, + {map[int]int{}, 0}, + {make(chan int), 0}, + + {[]int(nil), 0}, + {map[int]int(nil), 0}, + {(chan int)(nil), 0}, + } + + for _, c := range trueCases { + ok, l := getLen(c.v) + True(t, ok, "Expected getLen success to get length of %#v", c.v) + Equal(t, c.l, l) + } +} + +func TestLen(t *testing.T) { + mockT := new(testing.T) + + False(t, Len(mockT, nil, 0), "nil does not have length") + False(t, Len(mockT, 0, 0), "int does not have length") + False(t, Len(mockT, true, 0), "true does not have length") + False(t, Len(mockT, false, 0), "false does not have length") + False(t, Len(mockT, 'A', 0), "Rune does not have length") + False(t, Len(mockT, struct{}{}, 0), "Struct does not have length") + + ch := make(chan int, 5) + ch <- 1 + ch <- 2 + ch <- 3 + + cases := []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 3}, + {[...]int{1, 2, 3}, 3}, + {"ABC", 3}, + {map[int]int{1: 2, 2: 4, 3: 6}, 3}, + {ch, 3}, + + {[]int{}, 0}, + {map[int]int{}, 0}, + {make(chan int), 0}, + + {[]int(nil), 0}, + {map[int]int(nil), 0}, + {(chan int)(nil), 0}, + } + + for _, c := range cases { + True(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) + } + + cases = []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 4}, + {[...]int{1, 2, 3}, 2}, + {"ABC", 2}, + {map[int]int{1: 2, 2: 4, 3: 6}, 4}, + {ch, 2}, + + {[]int{}, 1}, + {map[int]int{}, 1}, + {make(chan int), 1}, + + {[]int(nil), 1}, + {map[int]int(nil), 1}, + {(chan int)(nil), 1}, + } + + for _, c := range cases { + False(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) + } +} + +func TestWithinDuration(t *testing.T) { + + mockT := new(testing.T) + a := time.Now() + b := a.Add(10 * time.Second) + + True(t, WithinDuration(mockT, a, b, 10*time.Second), "A 10s difference is within a 10s time difference") + True(t, WithinDuration(mockT, b, a, 10*time.Second), "A 10s difference is within a 10s time difference") + + False(t, WithinDuration(mockT, a, b, 9*time.Second), "A 10s difference is not within a 9s time difference") + False(t, WithinDuration(mockT, b, a, 9*time.Second), "A 10s difference is not within a 9s time difference") + + False(t, WithinDuration(mockT, a, b, -9*time.Second), "A 10s difference is not within a 9s time difference") + False(t, WithinDuration(mockT, b, a, -9*time.Second), "A 10s difference is not within a 9s time difference") + + False(t, WithinDuration(mockT, a, b, -11*time.Second), "A 10s difference is not within a 9s time difference") + False(t, WithinDuration(mockT, b, a, -11*time.Second), "A 10s difference is not within a 9s time difference") +} + +func TestInDelta(t *testing.T) { + mockT := new(testing.T) + + True(t, InDelta(mockT, 1.001, 1, 0.01), "|1.001 - 1| <= 0.01") + True(t, InDelta(mockT, 1, 1.001, 0.01), "|1 - 1.001| <= 0.01") + True(t, InDelta(mockT, 1, 2, 1), "|1 - 2| <= 1") + False(t, InDelta(mockT, 1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") + False(t, InDelta(mockT, 2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") + False(t, InDelta(mockT, "", nil, 1), "Expected non numerals to fail") + + cases := []struct { + a, b interface{} + delta float64 + }{ + {uint8(2), uint8(1), 1}, + {uint16(2), uint16(1), 1}, + {uint32(2), uint32(1), 1}, + {uint64(2), uint64(1), 1}, + + {int(2), int(1), 1}, + {int8(2), int8(1), 1}, + {int16(2), int16(1), 1}, + {int32(2), int32(1), 1}, + {int64(2), int64(1), 1}, + + {float32(2), float32(1), 1}, + {float64(2), float64(1), 1}, + } + + for _, tc := range cases { + True(t, InDelta(mockT, tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) + } +} + +func TestInEpsilon(t *testing.T) { + mockT := new(testing.T) + + cases := []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), uint16(2), .001}, + {2.1, 2.2, 0.1}, + {2.2, 2.1, 0.1}, + {-2.1, -2.2, 0.1}, + {-2.2, -2.1, 0.1}, + {uint64(100), uint8(101), 0.01}, + {0.1, -0.1, 2}, + } + + for _, tc := range cases { + True(t, InEpsilon(mockT, tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } + + cases = []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), int16(-2), .001}, + {uint64(100), uint8(102), 0.01}, + {2.1, 2.2, 0.001}, + {2.2, 2.1, 0.001}, + {2.1, -2.2, 1}, + {2.1, "bla-bla", 0}, + {0.1, -0.1, 1.99}, + } + + for _, tc := range cases { + False(t, InEpsilon(mockT, tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } + +} + +func TestRegexp(t *testing.T) { + mockT := new(testing.T) + + cases := []struct { + rx, str string + }{ + {"^start", "start of the line"}, + {"end$", "in the end"}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, + } + + for _, tc := range cases { + True(t, Regexp(mockT, tc.rx, tc.str)) + True(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + False(t, NotRegexp(mockT, tc.rx, tc.str)) + False(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + } + + cases = []struct { + rx, str string + }{ + {"^asdfastart", "Not the start of the line"}, + {"end$", "in the end."}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, + } + + for _, tc := range cases { + False(t, Regexp(mockT, tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) + False(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + True(t, NotRegexp(mockT, tc.rx, tc.str)) + True(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + } +} diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go new file mode 100644 index 0000000..1c6de28 --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go @@ -0,0 +1,150 @@ +// A set of comprehensive testing tools for use with the normal Go testing system. +// +// Example Usage +// +// The following is a complete example using assert in a standard test function: +// import ( +// "testing" +// "github.com/stretchr/testify/assert" +// ) +// +// func TestSomething(t *testing.T) { +// +// var a string = "Hello" +// var b string = "Hello" +// +// assert.Equal(t, a, b, "The two words should be the same.") +// +// } +// +// if you assert many times, use the below: +// +// import ( +// "testing" +// "github.com/stretchr/testify/assert" +// ) +// +// func TestSomething(t *testing.T) { +// assert := assert.New(t) +// +// var a string = "Hello" +// var b string = "Hello" +// +// assert.Equal(a, b, "The two words should be the same.") +// } +// +// Assertions +// +// Assertions allow you to easily write test code, and are global funcs in the `assert` package. +// All assertion functions take, as the first argument, the `*testing.T` object provided by the +// testing framework. This allows the assertion funcs to write the failings and other details to +// the correct place. +// +// Every assertion function also takes an optional string message as the final argument, +// allowing custom error messages to be appended to the message the assertion method outputs. +// +// Here is an overview of the assert functions: +// +// assert.Equal(t, expected, actual [, message [, format-args]) +// +// assert.NotEqual(t, notExpected, actual [, message [, format-args]]) +// +// assert.True(t, actualBool [, message [, format-args]]) +// +// assert.False(t, actualBool [, message [, format-args]]) +// +// assert.Nil(t, actualObject [, message [, format-args]]) +// +// assert.NotNil(t, actualObject [, message [, format-args]]) +// +// assert.Empty(t, actualObject [, message [, format-args]]) +// +// assert.NotEmpty(t, actualObject [, message [, format-args]]) +// +// assert.Len(t, actualObject, expectedLength, [, message [, format-args]]) +// +// assert.Error(t, errorObject [, message [, format-args]]) +// +// assert.NoError(t, errorObject [, message [, format-args]]) +// +// assert.EqualError(t, theError, errString [, message [, format-args]]) +// +// assert.Implements(t, (*MyInterface)(nil), new(MyObject) [,message [, format-args]]) +// +// assert.IsType(t, expectedObject, actualObject [, message [, format-args]]) +// +// assert.Contains(t, stringOrSlice, substringOrElement [, message [, format-args]]) +// +// assert.NotContains(t, stringOrSlice, substringOrElement [, message [, format-args]]) +// +// assert.Panics(t, func(){ +// +// // call code that should panic +// +// } [, message [, format-args]]) +// +// assert.NotPanics(t, func(){ +// +// // call code that should not panic +// +// } [, message [, format-args]]) +// +// assert.WithinDuration(t, timeA, timeB, deltaTime, [, message [, format-args]]) +// +// assert.InDelta(t, numA, numB, delta, [, message [, format-args]]) +// +// assert.InEpsilon(t, numA, numB, epsilon, [, message [, format-args]]) +// +// assert package contains Assertions object. it has assertion methods. +// +// Here is an overview of the assert functions: +// assert.Equal(expected, actual [, message [, format-args]) +// +// assert.NotEqual(notExpected, actual [, message [, format-args]]) +// +// assert.True(actualBool [, message [, format-args]]) +// +// assert.False(actualBool [, message [, format-args]]) +// +// assert.Nil(actualObject [, message [, format-args]]) +// +// assert.NotNil(actualObject [, message [, format-args]]) +// +// assert.Empty(actualObject [, message [, format-args]]) +// +// assert.NotEmpty(actualObject [, message [, format-args]]) +// +// assert.Len(actualObject, expectedLength, [, message [, format-args]]) +// +// assert.Error(errorObject [, message [, format-args]]) +// +// assert.NoError(errorObject [, message [, format-args]]) +// +// assert.EqualError(theError, errString [, message [, format-args]]) +// +// assert.Implements((*MyInterface)(nil), new(MyObject) [,message [, format-args]]) +// +// assert.IsType(expectedObject, actualObject [, message [, format-args]]) +// +// assert.Contains(stringOrSlice, substringOrElement [, message [, format-args]]) +// +// assert.NotContains(stringOrSlice, substringOrElement [, message [, format-args]]) +// +// assert.Panics(func(){ +// +// // call code that should panic +// +// } [, message [, format-args]]) +// +// assert.NotPanics(func(){ +// +// // call code that should not panic +// +// } [, message [, format-args]]) +// +// assert.WithinDuration(timeA, timeB, deltaTime, [, message [, format-args]]) +// +// assert.InDelta(numA, numB, delta, [, message [, format-args]]) +// +// assert.InEpsilon(numA, numB, epsilon, [, message [, format-args]]) +package assert diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/errors.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/errors.go new file mode 100644 index 0000000..ac9dc9d --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/errors.go @@ -0,0 +1,10 @@ +package assert + +import ( + "errors" +) + +// AnError is an error instance useful for testing. If the code does not care +// about error specifics, and only needs to return the error for example, this +// error should be used to make the test code more readable. +var AnError = errors.New("assert.AnError general error for testing") diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go new file mode 100644 index 0000000..67a6925 --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go @@ -0,0 +1,262 @@ +package assert + +import "time" + +type Assertions struct { + t TestingT +} + +func New(t TestingT) *Assertions { + return &Assertions{ + t: t, + } +} + +// Fail reports a failure through +func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool { + return Fail(a.t, failureMessage, msgAndArgs...) +} + +// Implements asserts that an object is implemented by the specified interface. +// +// assert.Implements((*MyInterface)(nil), new(MyObject), "MyObject") +func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { + return Implements(a.t, interfaceObject, object, msgAndArgs...) +} + +// IsType asserts that the specified objects are of the same type. +func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { + return IsType(a.t, expectedType, object, msgAndArgs...) +} + +// Equal asserts that two objects are equal. +// +// assert.Equal(123, 123, "123 and 123 should be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Equal(expected, actual interface{}, msgAndArgs ...interface{}) bool { + return Equal(a.t, expected, actual, msgAndArgs...) +} + +// EqualValues asserts that two objects are equal or convertable to the same types +// and equal. +// +// assert.EqualValues(uint32(123), int32(123), "123 and 123 should be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) EqualValues(expected, actual interface{}, msgAndArgs ...interface{}) bool { + return EqualValues(a.t, expected, actual, msgAndArgs...) +} + +// Exactly asserts that two objects are equal is value and type. +// +// assert.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Exactly(expected, actual interface{}, msgAndArgs ...interface{}) bool { + return Exactly(a.t, expected, actual, msgAndArgs...) +} + +// NotNil asserts that the specified object is not nil. +// +// assert.NotNil(err, "err should be something") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { + return NotNil(a.t, object, msgAndArgs...) +} + +// Nil asserts that the specified object is nil. +// +// assert.Nil(err, "err should be nothing") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { + return Nil(a.t, object, msgAndArgs...) +} + +// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or a +// slice with len == 0. +// +// assert.Empty(obj) +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { + return Empty(a.t, object, msgAndArgs...) +} + +// Empty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or a +// slice with len == 0. +// +// if assert.NotEmpty(obj) { +// assert.Equal("two", obj[1]) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool { + return NotEmpty(a.t, object, msgAndArgs...) +} + +// Len asserts that the specified object has specific length. +// Len also fails if the object has a type that len() not accept. +// +// assert.Len(mySlice, 3, "The size of slice is not 3") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool { + return Len(a.t, object, length, msgAndArgs...) +} + +// True asserts that the specified value is true. +// +// assert.True(myBool, "myBool should be true") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { + return True(a.t, value, msgAndArgs...) +} + +// False asserts that the specified value is true. +// +// assert.False(myBool, "myBool should be false") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { + return False(a.t, value, msgAndArgs...) +} + +// NotEqual asserts that the specified values are NOT equal. +// +// assert.NotEqual(obj1, obj2, "two objects shouldn't be equal") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NotEqual(expected, actual interface{}, msgAndArgs ...interface{}) bool { + return NotEqual(a.t, expected, actual, msgAndArgs...) +} + +// Contains asserts that the specified string contains the specified substring. +// +// assert.Contains("Hello World", "World", "But 'Hello World' does contain 'World'") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Contains(s, contains interface{}, msgAndArgs ...interface{}) bool { + return Contains(a.t, s, contains, msgAndArgs...) +} + +// NotContains asserts that the specified string does NOT contain the specified substring. +// +// assert.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NotContains(s, contains interface{}, msgAndArgs ...interface{}) bool { + return NotContains(a.t, s, contains, msgAndArgs...) +} + +// Uses a Comparison to assert a complex condition. +func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool { + return Condition(a.t, comp, msgAndArgs...) +} + +// Panics asserts that the code inside the specified PanicTestFunc panics. +// +// assert.Panics(func(){ +// GoCrazy() +// }, "Calling GoCrazy() should panic") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool { + return Panics(a.t, f, msgAndArgs...) +} + +// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// assert.NotPanics(func(){ +// RemainCalm() +// }, "Calling RemainCalm() should NOT panic") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool { + return NotPanics(a.t, f, msgAndArgs...) +} + +// WithinDuration asserts that the two times are within duration delta of each other. +// +// assert.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) WithinDuration(expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { + return WithinDuration(a.t, expected, actual, delta, msgAndArgs...) +} + +// InDelta asserts that the two numerals are within delta of each other. +// +// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) InDelta(expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + return InDelta(a.t, expected, actual, delta, msgAndArgs...) +} + +// InEpsilon asserts that expected and actual have a relative error less than epsilon +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) InEpsilon(expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { + return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...) +} + +// NoError asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if assert.NoError(err) { +// assert.Equal(actualObj, expectedObj) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NoError(theError error, msgAndArgs ...interface{}) bool { + return NoError(a.t, theError, msgAndArgs...) +} + +// Error asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if assert.Error(err, "An error was expected") { +// assert.Equal(err, expectedError) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Error(theError error, msgAndArgs ...interface{}) bool { + return Error(a.t, theError, msgAndArgs...) +} + +// EqualError asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// if assert.Error(err, "An error was expected") { +// assert.Equal(err, expectedError) +// } +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool { + return EqualError(a.t, theError, errString, msgAndArgs...) +} + +// Regexp asserts that a specified regexp matches a string. +// +// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") +// assert.Regexp(t, "start...$", "it's not starting") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + return Regexp(a.t, rx, str, msgAndArgs...) +} + +// NotRegexp asserts that a specified regexp does not match a string. +// +// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") +// assert.NotRegexp(t, "^start", "it's not starting") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + return NotRegexp(a.t, rx, str, msgAndArgs...) +} diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions_test.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions_test.go new file mode 100644 index 0000000..0dac6c7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions_test.go @@ -0,0 +1,526 @@ +package assert + +import ( + "errors" + "regexp" + "testing" + "time" +) + +func TestImplementsWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) { + t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface") + } + if assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) { + t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface") + } +} + +func TestIsTypeWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { + t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject") + } + if assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) { + t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject") + } + +} + +func TestEqualWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.Equal("Hello World", "Hello World") { + t.Error("Equal should return true") + } + if !assert.Equal(123, 123) { + t.Error("Equal should return true") + } + if !assert.Equal(123.5, 123.5) { + t.Error("Equal should return true") + } + if !assert.Equal([]byte("Hello World"), []byte("Hello World")) { + t.Error("Equal should return true") + } + if !assert.Equal(nil, nil) { + t.Error("Equal should return true") + } +} + +func TestEqualValuesWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.EqualValues(uint32(10), int32(10)) { + t.Error("EqualValues should return true") + } +} + +func TestNotNilWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.NotNil(new(AssertionTesterConformingObject)) { + t.Error("NotNil should return true: object is not nil") + } + if assert.NotNil(nil) { + t.Error("NotNil should return false: object is nil") + } + +} + +func TestNilWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.Nil(nil) { + t.Error("Nil should return true: object is nil") + } + if assert.Nil(new(AssertionTesterConformingObject)) { + t.Error("Nil should return false: object is not nil") + } + +} + +func TestTrueWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.True(true) { + t.Error("True should return true") + } + if assert.True(false) { + t.Error("True should return false") + } + +} + +func TestFalseWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.False(false) { + t.Error("False should return true") + } + if assert.False(true) { + t.Error("False should return false") + } + +} + +func TestExactlyWrapper(t *testing.T) { + assert := New(new(testing.T)) + + a := float32(1) + b := float64(1) + c := float32(1) + d := float32(2) + + if assert.Exactly(a, b) { + t.Error("Exactly should return false") + } + if assert.Exactly(a, d) { + t.Error("Exactly should return false") + } + if !assert.Exactly(a, c) { + t.Error("Exactly should return true") + } + + if assert.Exactly(nil, a) { + t.Error("Exactly should return false") + } + if assert.Exactly(a, nil) { + t.Error("Exactly should return false") + } + +} + +func TestNotEqualWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.NotEqual("Hello World", "Hello World!") { + t.Error("NotEqual should return true") + } + if !assert.NotEqual(123, 1234) { + t.Error("NotEqual should return true") + } + if !assert.NotEqual(123.5, 123.55) { + t.Error("NotEqual should return true") + } + if !assert.NotEqual([]byte("Hello World"), []byte("Hello World!")) { + t.Error("NotEqual should return true") + } + if !assert.NotEqual(nil, new(AssertionTesterConformingObject)) { + t.Error("NotEqual should return true") + } +} + +func TestContainsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + list := []string{"Foo", "Bar"} + + if !assert.Contains("Hello World", "Hello") { + t.Error("Contains should return true: \"Hello World\" contains \"Hello\"") + } + if assert.Contains("Hello World", "Salut") { + t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"") + } + + if !assert.Contains(list, "Foo") { + t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") + } + if assert.Contains(list, "Salut") { + t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"") + } + +} + +func TestNotContainsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + list := []string{"Foo", "Bar"} + + if !assert.NotContains("Hello World", "Hello!") { + t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"") + } + if assert.NotContains("Hello World", "Hello") { + t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"") + } + + if !assert.NotContains(list, "Foo!") { + t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"") + } + if assert.NotContains(list, "Foo") { + t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") + } + +} + +func TestConditionWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.Condition(func() bool { return true }, "Truth") { + t.Error("Condition should return true") + } + + if assert.Condition(func() bool { return false }, "Lie") { + t.Error("Condition should return false") + } + +} + +func TestDidPanicWrapper(t *testing.T) { + + if funcDidPanic, _ := didPanic(func() { + panic("Panic!") + }); !funcDidPanic { + t.Error("didPanic should return true") + } + + if funcDidPanic, _ := didPanic(func() { + }); funcDidPanic { + t.Error("didPanic should return false") + } + +} + +func TestPanicsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.Panics(func() { + panic("Panic!") + }) { + t.Error("Panics should return true") + } + + if assert.Panics(func() { + }) { + t.Error("Panics should return false") + } + +} + +func TestNotPanicsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.NotPanics(func() { + }) { + t.Error("NotPanics should return true") + } + + if assert.NotPanics(func() { + panic("Panic!") + }) { + t.Error("NotPanics should return false") + } + +} + +func TestEqualWrapper_Funcs(t *testing.T) { + + assert := New(t) + + type f func() int + var f1 f = func() int { return 1 } + var f2 f = func() int { return 2 } + + var f1_copy f = f1 + + assert.Equal(f1_copy, f1, "Funcs are the same and should be considered equal") + assert.NotEqual(f1, f2, "f1 and f2 are different") + +} + +func TestNoErrorWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + // start with a nil error + var err error = nil + + assert.True(mockAssert.NoError(err), "NoError should return True for nil arg") + + // now set an error + err = errors.New("Some error") + + assert.False(mockAssert.NoError(err), "NoError with error should return False") + +} + +func TestErrorWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + // start with a nil error + var err error = nil + + assert.False(mockAssert.Error(err), "Error should return False for nil arg") + + // now set an error + err = errors.New("Some error") + + assert.True(mockAssert.Error(err), "Error with error should return True") + +} + +func TestEqualErrorWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + // start with a nil error + var err error + assert.False(mockAssert.EqualError(err, ""), + "EqualError should return false for nil arg") + + // now set an error + err = errors.New("some error") + assert.False(mockAssert.EqualError(err, "Not some error"), + "EqualError should return false for different error string") + assert.True(mockAssert.EqualError(err, "some error"), + "EqualError should return true") +} + +func TestEmptyWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.True(mockAssert.Empty(""), "Empty string is empty") + assert.True(mockAssert.Empty(nil), "Nil is empty") + assert.True(mockAssert.Empty([]string{}), "Empty string array is empty") + assert.True(mockAssert.Empty(0), "Zero int value is empty") + assert.True(mockAssert.Empty(false), "False value is empty") + + assert.False(mockAssert.Empty("something"), "Non Empty string is not empty") + assert.False(mockAssert.Empty(errors.New("something")), "Non nil object is not empty") + assert.False(mockAssert.Empty([]string{"something"}), "Non empty string array is not empty") + assert.False(mockAssert.Empty(1), "Non-zero int value is not empty") + assert.False(mockAssert.Empty(true), "True value is not empty") + +} + +func TestNotEmptyWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.False(mockAssert.NotEmpty(""), "Empty string is empty") + assert.False(mockAssert.NotEmpty(nil), "Nil is empty") + assert.False(mockAssert.NotEmpty([]string{}), "Empty string array is empty") + assert.False(mockAssert.NotEmpty(0), "Zero int value is empty") + assert.False(mockAssert.NotEmpty(false), "False value is empty") + + assert.True(mockAssert.NotEmpty("something"), "Non Empty string is not empty") + assert.True(mockAssert.NotEmpty(errors.New("something")), "Non nil object is not empty") + assert.True(mockAssert.NotEmpty([]string{"something"}), "Non empty string array is not empty") + assert.True(mockAssert.NotEmpty(1), "Non-zero int value is not empty") + assert.True(mockAssert.NotEmpty(true), "True value is not empty") + +} + +func TestLenWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.False(mockAssert.Len(nil, 0), "nil does not have length") + assert.False(mockAssert.Len(0, 0), "int does not have length") + assert.False(mockAssert.Len(true, 0), "true does not have length") + assert.False(mockAssert.Len(false, 0), "false does not have length") + assert.False(mockAssert.Len('A', 0), "Rune does not have length") + assert.False(mockAssert.Len(struct{}{}, 0), "Struct does not have length") + + ch := make(chan int, 5) + ch <- 1 + ch <- 2 + ch <- 3 + + cases := []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 3}, + {[...]int{1, 2, 3}, 3}, + {"ABC", 3}, + {map[int]int{1: 2, 2: 4, 3: 6}, 3}, + {ch, 3}, + + {[]int{}, 0}, + {map[int]int{}, 0}, + {make(chan int), 0}, + + {[]int(nil), 0}, + {map[int]int(nil), 0}, + {(chan int)(nil), 0}, + } + + for _, c := range cases { + assert.True(mockAssert.Len(c.v, c.l), "%#v have %d items", c.v, c.l) + } +} + +func TestWithinDurationWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + a := time.Now() + b := a.Add(10 * time.Second) + + assert.True(mockAssert.WithinDuration(a, b, 10*time.Second), "A 10s difference is within a 10s time difference") + assert.True(mockAssert.WithinDuration(b, a, 10*time.Second), "A 10s difference is within a 10s time difference") + + assert.False(mockAssert.WithinDuration(a, b, 9*time.Second), "A 10s difference is not within a 9s time difference") + assert.False(mockAssert.WithinDuration(b, a, 9*time.Second), "A 10s difference is not within a 9s time difference") + + assert.False(mockAssert.WithinDuration(a, b, -9*time.Second), "A 10s difference is not within a 9s time difference") + assert.False(mockAssert.WithinDuration(b, a, -9*time.Second), "A 10s difference is not within a 9s time difference") + + assert.False(mockAssert.WithinDuration(a, b, -11*time.Second), "A 10s difference is not within a 9s time difference") + assert.False(mockAssert.WithinDuration(b, a, -11*time.Second), "A 10s difference is not within a 9s time difference") +} + +func TestInDeltaWrapper(t *testing.T) { + assert := New(new(testing.T)) + + True(t, assert.InDelta(1.001, 1, 0.01), "|1.001 - 1| <= 0.01") + True(t, assert.InDelta(1, 1.001, 0.01), "|1 - 1.001| <= 0.01") + True(t, assert.InDelta(1, 2, 1), "|1 - 2| <= 1") + False(t, assert.InDelta(1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") + False(t, assert.InDelta(2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") + False(t, assert.InDelta("", nil, 1), "Expected non numerals to fail") + + cases := []struct { + a, b interface{} + delta float64 + }{ + {uint8(2), uint8(1), 1}, + {uint16(2), uint16(1), 1}, + {uint32(2), uint32(1), 1}, + {uint64(2), uint64(1), 1}, + + {int(2), int(1), 1}, + {int8(2), int8(1), 1}, + {int16(2), int16(1), 1}, + {int32(2), int32(1), 1}, + {int64(2), int64(1), 1}, + + {float32(2), float32(1), 1}, + {float64(2), float64(1), 1}, + } + + for _, tc := range cases { + True(t, assert.InDelta(tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) + } +} + +func TestInEpsilonWrapper(t *testing.T) { + assert := New(new(testing.T)) + + cases := []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), uint16(2), .001}, + {2.1, 2.2, 0.1}, + {2.2, 2.1, 0.1}, + {-2.1, -2.2, 0.1}, + {-2.2, -2.1, 0.1}, + {uint64(100), uint8(101), 0.01}, + {0.1, -0.1, 2}, + } + + for _, tc := range cases { + True(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } + + cases = []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), int16(-2), .001}, + {uint64(100), uint8(102), 0.01}, + {2.1, 2.2, 0.001}, + {2.2, 2.1, 0.001}, + {2.1, -2.2, 1}, + {2.1, "bla-bla", 0}, + {0.1, -0.1, 1.99}, + } + + for _, tc := range cases { + False(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } +} + +func TestRegexpWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + cases := []struct { + rx, str string + }{ + {"^start", "start of the line"}, + {"end$", "in the end"}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, + } + + for _, tc := range cases { + True(t, assert.Regexp(tc.rx, tc.str)) + True(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) + False(t, assert.NotRegexp(tc.rx, tc.str)) + False(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) + } + + cases = []struct { + rx, str string + }{ + {"^asdfastart", "Not the start of the line"}, + {"end$", "in the end."}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, + } + + for _, tc := range cases { + False(t, assert.Regexp(tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) + False(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) + True(t, assert.NotRegexp(tc.rx, tc.str)) + True(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) + } +} diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go new file mode 100644 index 0000000..0419c1b --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions.go @@ -0,0 +1,157 @@ +package assert + +import ( + "fmt" + "net/http" + "net/http/httptest" + "net/url" + "strings" +) + +// httpCode is a helper that returns HTTP code of the response. It returns -1 +// if building a new request fails. +func httpCode(handler http.HandlerFunc, mode, url string, values url.Values) int { + w := httptest.NewRecorder() + req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil) + if err != nil { + return -1 + } + handler(w, req) + return w.Code +} + +// HTTPSuccess asserts that a specified handler returns a success status code. +// +// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPSuccess(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values) bool { + code := httpCode(handler, mode, url, values) + if code == -1 { + return false + } + return code >= http.StatusOK && code <= http.StatusPartialContent +} + +// HTTPRedirect asserts that a specified handler returns a redirect status code. +// +// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPRedirect(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values) bool { + code := httpCode(handler, mode, url, values) + if code == -1 { + return false + } + return code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect +} + +// HTTPError asserts that a specified handler returns an error status code. +// +// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPError(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values) bool { + code := httpCode(handler, mode, url, values) + if code == -1 { + return false + } + return code >= http.StatusBadRequest +} + +// HttpBody is a helper that returns HTTP body of the response. It returns +// empty string if building a new request fails. +func HttpBody(handler http.HandlerFunc, mode, url string, values url.Values) string { + w := httptest.NewRecorder() + req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil) + if err != nil { + return "" + } + handler(w, req) + return w.Body.String() +} + +// HTTPBodyContains asserts that a specified handler returns a +// body that contains a string. +// +// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyContains(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool { + body := HttpBody(handler, mode, url, values) + + contains := strings.Contains(body, fmt.Sprint(str)) + if !contains { + Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) + } + + return contains +} + +// HTTPBodyNotContains asserts that a specified handler returns a +// body that does not contain a string. +// +// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool { + body := HttpBody(handler, mode, url, values) + + contains := strings.Contains(body, fmt.Sprint(str)) + if contains { + Fail(t, "Expected response body for %s to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body) + } + + return !contains +} + +// +// Assertions Wrappers +// + +// HTTPSuccess asserts that a specified handler returns a success status code. +// +// assert.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, mode, url string, values url.Values) bool { + return HTTPSuccess(a.t, handler, mode, url, values) +} + +// HTTPRedirect asserts that a specified handler returns a redirect status code. +// +// assert.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, mode, url string, values url.Values) bool { + return HTTPRedirect(a.t, handler, mode, url, values) +} + +// HTTPError asserts that a specified handler returns an error status code. +// +// assert.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPError(handler http.HandlerFunc, mode, url string, values url.Values) bool { + return HTTPError(a.t, handler, mode, url, values) +} + +// HTTPBodyContains asserts that a specified handler returns a +// body that contains a string. +// +// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool { + return HTTPBodyContains(a.t, handler, mode, url, values, str) +} + +// HTTPBodyNotContains asserts that a specified handler returns a +// body that does not contain a string. +// +// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool { + return HTTPBodyNotContains(a.t, handler, mode, url, values, str) +} diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions_test.go b/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions_test.go new file mode 100644 index 0000000..684c2d5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/stretchr/testify/assert/http_assertions_test.go @@ -0,0 +1,86 @@ +package assert + +import ( + "fmt" + "net/http" + "net/url" + "testing" +) + +func httpOK(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) +} + +func httpRedirect(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusTemporaryRedirect) +} + +func httpError(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusInternalServerError) +} + +func TestHTTPStatuses(t *testing.T) { + assert := New(t) + mockT := new(testing.T) + + assert.Equal(HTTPSuccess(mockT, httpOK, "GET", "/", nil), true) + assert.Equal(HTTPSuccess(mockT, httpRedirect, "GET", "/", nil), false) + assert.Equal(HTTPSuccess(mockT, httpError, "GET", "/", nil), false) + + assert.Equal(HTTPRedirect(mockT, httpOK, "GET", "/", nil), false) + assert.Equal(HTTPRedirect(mockT, httpRedirect, "GET", "/", nil), true) + assert.Equal(HTTPRedirect(mockT, httpError, "GET", "/", nil), false) + + assert.Equal(HTTPError(mockT, httpOK, "GET", "/", nil), false) + assert.Equal(HTTPError(mockT, httpRedirect, "GET", "/", nil), false) + assert.Equal(HTTPError(mockT, httpError, "GET", "/", nil), true) +} + +func TestHTTPStatusesWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.Equal(mockAssert.HTTPSuccess(httpOK, "GET", "/", nil), true) + assert.Equal(mockAssert.HTTPSuccess(httpRedirect, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPSuccess(httpError, "GET", "/", nil), false) + + assert.Equal(mockAssert.HTTPRedirect(httpOK, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPRedirect(httpRedirect, "GET", "/", nil), true) + assert.Equal(mockAssert.HTTPRedirect(httpError, "GET", "/", nil), false) + + assert.Equal(mockAssert.HTTPError(httpOK, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPError(httpRedirect, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPError(httpError, "GET", "/", nil), true) +} + +func httpHelloName(w http.ResponseWriter, r *http.Request) { + name := r.FormValue("name") + w.Write([]byte(fmt.Sprintf("Hello, %s!", name))) +} + +func TestHttpBody(t *testing.T) { + assert := New(t) + mockT := new(testing.T) + + assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.False(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) + + assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.True(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) +} + +func TestHttpBodyWrappers(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.True(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.True(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.False(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) + + assert.False(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.False(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.True(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) + +} From 8bf1e629e6cb1ae29783edececc04fd9c95d4bd6 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Thu, 9 Apr 2015 09:20:02 +0200 Subject: [PATCH 3/3] Update testify assert methods `assert.Equal` now tests for type equality as well, which means 256 != 0xff. The alternative is to use `assert.EqualValues` --- acia6551_test.go | 36 +- address_bus_test.go | 18 +- cpu_test.go | 890 ++++++++++++++++++++++---------------------- ram_test.go | 6 +- rom_test.go | 12 +- 5 files changed, 481 insertions(+), 481 deletions(-) diff --git a/acia6551_test.go b/acia6551_test.go index 7caa20f..051834a 100644 --- a/acia6551_test.go +++ b/acia6551_test.go @@ -17,7 +17,7 @@ func TestNewAcia6551(t *testing.T) { acia, err := NewAcia6551(output) assert.Nil(t, err) - assert.Equal(t, 0x4, acia.Size()) + assert.EqualValues(t, 0x4, acia.Size()) } func TestAciaAsMemory(t *testing.T) { @@ -29,17 +29,17 @@ func TestAciaReset(t *testing.T) { a.Reset() - assert.Equal(t, a.tx, 0) + assert.EqualValues(t, a.tx, 0) assert.True(t, a.txEmpty) - assert.Equal(t, a.rx, 0) + assert.EqualValues(t, a.rx, 0) assert.False(t, a.rxFull) assert.False(t, a.txIrqEnabled) assert.False(t, a.rxIrqEnabled) assert.False(t, a.overrun) - assert.Equal(t, 0, a.controlData) + assert.EqualValues(t, 0, a.controlData) } func TestAciaReaderWithTxEmpty(t *testing.T) { @@ -51,7 +51,7 @@ func TestAciaReaderWithTxEmpty(t *testing.T) { value := make([]byte, 1) bytesRead, _ := a.Read(value) - assert.Equal(t, 0, bytesRead) + assert.EqualValues(t, 0, bytesRead) } func TestAciaWriteByteAndReader(t *testing.T) { @@ -70,7 +70,7 @@ func TestAciaWriteByteAndReader(t *testing.T) { <-done - assert.Equal(t, 0x42, value[0]) + assert.EqualValues(t, 0x42, value[0]) } func TestAciaWriterAndReadByte(t *testing.T) { @@ -79,15 +79,15 @@ func TestAciaWriterAndReadByte(t *testing.T) { // System writes a single byte bytesWritten, _ := a.Write([]byte{0x42}) - if assert.Equal(t, 1, bytesWritten) { - assert.Equal(t, 0x42, a.ReadByte(aciaData)) + if assert.EqualValues(t, 1, bytesWritten) { + assert.EqualValues(t, 0x42, a.ReadByte(aciaData)) } // System writes multiple bytes bytesWritten, _ = a.Write([]byte{0x42, 0x32, 0xAB}) - if assert.Equal(t, 3, bytesWritten) { - assert.Equal(t, 0xAB, a.ReadByte(aciaData)) + if assert.EqualValues(t, 3, bytesWritten) { + assert.EqualValues(t, 0xAB, a.ReadByte(aciaData)) } } @@ -108,14 +108,14 @@ func TestAciaCommandRegister(t *testing.T) { assert.True(t, a.rxIrqEnabled) assert.True(t, a.txIrqEnabled) - assert.Equal(t, 0x06, a.ReadByte(aciaCommand)) + assert.EqualValues(t, 0x06, a.ReadByte(aciaCommand)) } func TestAciaControlRegister(t *testing.T) { a, _ := AciaSubject() a.WriteByte(aciaControl, 0xB8) - assert.Equal(t, 0xB8, a.ReadByte(aciaControl)) + assert.EqualValues(t, 0xB8, a.ReadByte(aciaControl)) } func TestAciaStatusRegister(t *testing.T) { @@ -124,22 +124,22 @@ func TestAciaStatusRegister(t *testing.T) { a.rxFull = false a.txEmpty = false a.overrun = false - assert.Equal(t, 0x00, a.ReadByte(aciaStatus)) + assert.EqualValues(t, 0x00, a.ReadByte(aciaStatus)) a.rxFull = true a.txEmpty = false a.overrun = false - assert.Equal(t, 0x08, a.ReadByte(aciaStatus)) + assert.EqualValues(t, 0x08, a.ReadByte(aciaStatus)) a.rxFull = false a.txEmpty = true a.overrun = false - assert.Equal(t, 0x10, a.ReadByte(aciaStatus)) + assert.EqualValues(t, 0x10, a.ReadByte(aciaStatus)) a.rxFull = false a.txEmpty = false a.overrun = true - assert.Equal(t, 0x04, a.ReadByte(aciaStatus)) + assert.EqualValues(t, 0x04, a.ReadByte(aciaStatus)) } func TestAciaIntegration(t *testing.T) { @@ -183,6 +183,6 @@ func TestAciaIntegration(t *testing.T) { // value := make([]byte, 1) // bytesRead, _ := acia.Read(value) - assert.Equal(t, 0x42, value[0]) - assert.Equal(t, 0xAB, cpu.A) + assert.EqualValues(t, 0x42, value[0]) + assert.EqualValues(t, 0xAB, cpu.A) } diff --git a/address_bus_test.go b/address_bus_test.go index bfcd8fc..8949aab 100644 --- a/address_bus_test.go +++ b/address_bus_test.go @@ -14,7 +14,7 @@ func TestEmptyAddressBus(t *testing.T) { assert.Nil(err) if assert.NotNil(bus) { - assert.Equal(0, len(bus.addressables)) + assert.EqualValues(0, len(bus.addressables)) } } @@ -25,7 +25,7 @@ func TestAttachToAddressBus(t *testing.T) { ram, _ := NewRam(0x10000) bus.Attach(ram, 0x0000) - assert.Equal(1, len(bus.addressables)) + assert.EqualValues(1, len(bus.addressables)) } func TestBusReadWrite(t *testing.T) { @@ -39,28 +39,28 @@ func TestBusReadWrite(t *testing.T) { // 8-bit Writing bus.WriteByte(0x1234, 0xFA) - assert.Equal(0xFA, ram.ReadByte(0x1234)) + assert.EqualValues(0xFA, ram.ReadByte(0x1234)) // 16-bit Writing bus.Write16(0x1000, 0xAB42) - assert.Equal(0x42, ram.ReadByte(0x1000)) - assert.Equal(0xAB, ram.ReadByte(0x1001)) + assert.EqualValues(0x42, ram.ReadByte(0x1000)) + assert.EqualValues(0xAB, ram.ReadByte(0x1001)) // 8-bit Reading ram.WriteByte(0x5522, 0xDA) - assert.Equal(0xDA, bus.ReadByte(0x5522)) + assert.EqualValues(0xDA, bus.ReadByte(0x5522)) // 16-bit Reading ram.WriteByte(0x4440, 0x7F) ram.WriteByte(0x4441, 0x56) - assert.Equal(0x567F, bus.Read16(0x4440)) + assert.EqualValues(0x567F, bus.Read16(0x4440)) //// Test addressing memory not mounted at 0x0000 // Read from relative addressable Ram2: $C123 ram2.WriteByte(0x4123, 0xEF) - assert.Equal(0xEF, bus.ReadByte(0xC123)) + assert.EqualValues(0xEF, bus.ReadByte(0xC123)) bus.WriteByte(0x8001, 0x12) - assert.Equal(0x12, ram2.ReadByte(0x0001)) + assert.EqualValues(0x12, ram2.ReadByte(0x0001)) } diff --git a/cpu_test.go b/cpu_test.go index 9e2ac0e..c06be9c 100644 --- a/cpu_test.go +++ b/cpu_test.go @@ -40,29 +40,29 @@ func TestStackPushPopPeek(t *testing.T) { assert := assert.New(t) cpu, _, _ := NewRamMachine() - assert.Equal(0xFF, cpu.SP) + assert.EqualValues(0xFF, cpu.SP) cpu.stackPush(0x42) cpu.stackPush(0xA0) - assert.Equal(0xFD, cpu.SP) - assert.Equal(0x42, cpu.Bus.ReadByte(0x1FF)) - assert.Equal(0xA0, cpu.Bus.ReadByte(0x1FE)) + assert.EqualValues(0xFD, cpu.SP) + assert.EqualValues(0x42, cpu.Bus.ReadByte(0x1FF)) + assert.EqualValues(0xA0, cpu.Bus.ReadByte(0x1FE)) peekValue := cpu.stackPeek() - assert.Equal(0xFD, cpu.SP) - assert.Equal(0xA0, peekValue) + assert.EqualValues(0xFD, cpu.SP) + assert.EqualValues(0xA0, peekValue) popValue := cpu.stackPop() - assert.Equal(0xFE, cpu.SP) - assert.Equal(0xA0, popValue) + assert.EqualValues(0xFE, cpu.SP) + assert.EqualValues(0xA0, popValue) } func TestCpuAddressBus(t *testing.T) { assert := assert.New(t) cpu, bus, _ := NewRamMachine() - assert.Equal(cpu.Bus, bus) + assert.EqualValues(cpu.Bus, bus) assert.NotNil(cpu.Bus) } @@ -76,13 +76,13 @@ func TestCpuReset(t *testing.T) { // **1101** is specified, but we are satisfied with // 00110100 here. - assert.Equal(0x34, cpu.P) + assert.EqualValues(0x34, cpu.P) assert.True(cpu.getIrqDisable()) assert.False(cpu.getDecimal()) assert.True(cpu.getBreak()) // Read PC from $FFFC-FFFD - assert.Equal(0x1234, cpu.PC) + assert.EqualValues(0x1234, cpu.PC) } func TestCpuInterrupt(t *testing.T) { @@ -93,17 +93,17 @@ func TestCpuInterrupt(t *testing.T) { cpu.SP = 0xFF // Set the stack pointer cpu.PC = 0x0380 // Some fake point of execution - assert.Equal(t, 0xFF, cpu.SP) + assert.EqualValues(t, 0xFF, cpu.SP) status := cpu.P // Trigger IRQ cpu.Interrupt() - assert.Equal(t, 0x1234, cpu.PC) - assert.Equal(t, 0x03, cpu.Bus.ReadByte(0x01FF)) - assert.Equal(t, 0x80, cpu.Bus.ReadByte(0x01FE)) - assert.Equal(t, status, cpu.Bus.ReadByte(0x01FD)) + assert.EqualValues(t, 0x1234, cpu.PC) + assert.EqualValues(t, 0x03, cpu.Bus.ReadByte(0x01FF)) + assert.EqualValues(t, 0x80, cpu.Bus.ReadByte(0x01FE)) + assert.EqualValues(t, status, cpu.Bus.ReadByte(0x01FD)) assert.True(t, cpu.getIrqDisable()) } @@ -115,11 +115,11 @@ func TestProgramLoading(t *testing.T) { cpu, bus, _ := NewRamMachine() cpu.LoadProgram(program, 0x0300) - assert.Equal(0xEA, bus.ReadByte(0x0300)) - assert.Equal(0xEB, bus.ReadByte(0x0301)) - assert.Equal(0xEC, bus.ReadByte(0x0302)) + assert.EqualValues(0xEA, bus.ReadByte(0x0300)) + assert.EqualValues(0xEB, bus.ReadByte(0x0301)) + assert.EqualValues(0xEC, bus.ReadByte(0x0302)) - assert.Equal(0x0300, cpu.PC) + assert.EqualValues(0x0300, cpu.PC) } //// NOP @@ -128,7 +128,7 @@ func TestNOP(t *testing.T) { cpu, _, _ := NewRamMachine() cpu.LoadProgram([]byte{0xEA}, 0x0300) cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x0301, cpu.PC) } func TestSEC(t *testing.T) { @@ -208,8 +208,8 @@ func TestADCImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x95, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x95, cpu.A) assert.False(t, cpu.getCarry()) } @@ -220,8 +220,8 @@ func TestADCWithCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x13, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x13, cpu.A) assert.True(t, cpu.getCarry()) } @@ -234,8 +234,8 @@ func TestADCWithCarryOver(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x0A, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0A, cpu.A) assert.False(t, cpu.getCarry()) } @@ -250,8 +250,8 @@ func TestADCWithOverflow(t *testing.T) { // -48 + -112 = 96 => signed overflow cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x60, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x60, cpu.A) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getOverflow()) } @@ -263,8 +263,8 @@ func TestADCZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -275,8 +275,8 @@ func TestADCNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF7, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF7, cpu.A) assert.True(t, cpu.getNegative()) } @@ -288,8 +288,8 @@ func TestADCDecimal(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x47, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x47, cpu.A) } func TestADCZeropage(t *testing.T) { @@ -300,8 +300,8 @@ func TestADCZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } func TestADCZeropageX(t *testing.T) { @@ -313,8 +313,8 @@ func TestADCZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } func TestADCAbsolute(t *testing.T) { @@ -325,8 +325,8 @@ func TestADCAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } func TestADCAbsoluteX(t *testing.T) { @@ -338,8 +338,8 @@ func TestADCAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } func TestADCAbsoluteY(t *testing.T) { @@ -351,8 +351,8 @@ func TestADCAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } func TestADCIndirectX(t *testing.T) { @@ -365,8 +365,8 @@ func TestADCIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } func TestADCIndirectY(t *testing.T) { @@ -379,8 +379,8 @@ func TestADCIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) } //// SBC @@ -393,8 +393,8 @@ func TestSBCImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x41, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x41, cpu.A) assert.True(t, cpu.getCarry()) } @@ -406,8 +406,8 @@ func TestSBCWithoutCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x40, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x40, cpu.A) assert.True(t, cpu.getCarry()) } @@ -419,8 +419,8 @@ func TestSBCNegativeNoCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xff, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xff, cpu.A) assert.False(t, cpu.getCarry()) assert.True(t, cpu.getNegative()) } @@ -433,8 +433,8 @@ func TestSBCDecimal(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x28, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x28, cpu.A) } func TestSBCZero(t *testing.T) { @@ -445,8 +445,8 @@ func TestSBCZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -459,8 +459,8 @@ func TestSBCZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } func TestZeropageX(t *testing.T) { @@ -473,8 +473,8 @@ func TestZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } func TestSBCAbsolute(t *testing.T) { @@ -486,8 +486,8 @@ func TestSBCAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } func TestSBCAbsoluteX(t *testing.T) { @@ -500,8 +500,8 @@ func TestSBCAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } func TestSBCAbsoluteY(t *testing.T) { @@ -514,8 +514,8 @@ func TestSBCAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } func TestSBCIndirectX(t *testing.T) { @@ -529,8 +529,8 @@ func TestSBCIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } func TestSBCIndirectY(t *testing.T) { @@ -544,8 +544,8 @@ func TestSBCIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x30, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x30, cpu.A) } //// INX @@ -557,8 +557,8 @@ func TestINX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x43, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x43, cpu.X) } func TestINXRollover(t *testing.T) { @@ -568,8 +568,8 @@ func TestINXRollover(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.X) } //// INY @@ -581,8 +581,8 @@ func TestINY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x43, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x43, cpu.Y) } func TestINYRollover(t *testing.T) { @@ -592,8 +592,8 @@ func TestINYRollover(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Y) } //// INC @@ -605,8 +605,8 @@ func TestINCZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x42)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x42)) } func TestINCZeropageX(t *testing.T) { @@ -617,8 +617,8 @@ func TestINCZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x43)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x43)) } func TestINCAbsolute(t *testing.T) { @@ -628,8 +628,8 @@ func TestINCAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8000)) } func TestINCAbsoluteX(t *testing.T) { @@ -640,8 +640,8 @@ func TestINCAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8002)) } //// DEX @@ -653,8 +653,8 @@ func TestDEX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x41, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x41, cpu.X) } func TestDEXRollover(t *testing.T) { @@ -664,8 +664,8 @@ func TestDEXRollover(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xFF, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xFF, cpu.X) } //// DEY @@ -677,8 +677,8 @@ func TestDEY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x41, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x41, cpu.Y) } func TestDEYRollover(t *testing.T) { @@ -688,8 +688,8 @@ func TestDEYRollover(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xFF, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xFF, cpu.Y) } //// DEC @@ -701,8 +701,8 @@ func TestDECZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x42)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x42)) } func TestDECZeropageX(t *testing.T) { @@ -713,8 +713,8 @@ func TestDECZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x43)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x43)) } func TestDECAbsolute(t *testing.T) { @@ -724,8 +724,8 @@ func TestDECAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x8000)) } func TestDECAbsoluteX(t *testing.T) { @@ -736,8 +736,8 @@ func TestDECAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x8002)) } //// LDA @@ -748,8 +748,8 @@ func TestLDAImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.A) } func TestLDANegative(t *testing.T) { @@ -758,8 +758,8 @@ func TestLDANegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xAE, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xAE, cpu.A) assert.True(t, cpu.getNegative()) } @@ -769,8 +769,8 @@ func TestLDAZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -781,8 +781,8 @@ func TestLDAZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } func TestLDAZeropageX(t *testing.T) { @@ -793,8 +793,8 @@ func TestLDAZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } func TestLDAAbsolute(t *testing.T) { @@ -804,8 +804,8 @@ func TestLDAAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } func TestLDAAbsoluteX(t *testing.T) { @@ -816,8 +816,8 @@ func TestLDAAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } func TestLDAAbsoluteY(t *testing.T) { @@ -828,8 +828,8 @@ func TestLDAAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } func TestLDAIndirectX(t *testing.T) { @@ -841,8 +841,8 @@ func TestLDAIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } func TestLDAIndirectY(t *testing.T) { @@ -854,8 +854,8 @@ func TestLDAIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.A) } //// LDX @@ -866,8 +866,8 @@ func TestLDXImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.X) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.X) } func TestLDXNegative(t *testing.T) { @@ -876,8 +876,8 @@ func TestLDXNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xAE, cpu.X) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xAE, cpu.X) assert.True(t, cpu.getNegative()) } @@ -887,8 +887,8 @@ func TestLDXZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.X) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.X) assert.True(t, cpu.getZero()) } @@ -899,8 +899,8 @@ func TestLDXZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.X) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.X) } func TestLDXZeropageY(t *testing.T) { @@ -911,8 +911,8 @@ func TestLDXZeropageY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.X) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.X) } func TestLDXAbsolute(t *testing.T) { @@ -922,8 +922,8 @@ func TestLDXAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.X) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.X) } func TestLDXAbsoluteY(t *testing.T) { @@ -934,8 +934,8 @@ func TestLDXAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.X) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.X) } //// LDY @@ -946,8 +946,8 @@ func TestLDYImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Y) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Y) } func TestLDYNegative(t *testing.T) { @@ -956,8 +956,8 @@ func TestLDYNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xAE, cpu.Y) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xAE, cpu.Y) assert.True(t, cpu.getNegative()) } @@ -967,8 +967,8 @@ func TestLDYZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.Y) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Y) assert.True(t, cpu.getZero()) } @@ -979,8 +979,8 @@ func TestLDYZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.Y) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.Y) } func TestLDYZeropageX(t *testing.T) { @@ -991,8 +991,8 @@ func TestLDYZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF8, cpu.Y) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.Y) } func TestLDYAbsolute(t *testing.T) { @@ -1002,8 +1002,8 @@ func TestLDYAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.Y) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.Y) } func TestLDYAbsoluteX(t *testing.T) { @@ -1014,8 +1014,8 @@ func TestLDYAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF8, cpu.Y) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF8, cpu.Y) } //// ORA @@ -1027,8 +1027,8 @@ func TestORAImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x72, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x72, cpu.A) } func TestORANegative(t *testing.T) { @@ -1038,8 +1038,8 @@ func TestORANegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) assert.True(t, cpu.getNegative()) } @@ -1050,8 +1050,8 @@ func TestORAZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1063,8 +1063,8 @@ func TestORAZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } func TestORAZeropageX(t *testing.T) { @@ -1076,8 +1076,8 @@ func TestORAZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } func TestORAAbsolute(t *testing.T) { @@ -1088,8 +1088,8 @@ func TestORAAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } func TestORAAbsoluteX(t *testing.T) { @@ -1101,8 +1101,8 @@ func TestORAAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } func TestORAAbsoluteY(t *testing.T) { @@ -1114,8 +1114,8 @@ func TestORAAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } func TestORAIndirectX(t *testing.T) { @@ -1128,8 +1128,8 @@ func TestORAIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } func TestORAIndirectY(t *testing.T) { @@ -1142,8 +1142,8 @@ func TestORAIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xF2, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xF2, cpu.A) } //// AND @@ -1155,8 +1155,8 @@ func TestANDImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestANDNegative(t *testing.T) { @@ -1166,8 +1166,8 @@ func TestANDNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xA0, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xA0, cpu.A) assert.True(t, cpu.getNegative()) } @@ -1178,8 +1178,8 @@ func TestANDZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1191,8 +1191,8 @@ func TestANDZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x09, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x09, cpu.A) } func TestANDZeropageX(t *testing.T) { @@ -1204,8 +1204,8 @@ func TestANDZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestANDAbsolute(t *testing.T) { @@ -1216,8 +1216,8 @@ func TestANDAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestANDAbsoluteX(t *testing.T) { @@ -1229,8 +1229,8 @@ func TestANDAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestANDAbsoluteY(t *testing.T) { @@ -1242,8 +1242,8 @@ func TestANDAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestANDIndirectX(t *testing.T) { @@ -1256,8 +1256,8 @@ func TestANDIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestANDIndirectY(t *testing.T) { @@ -1270,8 +1270,8 @@ func TestANDIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } //// EOR @@ -1283,8 +1283,8 @@ func TestEORImmediate(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORNegative(t *testing.T) { @@ -1294,8 +1294,8 @@ func TestEORNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xD3, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xD3, cpu.A) assert.True(t, cpu.getNegative()) } @@ -1306,8 +1306,8 @@ func TestEORZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1319,8 +1319,8 @@ func TestEORZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORZeropageX(t *testing.T) { @@ -1332,8 +1332,8 @@ func TestEORZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORAbsolute(t *testing.T) { @@ -1344,8 +1344,8 @@ func TestEORAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORAbsoluteX(t *testing.T) { @@ -1357,8 +1357,8 @@ func TestEORAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORAbsoluteY(t *testing.T) { @@ -1370,8 +1370,8 @@ func TestEORAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORIndirectX(t *testing.T) { @@ -1384,8 +1384,8 @@ func TestEORIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } func TestEORIndirectY(t *testing.T) { @@ -1398,8 +1398,8 @@ func TestEORIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x3D, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x3D, cpu.A) } //// STA @@ -1411,8 +1411,8 @@ func TestSTAZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x0080)) } func TestSTAZeropageX(t *testing.T) { @@ -1423,8 +1423,8 @@ func TestSTAZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x0082)) } func TestSTAAbsolute(t *testing.T) { @@ -1434,8 +1434,8 @@ func TestSTAAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x8000)) } func TestSTAAbsoluteX(t *testing.T) { @@ -1446,8 +1446,8 @@ func TestSTAAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x8002)) } func TestSTAAbsoluteY(t *testing.T) { @@ -1459,8 +1459,8 @@ func TestSTAAbsoluteY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x8002)) } func TestSTAIndirectX(t *testing.T) { @@ -1472,8 +1472,8 @@ func TestSTAIndirectX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0xC000)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0xC000)) } func TestSTAIndirectY(t *testing.T) { @@ -1485,8 +1485,8 @@ func TestSTAIndirectY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0xC002)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0xC002)) } //// STX @@ -1498,8 +1498,8 @@ func TestSTXZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x0080)) } func TestSTXZeropageY(t *testing.T) { @@ -1510,8 +1510,8 @@ func TestSTXZeropageY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x0082)) } func TestSTXAbsolute(t *testing.T) { @@ -1521,8 +1521,8 @@ func TestSTXAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x8000)) } //// STY @@ -1534,8 +1534,8 @@ func TestSTYZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x0080)) } func TestSTYZeropageX(t *testing.T) { @@ -1546,8 +1546,8 @@ func TestSTYZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x0082)) } func TestSTYAbsolute(t *testing.T) { @@ -1557,8 +1557,8 @@ func TestSTYAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x42, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Bus.ReadByte(0x8000)) } //// TAX @@ -1570,8 +1570,8 @@ func TestTAX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x42, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x42, cpu.X) } func TestTAXNegative(t *testing.T) { @@ -1581,8 +1581,8 @@ func TestTAXNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xE0, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xE0, cpu.X) assert.True(t, cpu.getNegative()) } @@ -1593,8 +1593,8 @@ func TestTAXZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.X) assert.True(t, cpu.getZero()) } @@ -1607,8 +1607,8 @@ func TestTAY(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x42, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x42, cpu.Y) } func TestTAYNegative(t *testing.T) { @@ -1618,8 +1618,8 @@ func TestTAYNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xE0, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xE0, cpu.Y) assert.True(t, cpu.getNegative()) } @@ -1630,8 +1630,8 @@ func TestTAYZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.Y) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Y) assert.True(t, cpu.getZero()) } @@ -1644,8 +1644,8 @@ func TestTXA(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x42, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x42, cpu.A) } func TestTXANegative(t *testing.T) { @@ -1655,8 +1655,8 @@ func TestTXANegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xE0, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xE0, cpu.A) assert.True(t, cpu.getNegative()) } @@ -1667,8 +1667,8 @@ func TestTXAZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1681,8 +1681,8 @@ func TestTYA(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x42, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x42, cpu.A) } func TestTYANegative(t *testing.T) { @@ -1692,8 +1692,8 @@ func TestTYANegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xE0, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xE0, cpu.A) assert.True(t, cpu.getNegative()) } @@ -1704,8 +1704,8 @@ func TestTYAZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1718,8 +1718,8 @@ func TestTSX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x42, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x42, cpu.X) } func TestTSXNegative(t *testing.T) { @@ -1729,8 +1729,8 @@ func TestTSXNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xE0, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xE0, cpu.X) assert.True(t, cpu.getNegative()) } @@ -1741,8 +1741,8 @@ func TestTSXZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.X) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.X) assert.True(t, cpu.getZero()) } @@ -1755,8 +1755,8 @@ func TestTXS(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x42, cpu.SP) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x42, cpu.SP) } //// ASL @@ -1768,8 +1768,8 @@ func TestASLaccumulator(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestASLAccumulatorNegative(t *testing.T) { @@ -1779,8 +1779,8 @@ func TestASLAccumulatorNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x80, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x80, cpu.A) assert.True(t, cpu.getNegative()) } @@ -1791,8 +1791,8 @@ func TestASLAccumulatorZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1803,8 +1803,8 @@ func TestASLAccumulatorCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x54, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x54, cpu.A) assert.True(t, cpu.getCarry()) } @@ -1815,8 +1815,8 @@ func TestASLzeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x0080)) } func TestASLzeropageNegative(t *testing.T) { @@ -1826,8 +1826,8 @@ func TestASLzeropageNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x80, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x80, cpu.Bus.ReadByte(0x0080)) assert.True(t, cpu.getNegative()) } @@ -1838,8 +1838,8 @@ func TestASLzeropageZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x0080)) assert.True(t, cpu.getZero()) } @@ -1850,8 +1850,8 @@ func TestASLzeropageCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x54, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x54, cpu.Bus.ReadByte(0x0080)) assert.True(t, cpu.getCarry()) } @@ -1863,8 +1863,8 @@ func TestASLzeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x0082)) } func TestASLabsolute(t *testing.T) { @@ -1874,8 +1874,8 @@ func TestASLabsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8000)) } func TestASLabsoluteX(t *testing.T) { @@ -1886,8 +1886,8 @@ func TestASLabsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8002)) } //// LSR @@ -1899,8 +1899,8 @@ func TestLSRaccumulator(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x01, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x01, cpu.A) } func TestLSRAccumulatorZero(t *testing.T) { @@ -1910,8 +1910,8 @@ func TestLSRAccumulatorZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -1922,8 +1922,8 @@ func TestLSRAccumulatorCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getCarry()) } @@ -1934,8 +1934,8 @@ func TestLSRzeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x01, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x01, cpu.Bus.ReadByte(0x0080)) } func TestLSRzeropageZero(t *testing.T) { @@ -1945,8 +1945,8 @@ func TestLSRzeropageZero(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x0080)) assert.True(t, cpu.getZero()) } @@ -1957,8 +1957,8 @@ func TestLSRzeropageCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x00, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x00, cpu.Bus.ReadByte(0x0080)) assert.True(t, cpu.getCarry()) } @@ -1970,8 +1970,8 @@ func TestLSRzeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x0082)) } func TestLSRabsolute(t *testing.T) { @@ -1981,8 +1981,8 @@ func TestLSRabsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8000)) } func TestLSRabsoluteX(t *testing.T) { @@ -1993,8 +1993,8 @@ func TestLSRabsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8002)) } //// ROL @@ -2006,8 +2006,8 @@ func TestROLAccumulator(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x02, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x02, cpu.A) } func TestROLAccumulatorZeroAndCarry(t *testing.T) { @@ -2019,8 +2019,8 @@ func TestROLAccumulatorZeroAndCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) assert.True(t, cpu.getCarry()) } @@ -2034,8 +2034,8 @@ func TestROLAccumulatorNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x80, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x80, cpu.A) assert.True(t, cpu.getNegative()) } @@ -2046,8 +2046,8 @@ func TestROLZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x0080)) } func TestROLZeropageX(t *testing.T) { @@ -2058,8 +2058,8 @@ func TestROLZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x0082)) } func TestROLAbsolute(t *testing.T) { @@ -2069,8 +2069,8 @@ func TestROLAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8000)) } func TestROLAbsoluteX(t *testing.T) { @@ -2081,8 +2081,8 @@ func TestROLAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x8002)) } //// ROR @@ -2094,8 +2094,8 @@ func TestRORAccumulator(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x01, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x01, cpu.A) } func TestRORAccumulatorZeroAndCarry(t *testing.T) { @@ -2107,8 +2107,8 @@ func TestRORAccumulatorZeroAndCarry(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) assert.True(t, cpu.getCarry()) } @@ -2122,8 +2122,8 @@ func TestRORAccumulatorNegative(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0x80, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0x80, cpu.A) assert.True(t, cpu.getNegative()) } @@ -2134,8 +2134,8 @@ func TestRORZeropage(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x01, cpu.Bus.ReadByte(0x0080)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x01, cpu.Bus.ReadByte(0x0080)) } func TestRORZeropageX(t *testing.T) { @@ -2146,8 +2146,8 @@ func TestRORZeropageX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0x01, cpu.Bus.ReadByte(0x0082)) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x01, cpu.Bus.ReadByte(0x0082)) } func TestRORAbsolute(t *testing.T) { @@ -2157,8 +2157,8 @@ func TestRORAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x01, cpu.Bus.ReadByte(0x8000)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x01, cpu.Bus.ReadByte(0x8000)) } func TestRORAbsoluteX(t *testing.T) { @@ -2169,8 +2169,8 @@ func TestRORAbsoluteX(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0x01, cpu.Bus.ReadByte(0x8002)) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x01, cpu.Bus.ReadByte(0x8002)) } /// CMP @@ -2183,7 +2183,7 @@ func TestCMPImmediate(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2193,7 +2193,7 @@ func TestCMPImmediate(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2203,7 +2203,7 @@ func TestCMPImmediate(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2218,7 +2218,7 @@ func TestCMPZeropage(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2229,7 +2229,7 @@ func TestCMPZeropage(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2240,7 +2240,7 @@ func TestCMPZeropage(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2256,7 +2256,7 @@ func TestCMPZeropageX(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2268,7 +2268,7 @@ func TestCMPZeropageX(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2280,7 +2280,7 @@ func TestCMPZeropageX(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2295,7 +2295,7 @@ func TestCMPAbsolute(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2306,7 +2306,7 @@ func TestCMPAbsolute(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2317,7 +2317,7 @@ func TestCMPAbsolute(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2333,7 +2333,7 @@ func TestCMPAbsoluteX(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2345,7 +2345,7 @@ func TestCMPAbsoluteX(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2357,7 +2357,7 @@ func TestCMPAbsoluteX(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2373,7 +2373,7 @@ func TestCMPAbsoluteY(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2385,7 +2385,7 @@ func TestCMPAbsoluteY(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2397,7 +2397,7 @@ func TestCMPAbsoluteY(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2414,7 +2414,7 @@ func TestCMPIndirectX(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2427,7 +2427,7 @@ func TestCMPIndirectX(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2440,7 +2440,7 @@ func TestCMPIndirectX(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2457,7 +2457,7 @@ func TestCMPIndirectY(t *testing.T) { cpu.A = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2470,7 +2470,7 @@ func TestCMPIndirectY(t *testing.T) { cpu.A = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2483,7 +2483,7 @@ func TestCMPIndirectY(t *testing.T) { cpu.A = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2499,7 +2499,7 @@ func TestCPXImmediate(t *testing.T) { cpu.X = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2509,7 +2509,7 @@ func TestCPXImmediate(t *testing.T) { cpu.X = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2519,7 +2519,7 @@ func TestCPXImmediate(t *testing.T) { cpu.X = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2534,7 +2534,7 @@ func TestCPXZeropage(t *testing.T) { cpu.X = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2545,7 +2545,7 @@ func TestCPXZeropage(t *testing.T) { cpu.X = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2556,7 +2556,7 @@ func TestCPXZeropage(t *testing.T) { cpu.X = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2571,7 +2571,7 @@ func TestCPXAbsolute(t *testing.T) { cpu.X = 0x42 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2582,7 +2582,7 @@ func TestCPXAbsolute(t *testing.T) { cpu.X = 0x43 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2593,7 +2593,7 @@ func TestCPXAbsolute(t *testing.T) { cpu.X = 0x08 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2609,7 +2609,7 @@ func TestCPYImmediate(t *testing.T) { cpu.Y = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2619,7 +2619,7 @@ func TestCPYImmediate(t *testing.T) { cpu.Y = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2629,7 +2629,7 @@ func TestCPYImmediate(t *testing.T) { cpu.Y = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2644,7 +2644,7 @@ func TestCPYZeropage(t *testing.T) { cpu.Y = 0x42 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2655,7 +2655,7 @@ func TestCPYZeropage(t *testing.T) { cpu.Y = 0x43 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2666,7 +2666,7 @@ func TestCPYZeropage(t *testing.T) { cpu.Y = 0x08 cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2681,7 +2681,7 @@ func TestCPYAbsolute(t *testing.T) { cpu.Y = 0x42 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.True(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2692,7 +2692,7 @@ func TestCPYAbsolute(t *testing.T) { cpu.Y = 0x43 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.True(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.False(t, cpu.getNegative()) @@ -2703,7 +2703,7 @@ func TestCPYAbsolute(t *testing.T) { cpu.Y = 0x08 cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0x0303, cpu.PC) assert.False(t, cpu.getCarry()) assert.False(t, cpu.getZero()) assert.True(t, cpu.getNegative()) @@ -2720,10 +2720,10 @@ func TestBRK(t *testing.T) { cpu.Step() - assert.Equal(t, 0x1234, cpu.PC) - assert.Equal(t, 0x03, cpu.Bus.ReadByte(0x01FF)) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x01FE)) - assert.Equal(t, status, cpu.Bus.ReadByte(0x01FD)) + assert.EqualValues(t, 0x1234, cpu.PC) + assert.EqualValues(t, 0x03, cpu.Bus.ReadByte(0x01FF)) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x01FE)) + assert.EqualValues(t, status, cpu.Bus.ReadByte(0x01FD)) assert.True(t, cpu.getBreak()) } @@ -2738,28 +2738,28 @@ func TestBCC(t *testing.T) { cpu.LoadProgram([]byte{0x90, 0x05}, 0x0300) cpu.setCarry(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x90, 0x05}, 0x0300) cpu.setCarry(false) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) /// Negative offset // Carry set cpu.LoadProgram([]byte{0x90, 0xfb}, 0x0300) cpu.setCarry(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x90, 0xFB}, 0x0300) cpu.setCarry(false) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) } //// BCS @@ -2773,13 +2773,13 @@ func TestBCS(t *testing.T) { cpu.setCarry(true) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0xB0, 0x05}, 0x0300) cpu.setCarry(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) /// Negative offset // Carry set @@ -2787,13 +2787,13 @@ func TestBCS(t *testing.T) { cpu.setCarry(true) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0xB0, 0xFB}, 0x0300) cpu.setCarry(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) } //// BNE @@ -2806,28 +2806,28 @@ func TestBNE(t *testing.T) { cpu.LoadProgram([]byte{0xD0, 0x05}, 0x0300) cpu.setZero(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0xD0, 0x05}, 0x0300) cpu.setZero(false) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) /// Negative offset // Carry set cpu.LoadProgram([]byte{0xD0, 0xfb}, 0x0300) cpu.setZero(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0xD0, 0xFB}, 0x0300) cpu.setZero(false) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) } //// BEQ @@ -2841,13 +2841,13 @@ func TestBEQ(t *testing.T) { cpu.setZero(true) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0xF0, 0x05}, 0x0300) cpu.setZero(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) /// Negative offset // Carry set @@ -2855,13 +2855,13 @@ func TestBEQ(t *testing.T) { cpu.setZero(true) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0xF0, 0xFB}, 0x0300) cpu.setZero(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) } //// BPL @@ -2874,28 +2874,28 @@ func TestBPL(t *testing.T) { cpu.LoadProgram([]byte{0x10, 0x05}, 0x0300) cpu.setNegative(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x10, 0x05}, 0x0300) cpu.setNegative(false) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) /// Negative offset // Carry set cpu.LoadProgram([]byte{0x10, 0xfb}, 0x0300) cpu.setNegative(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x10, 0xFB}, 0x0300) cpu.setNegative(false) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) } //// BMI @@ -2909,13 +2909,13 @@ func TestBMI(t *testing.T) { cpu.setNegative(true) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x30, 0x05}, 0x0300) cpu.setNegative(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) /// Negative offset // Carry set @@ -2923,13 +2923,13 @@ func TestBMI(t *testing.T) { cpu.setNegative(true) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x30, 0xFB}, 0x0300) cpu.setNegative(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) } //// BVC @@ -2942,28 +2942,28 @@ func TestBVC(t *testing.T) { cpu.LoadProgram([]byte{0x50, 0x05}, 0x0300) cpu.setOverflow(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x50, 0x05}, 0x0300) cpu.setOverflow(false) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) /// Negative offset // Carry set cpu.LoadProgram([]byte{0x50, 0xfb}, 0x0300) cpu.setOverflow(true) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x50, 0xFB}, 0x0300) cpu.setOverflow(false) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) } //// BVS @@ -2977,13 +2977,13 @@ func TestBVS(t *testing.T) { cpu.setOverflow(true) cpu.Step() // 0x0302 + 0x05 = 0x0307 - assert.Equal(t, 0x0307, cpu.PC) + assert.EqualValues(t, 0x0307, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x70, 0x05}, 0x0300) cpu.setOverflow(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) /// Negative offset // Carry set @@ -2991,13 +2991,13 @@ func TestBVS(t *testing.T) { cpu.setOverflow(true) cpu.Step() // 0x0302 + 0xFB => 0x0302 - 0x05 => 0x02FD - assert.Equal(t, 0x02FD, cpu.PC) + assert.EqualValues(t, 0x02FD, cpu.PC) // Carry not set cpu.LoadProgram([]byte{0x70, 0xFB}, 0x0300) cpu.setOverflow(false) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0x0302, cpu.PC) } //// BIT @@ -3098,9 +3098,9 @@ func TestPHP(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xFE, cpu.SP) - assert.Equal(t, 0xB5, cpu.Bus.ReadByte(0x01FF)) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xFE, cpu.SP) + assert.EqualValues(t, 0xB5, cpu.Bus.ReadByte(0x01FF)) } //// PLP @@ -3113,9 +3113,9 @@ func TestPLP(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xFF, cpu.SP) - assert.Equal(t, 0xB5, cpu.P) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xFF, cpu.SP) + assert.EqualValues(t, 0xB5, cpu.P) } //// PHA @@ -3128,9 +3128,9 @@ func TestPHA(t *testing.T) { cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xFE, cpu.SP) - assert.Equal(t, 0xB5, cpu.Bus.ReadByte(0x01FF)) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xFE, cpu.SP) + assert.EqualValues(t, 0xB5, cpu.Bus.ReadByte(0x01FF)) } //// PLP @@ -3142,24 +3142,24 @@ func TestPLA(t *testing.T) { cpu.stackPush(0x42) cpu.Step() - assert.Equal(t, 0x0301, cpu.PC) - assert.Equal(t, 0xFF, cpu.SP) - assert.Equal(t, 0x42, cpu.A) + assert.EqualValues(t, 0x0301, cpu.PC) + assert.EqualValues(t, 0xFF, cpu.SP) + assert.EqualValues(t, 0x42, cpu.A) cpu.stackPush(0xB5) cpu.Step() - assert.Equal(t, 0x0302, cpu.PC) - assert.Equal(t, 0xFF, cpu.SP) - assert.Equal(t, 0xB5, cpu.A) + assert.EqualValues(t, 0x0302, cpu.PC) + assert.EqualValues(t, 0xFF, cpu.SP) + assert.EqualValues(t, 0xB5, cpu.A) assert.True(t, cpu.getNegative()) cpu.stackPush(0x00) cpu.Step() - assert.Equal(t, 0x0303, cpu.PC) - assert.Equal(t, 0xFF, cpu.SP) - assert.Equal(t, 0x00, cpu.A) + assert.EqualValues(t, 0x0303, cpu.PC) + assert.EqualValues(t, 0xFF, cpu.SP) + assert.EqualValues(t, 0x00, cpu.A) assert.True(t, cpu.getZero()) } @@ -3171,7 +3171,7 @@ func TestJMPAbsolute(t *testing.T) { cpu.Step() - assert.Equal(t, 0x1234, cpu.PC) + assert.EqualValues(t, 0x1234, cpu.PC) } func TestJMPIndirect(t *testing.T) { @@ -3181,7 +3181,7 @@ func TestJMPIndirect(t *testing.T) { cpu.Step() - assert.Equal(t, 0x1234, cpu.PC) + assert.EqualValues(t, 0x1234, cpu.PC) } //// JSR @@ -3193,12 +3193,12 @@ func TestJSR(t *testing.T) { cpu.Step() - assert.Equal(t, 0x1234, cpu.PC) - assert.Equal(t, 0xFD, cpu.SP) + assert.EqualValues(t, 0x1234, cpu.PC) + assert.EqualValues(t, 0xFD, cpu.SP) // We expect PC - 1 (e.g. 3rd byte of JSR) to be on the stack - assert.Equal(t, 0x03, cpu.Bus.ReadByte(0x1FF)) - assert.Equal(t, 0x02, cpu.Bus.ReadByte(0x1FE)) + assert.EqualValues(t, 0x03, cpu.Bus.ReadByte(0x1FF)) + assert.EqualValues(t, 0x02, cpu.Bus.ReadByte(0x1FE)) } //// RTS @@ -3213,8 +3213,8 @@ func TestRTS(t *testing.T) { cpu.Step() - assert.Equal(t, 0x1234+1, cpu.PC) - assert.Equal(t, 0x34, cpu.P) + assert.EqualValues(t, 0x1234+1, cpu.PC) + assert.EqualValues(t, 0x34, cpu.P) } //// RTI @@ -3229,8 +3229,8 @@ func TestRTI(t *testing.T) { cpu.Step() - assert.Equal(t, 0x1234, cpu.PC) - assert.Equal(t, 0x5B|0x20, cpu.P) + assert.EqualValues(t, 0x1234, cpu.PC) + assert.EqualValues(t, 0x5B|0x20, cpu.P) } // Run this last, as the full suite takes ±10 seconds to run at diff --git a/ram_test.go b/ram_test.go index b341b39..fdc5ee4 100644 --- a/ram_test.go +++ b/ram_test.go @@ -12,7 +12,7 @@ func TestRamAsMemory(t *testing.T) { func TestRamSize(t *testing.T) { ram, _ := NewRam(0x8000) // 32 kB - assert.Equal(t, 0x8000, ram.Size()) + assert.EqualValues(t, 0x8000, ram.Size()) } func TestRamReadWrite(t *testing.T) { @@ -20,9 +20,9 @@ func TestRamReadWrite(t *testing.T) { // Ram zeroed out initially for i := 0; i < 0x8000; i++ { - assert.Equal(t, 0x00, ram.data[i]) + assert.EqualValues(t, 0x00, ram.data[i]) } ram.WriteByte(0x1000, 0x42) - assert.Equal(t, 0x42, ram.ReadByte(0x1000)) + assert.EqualValues(t, 0x42, ram.ReadByte(0x1000)) } diff --git a/rom_test.go b/rom_test.go index c6a5426..4c1a3f6 100644 --- a/rom_test.go +++ b/rom_test.go @@ -14,9 +14,9 @@ func Test8kRoms(t *testing.T) { rom, err := NewRom("test/8kb.rom") assert.Nil(t, err) - assert.Equal(t, 0x2000, rom.Size()) - assert.Equal(t, 0x01, rom.ReadByte(0x0000)) - assert.Equal(t, 0xFF, rom.ReadByte(0x2000-1)) + assert.EqualValues(t, 0x2000, rom.Size()) + assert.EqualValues(t, 0x01, rom.ReadByte(0x0000)) + assert.EqualValues(t, 0xFF, rom.ReadByte(0x2000-1)) } func TestRomWritePanic(t *testing.T) { @@ -32,9 +32,9 @@ func Test16kRom(t *testing.T) { rom, err := NewRom("test/16kb.rom") assert.Nil(t, err) - assert.Equal(t, 0x4000, rom.Size()) - assert.Equal(t, 0x01, rom.ReadByte(0x0000)) - assert.Equal(t, 0xFF, rom.ReadByte(0x4000-1)) + assert.EqualValues(t, 0x4000, rom.Size()) + assert.EqualValues(t, 0x01, rom.ReadByte(0x0000)) + assert.EqualValues(t, 0xFF, rom.ReadByte(0x4000-1)) } func TestRomNotFound(t *testing.T) {