31 using namespace basis;
40 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger::get(), to_print)
52 virtual int execute();
59 struct test_struct {
basis::un_int store;
int posn;
int size; };
61 int test_bit_vector::execute()
75 int found = foop.find_first(
true);
80 ASSERT_EQUAL(0, foop.find_first(0),
"locating location of first zero");
81 ASSERT_EQUAL(common::NOT_FOUND, foop.find_first(1),
"showing there are no one bits");
82 for (
int i = 0; i < 12; i++) foop.light(i);
83 ASSERT_EQUAL(12, foop.find_first(0),
"finding first on partially set vector");
89 for (
int j = 0; j < 40; j++) {
94 ASSERT_EQUAL(foop, foop2,
"after lighting, vectors should be identical");
98 if (foop.bits() < 90) foop.
resize(90);
101 test_struct t1 = { 27, 15, 5 };
103 test_struct t2 = { 8, 25, 4 };
105 test_struct t3 = { 1485, 34, 16 };
107 test_struct t4 = { 872465, 50, 32 };
110 for (
int i = 0; i < tests.
length(); i++) {
111 ASSERT_TRUE(foop.set(tests[i].posn, tests[i].size, tests[i].store),
112 "storing int in vector should work");
119 if (to_check != tests[i].store)
120 LOG(
a_sprintf(
"int found at %d in vector (%u) is different than what was stored (%u).",
121 i, to_check, tests[i].store));
122 ASSERT_EQUAL((
int)to_check, (
int)tests[i].store,
"should see expected int stored in vector");
128 int number_of_loops =
randomizer.inclusive(50, 150);
129 for (
int i = 0; i < number_of_loops; i++) {
131 switch (which_to_do) {
134 int new_size =
randomizer.inclusive(0, 32000);
140 int new_size =
randomizer.inclusive(0, 32000);
141 foop.
reset(new_size);
146 int sets_to_do =
randomizer.inclusive(40, 280);
147 for (
int i = 0; i < sets_to_do; i++) {
150 else foop.clear(
rando);
161 return final_report();
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
Represents a sequential, ordered, contiguous collection of objects.
void reset(int number=0, const contents *initial_contents=NULL_POINTER)
Resizes this array and sets the contents from an array of contents.
const contents & get(int index) const
Accesses individual objects stored in "this" at the "index" position.
outcome resize(int new_size, how_to_copy way=NEW_AT_END)
Changes the size of the C array to "new_size".
int length() const
Returns the current reported length of the allocated C array.
A very common template for a dynamic array of bytes.
a platform-independent way to acquire random numbers in a specific range.
An array of bits with operations for manipulating and querying individual bits.
#define SETUP_COMBO_LOGGER
a macro that retasks the program-wide logger as a combo_logger.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
unsigned int un_int
Abbreviated name for unsigned integers.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
HOOPLE_MAIN(test_bit_vector,)
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)
#define ASSERT_FALSE(a, test_name)