mnyfmt.c: Format money or currency amounts
Classes | Macros | Typedefs | Functions
mnyfmtts.c File Reference

Test program for mnyfmt(). More...

#include "mnyfmt.h"
#include "uUnit.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <limits.h>

Go to the source code of this file.

Classes

struct  FMTSTR
 Used by 'mnyfmt_wrap()' to check for memory overwrites. More...
 

Macros

#define mnyfmt   mnyfmt_wrap
 [Dirty] Trick to force all test cases to use 'mnyfmt_wrap() instead of mnyfmt()' More...
 
#define show(x)   do { printf("%s->[%s]\n", #x, x ); } while(0)
 Trick macro to see the value in a string. More...
 
#define sh   show(fmtstr);
 Abreviation to invoke show(fmtstr) More...
 
#define SCALE(f, CE)   ( (mnyfmt_long) ( (f) * 1.0e##CE ) )
 
#define SCALE(f, CE)   ( (mnyfmt_long) ( (f) * 1.0e##CE ) )
 
#define DIM   256
 
#define round   adh_round
 

Typedefs

typedef char mnyfmtts_REQUIRES_mnyfmt_format_char_EQUAL_TO_digit_9[(mnyfmt_format_char=='9'?1:-1)]
 Ensure that, at least for this test program [mnyfmtts.c], the formatting char is digit '9'. More...
 

Functions

int eqstr (const char *s1, const char *s2)
 s1 == s2 ??? More...
 
char * mnyfmt_wrap (char *format, char dec, mnyfmt_long intpart, unsigned CE)
 Wrapper around 'mnyfmt()' to check that it does not overwrite adyacent memory. More...
 
int mnyfmtts (const int argc, const char *argv[])
 test ==> mnyfmt() More...
 
void test_str2mnyCE ()
 
double adh_round (double val)
 Round to integer, rounding halfway cases away from zero. More...
 
int main (const int argc, const char *argv[])
 Main test program. More...
 

Detailed Description

Test program for mnyfmt().

Author
Adolfo Di Mare adolf.nosp@m.o@di.nosp@m.-mare.nosp@m..com
Date
2011

Definition in file mnyfmtts.c.

Macro Definition Documentation

#define mnyfmt   mnyfmt_wrap

[Dirty] Trick to force all test cases to use 'mnyfmt_wrap() instead of mnyfmt()'

Definition at line 142 of file mnyfmtts.c.

#define show (   x)    do { printf("%s->[%s]\n", #x, x ); } while(0)

Trick macro to see the value in a string.

Definition at line 145 of file mnyfmtts.c.

#define sh   show(fmtstr);

Abreviation to invoke show(fmtstr)

Definition at line 147 of file mnyfmtts.c.

#define SCALE (   f,
  CE 
)    ( (mnyfmt_long) ( (f) * 1.0e##CE ) )
#define SCALE (   f,
  CE 
)    ( (mnyfmt_long) ( (f) * 1.0e##CE ) )
#define DIM   256
#define round   adh_round

Typedef Documentation

typedef char mnyfmtts_REQUIRES_mnyfmt_format_char_EQUAL_TO_digit_9[(mnyfmt_format_char=='9'?1:-1)]

Ensure that, at least for this test program [mnyfmtts.c], the formatting char is digit '9'.

Definition at line 59 of file mnyfmtts.c.

Function Documentation

int eqstr ( const char *  s1,
const char *  s2 
)

s1 == s2 ???

Definition at line 62 of file mnyfmtts.c.

char* mnyfmt_wrap ( char *  format,
char  dec,
mnyfmt_long  intpart,
unsigned  CE 
)

Wrapper around 'mnyfmt()' to check that it does not overwrite adyacent memory.

Definition at line 80 of file mnyfmtts.c.

int mnyfmtts ( const int  argc,
const char *  argv[] 
)

test ==> mnyfmt()

Number of letters in array.

[Dirty] Trick to force round() to be adh_round()

Definition at line 150 of file mnyfmtts.c.

void test_str2mnyCE ( )

Definition at line 891 of file mnyfmtts.c.

double adh_round ( double  val)

Round to integer, rounding halfway cases away from zero.

Definition at line 961 of file mnyfmtts.c.

int main ( const int  argc,
const char *  argv[] 
)

Main test program.

Definition at line 967 of file mnyfmtts.c.