mirror of
https://github.com/zellyn/goapple2.git
synced 2024-10-02 20:55:00 +00:00
33 lines
639 B
Go
33 lines
639 B
Go
|
package disk
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestPreNybble(t *testing.T) {
|
||
|
var source [256]byte
|
||
|
for i := range source {
|
||
|
source[i] = byte(i)
|
||
|
}
|
||
|
target := PreNybble(source[:])
|
||
|
for i := range target {
|
||
|
if target[i] > 0x3F {
|
||
|
t.Errorf("target[%d] too large: 0x%02X", i, target[i])
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestPrePostNybble(t *testing.T) {
|
||
|
var source [256]byte
|
||
|
for i := range source {
|
||
|
source[i] = byte(i)
|
||
|
}
|
||
|
target := PreNybble(source[:])
|
||
|
sourceCheck := PostNybble(target[:])
|
||
|
for i := range source {
|
||
|
if source[i] != sourceCheck[i] {
|
||
|
t.Errorf("source, sourceCheck differ at %d: 0x%02X != 0x%02X", i, source[i], sourceCheck[i])
|
||
|
}
|
||
|
}
|
||
|
}
|