-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test-coverage for the console output functions (#123)
* Added test-coverage for the console output functions We've not added complete tests for the ADM-3A driver, but we've added enough to prove it works - by allowing output to be redirected we can test it does the right kinda thing. * Updated to use the correct type for our console handle * Added trivial test * Added version test
- Loading branch information
Showing
8 changed files
with
210 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package consoleout | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
// NullOutputDriver holds our state. | ||
type NullOutputDriver struct { | ||
|
||
// writer is where we send our output | ||
writer io.Writer | ||
} | ||
|
||
// GetName returns the name of this driver. | ||
// | ||
// This is part of the OutputDriver interface. | ||
func (no *NullOutputDriver) GetName() string { | ||
return "null" | ||
} | ||
|
||
// PutCharacter writes the specified character to the console, | ||
// as this is a null-driver nothing happens and instead the output | ||
// is discarded. | ||
// | ||
// This is part of the OutputDriver interface. | ||
func (n *NullOutputDriver) PutCharacter(c uint8) { | ||
// NOTHING HAppens | ||
} | ||
|
||
// SetWriter will update the writer. | ||
func (n *NullOutputDriver) SetWriter(w io.Writer) { | ||
n.writer = w | ||
} | ||
|
||
// init registers our driver, by name. | ||
func init() { | ||
Register("null", func() ConsoleDriver { | ||
return &NullOutputDriver{ | ||
writer: os.Stdout, | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package static | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
// TestStatic just ensures we have some files. | ||
func TestStatic(t *testing.T) { | ||
|
||
// Read the subdirectory | ||
files, err := Content.ReadDir("A") | ||
if err != nil { | ||
t.Fatalf("error reading contents") | ||
} | ||
|
||
// Ensure each file is a .COM files | ||
for _, entry := range files { | ||
name := entry.Name() | ||
if !strings.HasSuffix(name, ".COM") { | ||
t.Fatalf("file '%s' is not a .COM file", name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package version | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
// TestVersion is a nop-test that performs coverage of our version package. | ||
func TestVersion(t *testing.T) { | ||
x := GetVersionString() | ||
y := GetVersionBanner() | ||
|
||
// Banner should have our version | ||
if !strings.Contains(y, x) { | ||
t.Fatalf("banner doesn't contain our version") | ||
} | ||
} |