main: trying out assert and validations

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2025-02-10 17:28:15 -05:00
parent 01101c84a0
commit 98ec9e2a9c
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED

View file

@ -19,6 +19,7 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include "./common.h"
#include "./account.h"
@ -26,6 +27,11 @@
Account* do_account() {
Account* account = new Account(0.0);
assert(account);
if (nullptr == account) {
log_err("failed to allocate account");
return nullptr;
}
account->deposit(100.5); // Add some money
account->deposit(50.25); // Add more money
@ -36,10 +42,15 @@ Account* do_account() {
void scoped_account() {
log_out("HERE");
auto account = do_account();
if (nullptr == account) {
log_err("failed to allocate account");
return;
}
log_out("HERE");
account->withdraw(100);
log_out("Current Balance: " << account->getBalance());
log_err("dang");
delete account;
}