feisty meow concerns codebase  2.140
test_packing.cpp File Reference
Include dependency graph for test_packing.cpp:

Go to the source code of this file.

Macros

#define GENERATE_TEST_NAME(group, message)    (astring(group) + " test group: " + message)
 
#define TRY_ON(type, value, group)
 
#define TRY_ON_OBSCURE(type, value, group)
 
#define TRY_ON_F(type, value, group)
 
#define TEST   "first"
 
#define TEST   "second"
 
#define TEST   "third"
 
#define TEST   "fourth"
 

Functions

 HOOPLE_MAIN (test_object_packing,)
 

Macro Definition Documentation

◆ GENERATE_TEST_NAME

#define GENERATE_TEST_NAME (   group,
  message 
)     (astring(group) + " test group: " + message)

Definition at line 33 of file test_packing.cpp.

◆ TEST [1/4]

#define TEST   "first"

◆ TEST [2/4]

#define TEST   "second"

◆ TEST [3/4]

#define TEST   "third"

◆ TEST [4/4]

#define TEST   "fourth"

◆ TRY_ON

#define TRY_ON (   type,
  value,
  group 
)
Value:
{ \
byte_array temp_array; \
attach(temp_array, type(value)); \
type output; \
/*log(astring(astring::SPRINTF, "parms are: type=%s value=%s group=%s", #type, #value, #group));*/ \
ASSERT_TRUE(detach(temp_array, output), \
GENERATE_TEST_NAME(group, "should unpack " #type " okay")); \
ASSERT_TRUE(output == type(value), \
GENERATE_TEST_NAME(group, #type " value should match")); \
ASSERT_FALSE(temp_array.length(), \
GENERATE_TEST_NAME(group, #type " detached should be empty")); \
}
bool detach(byte_array &packed_form, astring &to_detach)
Unpacks a character string "to_attach" from "packed_form".
Definition: astring.cpp:1023
#define GENERATE_TEST_NAME(group, message)

Definition at line 36 of file test_packing.cpp.

◆ TRY_ON_F

#define TRY_ON_F (   type,
  value,
  group 
)
Value:
{ \
byte_array temp_array; \
attach(temp_array, type(value)); \
type output; \
/*log(astring(astring::SPRINTF, "parms are: type=%s value=%s group=%s", #type, #value, #group));*/ \
ASSERT_TRUE(detach(temp_array, output), \
GENERATE_TEST_NAME(group, "should unpack " #type " fine")); \
/* double_plus<type> a(output); \
double_plus<type> b(value); */ \
/*double diff = maximum(output, value) - minimum(output, value);*/ \
int exponent_1, exponent_2; \
double mantissa_1 = frexp(output, &exponent_1); \
double mantissa_2 = frexp(output, &exponent_2); \
ASSERT_FALSE( (mantissa_1 != mantissa_2) || (exponent_1 != exponent_2), \
GENERATE_TEST_NAME(group, #type " value should match just so")); \
ASSERT_FALSE(temp_array.length(), \
GENERATE_TEST_NAME(group, #type " detached should have no data left")); \
}

Definition at line 62 of file test_packing.cpp.

◆ TRY_ON_OBSCURE

#define TRY_ON_OBSCURE (   type,
  value,
  group 
)
Value:
{ \
byte_array temp_array; \
obscure_attach(temp_array, type(value)); \
type output; \
/*log(astring(astring::SPRINTF, "parms are: type=%s value=%s group=%s", #type, #value, #group));*/ \
ASSERT_TRUE(obscure_detach(temp_array, output), \
GENERATE_TEST_NAME(group, "should obscure unpack " #type " okay")); \
ASSERT_TRUE(output == type(value), \
GENERATE_TEST_NAME(group, #type " value should obscure match")); \
ASSERT_FALSE(temp_array.length(), \
GENERATE_TEST_NAME(group, #type " obscure detached should be empty")); \
}
bool obscure_detach(byte_array &packed_form, un_int &to_detach)
shifts the number back and checks validity, false returned if corrupted.

Definition at line 49 of file test_packing.cpp.

Function Documentation

◆ HOOPLE_MAIN()

HOOPLE_MAIN ( test_object_packing  )