summaryrefslogtreecommitdiff
path: root/test/packing
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2011-05-26 14:04:46 +1000
committerMichael Cahill <michael.cahill@wiredtiger.com>2011-05-26 14:04:46 +1000
commit93ab4058e71717009b71c02bc849f60e2b1f29df (patch)
tree95c0fab5981adf1df1db21597e1b6875b671ba24 /test/packing
parent1cf289fb8e05ffa36f7d0d7d7df96cf10286e6b8 (diff)
downloadmongo-93ab4058e71717009b71c02bc849f60e2b1f29df.tar.gz
Implement full packing and unpacking for multi-column keys/values.
--HG-- rename : lang/python/packing.py => lang/python/fpacking.py rename : lang/python/intpack-test.py => lang/python/packing-test.py rename : src/api/pack.c => src/schema/packing.c rename : test/packing/intpack-test.c => test/packing/packing-test.c
Diffstat (limited to 'test/packing')
-rw-r--r--test/packing/packing-test.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/packing/packing-test.c b/test/packing/packing-test.c
new file mode 100644
index 00000000000..ed4390d27f5
--- /dev/null
+++ b/test/packing/packing-test.c
@@ -0,0 +1,40 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <wiredtiger.h>
+#include <stdarg.h>
+
+void check(const char *fmt, ...)
+{
+ char buf[200], *end, *p;
+ va_list ap;
+ size_t len;
+
+ va_start(ap, fmt);
+ len = wiredtiger_struct_sizev(fmt, ap);
+ va_end(ap);
+
+ assert(len < sizeof buf);
+
+ va_start(ap, fmt);
+ assert(wiredtiger_struct_packv(buf, sizeof buf, fmt, ap) == 0);
+ va_end(ap);
+
+ printf("%s ", fmt);
+ for (p = buf, end = p + len; p < end; p++)
+ printf("%02x", *p & 0xff);
+ printf("\n");
+}
+
+int main() {
+ check("iii", 0, 101, -99);
+ check("3i", 0, 101, -99);
+ check("iS", 42, "forty two");
+#if 0
+ /* TODO: need a WT_ITEM */
+ check("u", r"\x42" * 20)
+ check("uu", r"\x42" * 10, r"\x42" * 10)
+#endif
+ return (0);
+}