chore: initialize containerized Go learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
84be3e5d77
64 files changed
+1382
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package pointers
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBankAccount(t *testing.T) {
|
||||
acc := NewBankAccount(100)
|
||||
acc.Deposit(50)
|
||||
if acc.Balance() != 150 {
|
||||
t.Fatalf("got %d, want 150", acc.Balance())
|
||||
}
|
||||
if !acc.Withdraw(40) || acc.Balance() != 110 {
|
||||
t.Fatalf("withdraw failed, balance=%d", acc.Balance())
|
||||
}
|
||||
if acc.Withdraw(500) || acc.Balance() != 110 {
|
||||
t.Fatalf("expected overdraft rejection, balance=%d", acc.Balance())
|
||||
}
|
||||
}
|
||||
|
||||
func TestIncrementAll(t *testing.T) {
|
||||
nums := []int{1, 2, 3}
|
||||
IncrementAll(nums, 10)
|
||||
if !reflect.DeepEqual(nums, []int{11, 12, 13}) {
|
||||
t.Fatalf("got %v, want [11 12 13]", nums)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user