wallet: add example
This commit is contained in:
parent
82ea599aaa
commit
4a497b9f93
@ -1,6 +1,25 @@
|
|||||||
package wallet
|
package wallet
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleWallet() {
|
||||||
|
wallet := Wallet{10}
|
||||||
|
|
||||||
|
wallet.Deposit(10)
|
||||||
|
fmt.Printf("The balance is %s\n", wallet.Balance())
|
||||||
|
|
||||||
|
err := wallet.Withdraw(10)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("The balance is %s\n", wallet.Balance())
|
||||||
|
|
||||||
|
// Output: The balance is 20 BTC
|
||||||
|
// The balance is 10 BTC
|
||||||
|
}
|
||||||
|
|
||||||
func TestWallet(t *testing.T) {
|
func TestWallet(t *testing.T) {
|
||||||
t.Run("deposit", func(t *testing.T) {
|
t.Run("deposit", func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user