O O Ø O O O O
RPN Unit Test
RPN Unit Test (rut) started as a little hack to test some number-theoretic code I was working on. I needed an easy test framework for some vanilla C functions, and so a stack-based language seemed the easiest choice. I wanted the ability to quickly define regression tests for a function, so I added some syntactic sugar for that. I needed memory leak checking, so I wrote it. Eventually, I integrated my multiprecise integer code as a base type, and started using the framework to test other code I was working on.
For example, a regression test might look like this:
[5 1 3 modexp] 1 5
This example invokes the function modexp(5, 1, 3), expecting the return values (1, 5) in return. All the magic of converting the parameters to bignums, and parsing the return values is handled via generic wrapper functions.
Currently, rut features:
- Strings, multiprecision integers, and binary blobs as basic data types
- Overloadable operators (functions)
- Automatic conversion of data types (where possible)
- Debugging malloc library, capable of enumerating allocations (chasing leaks), and locking memory records (trapping reallocs/frees)
- Regression test framework, with automatic leak detection
- Easy integration with gcov (coverage testing)
To Do
- Fromstr needs to return a void pointer. The value part should be moved to the value functions
- The dup wrappers should really be copies, since it's easy to fake the former from the latter..
Wish List
These are a little further away than the to-do.
- Infix notation
- Wrapper functions need to be generic and automatic (see the mess in int-types.c for why). Maybe I'll integrate with something like SWIG for this part.
Download
You can download the latest version here:
- rut-1.4.tgz (20080205)
Compiling
I hate autoconf, but until I replace it:
$ ./autogunk && ./configure && make
The build is targeted for OpenBSD. Compatability goo (things that you don't have, but OpenBSD does) is in openbsd-compat.
Good Luck
Documentation
Have a look in docs/. Some of it is even up to date.
Other Arbitrary Precision Math Packages
- Imath
- (Download)(local copy)
- Gnu MP (GMP)
- OpenSSL
- MIRACL
- LibTomMath
- BigDigits
- (download) Another basic MP library with free-ish (and hence, largely useless) license