test/unit-hashtable.cc
// Test suite for basic transactional put functionality
Test suite for basic transactional put functionality
Test suite for basic transactional put functionality
void testBasicTransPut() {
    typedef Hashtable<Hashtable_params<int, int>> ht_type;
    ht_type ht;
    {
        TestTransaction t(1);
        int value = 42;
        auto result = ht.transPut(1, &value);
        assert(!result.abort);
        assert(!result.existed);
        assert(t.try_commit());
        int* vp = ht.nontrans_get(1);
        assert(vp);
        assert(*vp == 42);
    }
    {
        TestTransaction t1(1);
        int value1 = 9001;
        auto result1 = ht.transPut(1, &value1, true);
        assert(!result1.abort);
        assert(result1.existed);
        TestTransaction t2(2);
        int value2 = 9002;
        auto result2 = ht.transPut(1, &value2, true);
        assert(!result2.abort);
        assert(result2.existed);
        assert(t2.try_commit());
        assert(t1.try_commit());
        int* vp = ht.nontrans_get(1);
        assert(vp);
        assert(*vp == 9001);
    }
    printf("PASS: %s\n", __FUNCTION__);
}
void testBasicTransPut ( ) { typedef Hashtable < Hashtable_params < int , int > > ht_type ; ht_type ht ; { TestTransaction t ( 1 ) ; int value = 42 ; auto result = ht . transPut ( 1 , & value ) ; assert ( ! result . abort ) ; assert ( ! result . existed ) ; assert ( t . try_commit ( ) ) ; int * vp = ht . nontrans_get ( 1 ) ; assert ( vp ) ; assert ( * vp == 42 ) ; } { TestTransaction t1 ( 1 ) ; int value1 = 9001 ; auto result1 = ht . transPut ( 1 , & value1 , true ) ; assert ( ! result1 . abort ) ; assert ( result1 . existed ) ; TestTransaction t2 ( 2 ) ; int value2 = 9002 ; auto result2 = ht . transPut ( 1 , & value2 , true ) ; assert ( ! result2 . abort ) ; assert ( result2 . existed ) ; assert ( t2 . try_commit ( ) ) ; assert ( t1 . try_commit ( ) ) ; int * vp = ht . nontrans_get ( 1 ) ; assert ( vp ) ; assert ( * vp == 9001 ) ; } printf ( " \n " , __FUNCTION__ ) ; }
Test suite for basic transactional put functionality
Test suite for basic transactional put functionality
// Test transactional put // Blind writes should both succeed