2022-02-21 22:05:53 +00:00
|
|
|
package izapple2
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
func testBoots(t *testing.T, model string, disk string, cycles uint64, banner string, prompt string) {
|
|
|
|
overrides := newConfiguration()
|
|
|
|
if disk != "" {
|
|
|
|
overrides.set(confS6, "diskii,disk1=\""+disk+"\"")
|
|
|
|
} else {
|
|
|
|
overrides.set(confS6, "empty")
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
at, err := makeApple2Tester(model, overrides)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
at.terminateCondition = func(a *Apple2) bool {
|
2024-01-06 20:48:23 +00:00
|
|
|
return a.cpu.GetCycles() > cycles
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
at.run()
|
|
|
|
|
|
|
|
text := at.getText()
|
2024-01-06 20:48:23 +00:00
|
|
|
if !strings.Contains(text, banner) {
|
|
|
|
t.Errorf("Expected '%s', got '%s'", banner, text)
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
2024-01-06 20:48:23 +00:00
|
|
|
if !strings.Contains(text, prompt) {
|
|
|
|
t.Errorf("Expected prompt '%s', got '%s'", prompt, text)
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
2024-01-06 20:48:23 +00:00
|
|
|
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
func TestPlusBoots(t *testing.T) {
|
|
|
|
testBoots(t, "2plus", "", 200_000, "APPLE ][", "\n]")
|
|
|
|
}
|
2022-02-21 22:05:53 +00:00
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
func Test2EBoots(t *testing.T) {
|
|
|
|
testBoots(t, "2e", "", 200_000, "Apple ][", "\n]")
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
func Test2EnhancedBoots(t *testing.T) {
|
|
|
|
testBoots(t, "2enh", "", 200_000, "Apple //e", "\n]")
|
|
|
|
}
|
2022-02-21 22:05:53 +00:00
|
|
|
|
2024-01-06 20:48:23 +00:00
|
|
|
func TestBase64Boots(t *testing.T) {
|
|
|
|
testBoots(t, "base64a", "", 1_000_000, "BASE 64A", "\n]")
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestPlusDOS33Boots(t *testing.T) {
|
2024-01-06 20:48:23 +00:00
|
|
|
testBoots(t, "2plus", "<internal>/dos33.dsk", 100_000_000, "DOS VERSION 3.3", "\n]")
|
2022-02-21 22:05:53 +00:00
|
|
|
}
|