X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=test%2Ftxn_test.c;fp=test%2Ftxn_test.c;h=e20027e4ac102536404ab9f9862f3a64449de1a1;hp=0000000000000000000000000000000000000000;hb=fa60fb1fb78136edc9e5863c0b86222f572963ef;hpb=df360b20f11476e53534a53c9ce11493d7c7a764 diff --git a/test/txn_test.c b/test/txn_test.c new file mode 100644 index 0000000..e20027e --- /dev/null +++ b/test/txn_test.c @@ -0,0 +1,31 @@ +#include +#include "CuTest.h" + +#include "common.h" +#include "runtime.h" +#include "txn.h" + +#define ASSERT_EQUAL(x, y) CuAssertIntEquals(tc, x, y) + +void test1 (CuTest* tc) { + txn_t *tm = txn_begin(TXN_READ_WRITE, TXN_REPEATABLE_READ, MAP_TYPE_LIST); + tm_set(tm, "abc", 4, 2); + tm_set(tm, "abc", 4, 3); + ASSERT_EQUAL( 3, tm_get(tm, "abc", 4) ); + ASSERT_EQUAL( TXN_VALIDATED, txn_commit(tm)); +} + +int main (void) { + + nbd_init(); + + CuString *output = CuStringNew(); + CuSuite* suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test1); + CuSuiteRun(suite); + CuSuiteDetails(suite, output); + printf("%s\n", output->buffer); + + return 0; +} +