-
-
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
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.
- Loading branch information
Showing
5 changed files
with
168 additions
and
35 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