Please send questions to
st10@humboldt.edu .
/*--------------------------------------------------
modified by smtuttle on 11-15-2010
--------------------------------------------------*/
#include <iostream>
#include <cmath>
#include "boa.h"
using namespace std;
/*--------------------------------------------------
Signature: boa_test : void -> bool
Purpose: expects nothing, and produces whether boa's
selectors return what is expected for example
boas, whether its modifiers have the expected
effect, and whether its other functions produce
what they should
Examples: boa_test( ) == true
--------------------------------------------------*/
bool boa_test( )
{
// first: exercise each constructor by creating a local
// (usually static) instance of your new class
// this is a local boa object -- a local instance of the
// boa class -- whose scope, or meaning, is JUST the
// function body it is declared in
boa george("fuschia", 50, "crocodiles");
// test all constructors!
// C++ SYNTAX EXCEPTION: when you declare a
// variable using a zero-argument constructor,
// you DON'T put parentheses after the variable
// name!! (so it won't look like a function
// header to the C++ compiler...)
boa carol;
// these are to keep track of my test results
bool selector_results;
bool modif_results;
bool other_results;
selector_results =
(george.get_color() == "fuschia") and
(george.get_length() == 50) and
(george.get_food() == "crocodiles") and
(carol.get_color() == "green") and
(carol.get_length() == 6) and
(carol.get_food() == "alligators");
// exercise the modifier methods
george.set_color("purple");
george.set_length(75);
george.set_food("dragons");
modif_results =
(george.get_color() == "purple") and
(george.get_length() == 75) and
(george.get_food() == "dragons");
other_results = (carol.longer_than(george) == false) and
(george.longer_than(carol) == true) and
(george.longer_than(george) == false) and
(carol.longer_than(7) == false) and
(carol.longer_than(6) == false) and
(carol.longer_than(5) == true);
return (selector_results and modif_results and other_results);
}