-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osversion: implement stringer interface, deprecate ToString() (#1547)
This allows the type to be used with fm.Sprintf() and similar uses. Signed-off-by: Sebastiaan van Stijn <[email protected]>
- Loading branch information
Showing
2 changed files
with
30 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package osversion | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestOSVersionString(t *testing.T) { | ||
v := OSVersion{ | ||
Version: 809042555, | ||
MajorVersion: 123, | ||
MinorVersion: 2, | ||
Build: 12345, | ||
} | ||
expected := "the version is: 123.2.12345" | ||
actual := fmt.Sprintf("the version is: %s", v) | ||
if actual != expected { | ||
t.Errorf("expected: %q, got: %q", expected, actual) | ||
} | ||
} |