39 lines
756 B
C
39 lines
756 B
C
#include <stdio.h>
|
|
#include <inttypes.h>
|
|
|
|
#include "meri_object.h"
|
|
#include "meri_bigint.h"
|
|
|
|
#include "tests.h"
|
|
|
|
static void print_bigint(struct meri_bigint const *bigint) {
|
|
printf("limbs %u:", bigint->nlimbs);
|
|
for (unsigned int i = 0; i < bigint->nlimbs; i++) {
|
|
printf(" [%d] %08" PRIx32, i, bigint->limbs[i]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
void print_obj(struct meri_object const *obj) {
|
|
printf("%p refcount %u type ", (void *)obj, obj->refcount);
|
|
switch (obj->type) {
|
|
case MERI_BIGINT:
|
|
printf("bigint ");
|
|
print_bigint((struct meri_bigint const*)obj);
|
|
break;
|
|
default:
|
|
printf("unknown(%d)\n", obj->type);
|
|
}
|
|
}
|
|
|
|
#define TEST(x) {\
|
|
printf("%s: ", #x);\
|
|
fflush(stdout);\
|
|
test_##x();\
|
|
printf("\n");\
|
|
}
|
|
|
|
int main(void) {
|
|
TEST(bigint);
|
|
return 0;
|
|
}
|