From b34c4517864b0aa79084497a7cae4511ccbdcd55 Mon Sep 17 00:00:00 2001 From: Fredrik Noring <noring@nocrew.org> Date: Sun, 24 May 1998 23:19:20 +0200 Subject: [PATCH] Added testsuite for Yabu. Rev: lib/modules/Yabu.pmod/test.pike:1.1 --- lib/modules/Yabu.pmod/test.pike | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lib/modules/Yabu.pmod/test.pike diff --git a/lib/modules/Yabu.pmod/test.pike b/lib/modules/Yabu.pmod/test.pike new file mode 100644 index 0000000000..759dee47a5 --- /dev/null +++ b/lib/modules/Yabu.pmod/test.pike @@ -0,0 +1,66 @@ +// Yabu test program + +#define ERR(msg) throw(({ msg+"\n", backtrace() })); + +void main(int argc, array argv) +{ + .module.db("test.db", "wct")->purge(); + object db = .module.db("test.db", "wct"); + object table = db["Aces"]; + + // Test transactions + table["Blixt"] = "Gordon"; + object transaction = table->transaction(); + + if(!equal(indices(table), ({ "Blixt" }))) + ERR("Table diff #1!"); + if(!equal(indices(transaction), ({ "Blixt" }))) + ERR("Table diff #2!"); + + transaction["Buck"] = "Rogers"; + + if(!equal(indices(table), ({ "Blixt" }))) + ERR("Table diff #3!"); + if(!equal(sort(indices(transaction)), ({ "Blixt", "Buck" }))) + ERR("Table diff #4!"); + if(table["Buck"] != 0) + ERR("Table diff #5!"); + if(transaction["Buck"] != "Rogers") + ERR("Table diff #6!"); + if(table["Blixt"] != "Gordon") + ERR("Table diff #7!"); + if(transaction["Blixt"] != "Gordon") + ERR("Table diff #8!"); + + transaction->commit(); + + if(table["Buck"] != "Rogers") + ERR("Table diff #9!"); + + mapping m = ([]); + for(int i = 0; i < 10; i++) { + string s = (string)(i%3); + m[s] = m[s] || ([]); + object t = db[s]; + for(int j = 0; j < 100; j++) { + string q = (string)(j%43); + m[s][q] += 1; + t[q] = t[q]+1; + } + t->sync(); + } + + for(int i = 0; i < 10; i++) { + string s = (string)(i%3); + object t = db[s]; + for(int j = 0; j < 100; j++) { + string q = (string)(j%43); + if(t[q] != m[s][q]) + ERR("Table diff #10!"); + } + } + + db->purge(); + + write("Yabu test program says A OK.\n"); +} -- GitLab