wallet: add example

This commit is contained in:
vinchent 2024-09-11 11:49:10 +02:00
parent 82ea599aaa
commit 4a497b9f93

View File

@ -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) {