~ubuntu-branches/ubuntu/trusty/mdds/trusty-proposed

« back to all changes in this revision

Viewing changes to src/multi_type_vector_test_default.cpp

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2013-10-21 21:49:59 UTC
  • mfrom: (4.1.12 experimental)
  • Revision ID: package-import@ubuntu.com-20131021214959-eulcfavx98ntwnuu
Tags: 0.9.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
        assert(db.get<string>(0) == "foo");
157
157
        assert(db.get<string>(9) == "foo");
158
158
    }
 
159
 
 
160
    {
 
161
        // Create with an array of values.
 
162
        vector<double> vals;
 
163
        vals.push_back(1.1);
 
164
        vals.push_back(1.2);
 
165
        vals.push_back(1.3);
 
166
        mtv_type db(vals.size(), vals.begin(), vals.end());
 
167
        assert(db.size() == 3);
 
168
        assert(db.block_size() == 1);
 
169
        assert(db.get<double>(0) == 1.1);
 
170
        assert(db.get<double>(1) == 1.2);
 
171
        assert(db.get<double>(2) == 1.3);
 
172
    }
 
173
 
 
174
    {
 
175
        vector<string> vals;
 
176
        mtv_type db_empty(0, vals.begin(), vals.end());
 
177
        assert(db_empty.size() == 0);
 
178
        assert(db_empty.block_size() == 0);
 
179
 
 
180
        vals.push_back("Andy");
 
181
        vals.push_back("Bruce");
 
182
 
 
183
        mtv_type db(2, vals.begin(), vals.end());
 
184
        assert(db.size() == 2);
 
185
        assert(db.block_size() == 1);
 
186
        assert(db.get<string>(0) == "Andy");
 
187
        assert(db.get<string>(1) == "Bruce");
 
188
    }
 
189
 
 
190
    {
 
191
        vector<int> vals(10, 1);
 
192
        try
 
193
        {
 
194
            mtv_type db(20, vals.begin(), vals.end());
 
195
            assert(!"This construction should have failed due to incorrect initial array size.");
 
196
        }
 
197
        catch (const invalid_arg_error&)
 
198
        {
 
199
            // good.
 
200
        }
 
201
    }
159
202
}
160
203
 
161
204
void mtv_test_basic()
2431
2474
            assert(it == it_end);
2432
2475
        }
2433
2476
    }
 
2477
 
 
2478
    {
 
2479
        // Make sure that decrementing the iterator calculates the position correctly.
 
2480
        mtv_type db(10);
 
2481
        db.set(0, true);
 
2482
        mtv_type::const_iterator it = db.begin();
 
2483
        assert(it->position == 0);
 
2484
        assert(it->size == 1);
 
2485
        ++it;
 
2486
        assert(it->position == 1);
 
2487
        assert(it->size == 9);
 
2488
        --it;
 
2489
        assert(it->position == 0);
 
2490
        assert(it->size == 1);
 
2491
        assert(it == db.begin());
 
2492
    }
2434
2493
}
2435
2494
 
2436
2495
void mtv_test_data_iterators()
2585
2644
    // With only a single block
2586
2645
 
2587
2646
    mtv_type::iterator it = db.begin();
2588
 
    assert(it->__private_data.start_pos == 0);
 
2647
    assert(it->position == 0);
2589
2648
    assert(it->__private_data.block_index == 0);
2590
2649
 
2591
2650
    it = db.end();
2592
2651
    --it;
2593
 
    assert(it->__private_data.start_pos == 0);
 
2652
    assert(it->position == 0);
2594
2653
    assert(it->__private_data.block_index == 0);
2595
2654
 
2596
2655
    // With 3 blocks (sizes of 4, 3, and 2 in this order)
2601
2660
 
2602
2661
    it = db.begin();
2603
2662
    assert(it->size == 4);
2604
 
    assert(it->__private_data.start_pos == 0);
 
2663
    assert(it->position == 0);
2605
2664
    assert(it->__private_data.block_index == 0);
2606
2665
    ++it;
2607
2666
    assert(it->size == 3);
2608
 
    assert(it->__private_data.start_pos == 4);
 
2667
    assert(it->position == 4);
2609
2668
    assert(it->__private_data.block_index == 1);
2610
2669
    ++it;
2611
2670
    assert(it->size == 2);
2612
 
    assert(it->__private_data.start_pos == 7);
 
2671
    assert(it->position == 7);
2613
2672
    assert(it->__private_data.block_index == 2);
2614
2673
 
2615
2674
    ++it;
2618
2677
    // Go in reverse direction.
2619
2678
    --it;
2620
2679
    assert(it->size == 2);
2621
 
    assert(it->__private_data.start_pos == 7);
 
2680
    assert(it->position == 7);
2622
2681
    assert(it->__private_data.block_index == 2);
2623
2682
    --it;
2624
2683
    assert(it->size == 3);
2625
 
    assert(it->__private_data.start_pos == 4);
 
2684
    assert(it->position == 4);
2626
2685
    assert(it->__private_data.block_index == 1);
2627
2686
    --it;
2628
2687
    assert(it->size == 4);
2629
 
    assert(it->__private_data.start_pos == 0);
 
2688
    assert(it->position == 0);
2630
2689
    assert(it->__private_data.block_index == 0);
2631
2690
    assert(it == db.begin());
2632
2691
}
2667
2726
    check = db.end();
2668
2727
    std::advance(check, -2);
2669
2728
    assert(it == check);
2670
 
    assert(it->__private_data.start_pos == 1);
 
2729
    assert(it->position == 1);
2671
2730
    assert(it->__private_data.block_index == 1);
2672
2731
 
2673
2732
    // Set value to the top empty block of size 1 followed by a non-empty block.
2677
2736
    it = db.set(0, 2.2); // same type as that of the following block.
2678
2737
    assert(it == db.begin());
2679
2738
    assert(it->size == 2);
2680
 
    assert(it->__private_data.start_pos == 0);
 
2739
    assert(it->position == 0);
2681
2740
    assert(it->__private_data.block_index == 0);
2682
2741
    db.set_empty(0, 0);
2683
2742
    it = db.set(0, true); // different type from that of the following block.
2684
2743
    assert(it == db.begin());
2685
2744
    assert(it->size == 1);
2686
 
    assert(it->__private_data.start_pos == 0);
 
2745
    assert(it->position == 0);
2687
2746
    assert(it->__private_data.block_index == 0);
2688
2747
 
2689
2748
    // Set value to the top of the top empty block (not size 1) followed by a non-empty block.
2705
2764
    --check;
2706
2765
    assert(it == check);
2707
2766
    assert(it->size == 2);
2708
 
    assert(it->__private_data.start_pos == 1);
 
2767
    assert(it->position == 1);
2709
2768
    assert(it->__private_data.block_index == 1);
2710
2769
    db.set_empty(0, 1);
2711
2770
    it = db.set(1, true); // different type from that of the following block.
2716
2775
    std::advance(check, -2);
2717
2776
    assert(it == check);
2718
2777
    assert(it->size == 1);
2719
 
    assert(it->__private_data.start_pos == 1);
 
2778
    assert(it->position == 1);
2720
2779
    assert(it->__private_data.block_index == 1);
2721
2780
 
2722
2781
    // Set value to the middle of the top empty block (not size 1) followed by a non-empty block.
2728
2787
    ++check;
2729
2788
    assert(it == check);
2730
2789
    assert(it->size == 1);
2731
 
    assert(it->__private_data.start_pos == 3);
 
2790
    assert(it->position == 3);
2732
2791
    assert(it->__private_data.block_index == 1);
2733
2792
 
2734
2793
    // Set value to an empty block of size 1 immediately below a non-empty block.
2806
2865
    ++check;
2807
2866
    assert(it == check);
2808
2867
    assert(it->size == 1);
2809
 
    assert(it->__private_data.start_pos == 1);
 
2868
    assert(it->position == 1);
2810
2869
 
2811
2870
    // Set value to the bottom of an empty block (not of size 1) between
2812
2871
    // non-empty blocks.
2814
2873
    db.set_empty(2, 4);
2815
2874
    it = db.set(4, true); // Same type as that of the following block.
2816
2875
    assert(it->size == 3);
2817
 
    assert(it->__private_data.start_pos == 4);
 
2876
    assert(it->position == 4);
2818
2877
    assert(it->__private_data.block_index == 2);
2819
2878
    ++it;
2820
2879
    assert(it == db.end());
2822
2881
    db.set_empty(2, 4);
2823
2882
    it = db.set(4, 1.1); // Different type from that of the following block.
2824
2883
    assert(it->size == 1);
2825
 
    assert(it->__private_data.start_pos == 4);
 
2884
    assert(it->position == 4);
2826
2885
    assert(it->__private_data.block_index == 2);
2827
2886
    std::advance(it, 2);
2828
2887
    assert(it == db.end());
2905
2964
    it = db.set(6, string("text"));
2906
2965
    assert(it->size == 1);
2907
2966
    assert(it->type == mtv::element_type_string);
2908
 
    assert(it->__private_data.start_pos = 6);
 
2967
    assert(it->position = 6);
2909
2968
    check = db.begin();
2910
2969
    std::advance(check, 2);
2911
2970
    assert(it == check);
2931
2990
    it = db.set(4, 1.1);
2932
2991
    assert(it->size == 1);
2933
2992
    assert(it->type == mtv::element_type_numeric);
2934
 
    assert(it->__private_data.start_pos == 4);
 
2993
    assert(it->position == 4);
2935
2994
    check = db.begin();
2936
2995
    ++check;
2937
2996
    assert(it == check);
2991
3050
    it = db.set(4, string("foo"));
2992
3051
    assert(it->size == 1);
2993
3052
    assert(it->type == mtv::element_type_string);
2994
 
    assert(it->__private_data.start_pos == 4);
 
3053
    assert(it->position == 4);
2995
3054
    assert(it->__private_data.block_index == 2);
2996
3055
    ++it;
2997
3056
    assert(it->size == 5);
3005
3064
    it = db.set(6, string("foo")); // 7 thru 9 is boolean.
3006
3065
    assert(it->size == 1);
3007
3066
    assert(it->type == mtv::element_type_string);
3008
 
    assert(it->__private_data.start_pos == 6);
 
3067
    assert(it->position == 6);
3009
3068
    assert(it->__private_data.block_index == 2);
3010
3069
    ++it;
3011
3070
    assert(it->size == 3);
3012
3071
    assert(it->type == mtv::element_type_boolean);
3013
 
    assert(it->__private_data.start_pos == 7);
 
3072
    assert(it->position == 7);
3014
3073
    ++it;
3015
3074
    assert(it == db.end());
3016
3075
 
3120
3179
    --it;
3121
3180
    assert(it->size == 4);
3122
3181
    assert(it->type == mtv::element_type_numeric);
3123
 
    assert(it->__private_data.start_pos == 2);
 
3182
    assert(it->position == 2);
3124
3183
    --it;
3125
3184
    assert(it->size == 2);
3126
3185
    assert(it->type == mtv::element_type_boolean);
3127
 
    assert(it->__private_data.start_pos == 0);
 
3186
    assert(it->position == 0);
3128
3187
    assert(it == db.begin());
3129
3188
 
3130
3189
    it = db.set(6, 4.5); // Same type as those of the preceding and following blocks.
3131
3190
    assert(it->size == 8);
3132
3191
    assert(it->type == mtv::element_type_numeric);
3133
 
    assert(it->__private_data.start_pos == 2);
 
3192
    assert(it->position == 2);
3134
3193
    assert(it->__private_data.block_index == 1);
3135
3194
    check = db.begin();
3136
3195
    ++check;
3160
3219
    it = db.set(4, static_cast<short>(28)); // Different type from either of the blocks.
3161
3220
    assert(it->size == 1);
3162
3221
    assert(it->type == mtv::element_type_short);
3163
 
    assert(it->__private_data.start_pos == 4);
 
3222
    assert(it->position == 4);
3164
3223
    assert(it->__private_data.block_index == 1);
3165
3224
    std::advance(it, 2);
3166
3225
    assert(it == db.end());
3176
3235
    assert(it == check);
3177
3236
    assert(it->size == 1);
3178
3237
    assert(it->type == mtv::element_type_string);
3179
 
    assert(it->__private_data.start_pos == 6);
 
3238
    assert(it->position == 6);
3180
3239
    ++it;
3181
3240
    assert(it->size == 3);
3182
3241
    assert(it->type == mtv::element_type_numeric);
3183
 
    assert(it->__private_data.start_pos == 7);
 
3242
    assert(it->position == 7);
3184
3243
    ++it;
3185
3244
    assert(it == db.end());
3186
3245
 
3507
3566
    advance(check, 2);
3508
3567
    assert(it == check);
3509
3568
    assert(it->size == 5);
3510
 
    assert(it->__private_data.start_pos == 3);
 
3569
    assert(it->position == 3);
3511
3570
    ++it;
3512
3571
    assert(it->type == mtv::element_type_empty);
3513
3572
    assert(it->size == 6);
3765
3824
    assert(it == check);
3766
3825
    assert(it->size == 9);
3767
3826
    assert(it->type == mtv::element_type_empty);
3768
 
    assert(it->__private_data.start_pos == 1);
 
3827
    assert(it->position == 1);
3769
3828
    assert(it->__private_data.block_index == 1);
3770
3829
    ++it;
3771
3830
    assert(it == db.end());
3779
3838
    assert(it == check);
3780
3839
    assert(it->size == 5);
3781
3840
    assert(it->type == mtv::element_type_empty);
3782
 
    assert(it->__private_data.start_pos == 1);
 
3841
    assert(it->position == 1);
3783
3842
    assert(it->__private_data.block_index == 1);
3784
3843
    ++it;
3785
3844
    assert(it->size == 1);
3804
3863
    assert(it->size == 4);
3805
3864
    assert(it->type == mtv::element_type_empty);
3806
3865
    assert(it->__private_data.block_index == 2);
3807
 
    assert(it->__private_data.start_pos == 5);
 
3866
    assert(it->position == 5);
3808
3867
    advance(it, 2);
3809
3868
    assert(it == db.end());
3810
3869
}
4039
4098
    stack_printer __stack_printer__("::mtv_test_position");
4040
4099
    mtv_type db(10, false);
4041
4100
    mtv_type::iterator check;
 
4101
    mtv_type::const_iterator const_check;
4042
4102
    db.set(6, 1.1);
4043
4103
    db.set(7, 1.2);
4044
4104
    db.set(8, 1.3);
4045
4105
    db.set(9, 1.4);
4046
4106
 
4047
 
    pair<mtv_type::iterator,mtv_type::size_type> pos = db.position(0);
 
4107
    mtv_type::position_type pos = db.position(0);
4048
4108
    assert(pos.first == db.begin());
4049
4109
    assert(pos.second == 0);
4050
4110
 
4085
4145
 
4086
4146
    // Quick check for the const variant.
4087
4147
    const mtv_type& db_ref = db;
4088
 
    pair<mtv_type::const_iterator,mtv_type::size_type> const_pos = db_ref.position(3);
 
4148
    mtv_type::const_position_type const_pos = db_ref.position(3);
4089
4149
    assert(const_pos.first == db_ref.begin());
4090
4150
    assert(const_pos.second == 3);
 
4151
    const_pos = db_ref.position(const_pos.first, 7);
 
4152
    const_check = db_ref.begin();
 
4153
    ++const_check;
 
4154
    assert(const_pos.first == const_check);
 
4155
    assert(const_pos.second == 1);
4091
4156
 
4092
4157
    // Check for the variant that takes position hint.
4093
4158
    pos = db.position(0);
4109
4174
    assert(pos.second == 3);
4110
4175
}
4111
4176
 
4112
 
void mtv_perf_test_block_position_lookup()
4113
 
{
4114
 
    size_t n = 24000;
4115
 
 
4116
 
    {
4117
 
        // Default insertion which always looks up the right element block
4118
 
        // from the position of the first block.  As such, as the block size
4119
 
        // grows, so does the time it takes to search for the right block.
4120
 
 
4121
 
        mtv_type db(n*2);
4122
 
        double val1 = 1.1;
4123
 
        int val2 = 23;
4124
 
        stack_printer __stack_printer__("::mtv_perf_test_block_position_lookup::default insertion");
4125
 
        for (size_t i = 0; i < n; ++i)
4126
 
        {
4127
 
            size_t pos1 = i*2, pos2 = i*2 + 1;
4128
 
            db.set(pos1, val1);
4129
 
            db.set(pos2, val2);
4130
 
        }
4131
 
    }
4132
 
 
4133
 
    {
4134
 
        // As a solution for this, we can use an iterator to specify the start
4135
 
        // position, which eliminates the above scalability problem nicely.
4136
 
 
4137
 
        mtv_type db(n*2);
4138
 
        mtv_type::iterator pos_hint = db.begin();
4139
 
        double val1 = 1.1;
4140
 
        int val2 = 23;
4141
 
        stack_printer __stack_printer__("::mtv_perf_test_block_position_lookup::insertion with position hint");
4142
 
        for (size_t i = 0; i < n; ++i)
4143
 
        {
4144
 
            size_t pos1 = i*2, pos2 = i*2 + 1;
4145
 
            pos_hint = db.set(pos_hint, pos1, val1);
4146
 
            pos_hint = db.set(pos_hint, pos2, val2);
4147
 
        }
4148
 
    }
 
4177
void mtv_test_next_position()
 
4178
{
 
4179
    stack_printer __stack_printer__("::mtv_test_next_position");
 
4180
    mtv_type db(10);
 
4181
    db.set(2, 1.1);
 
4182
    db.set(3, 1.2);
 
4183
    db.set(4, string("A"));
 
4184
    db.set(5, string("B"));
 
4185
    db.set(6, string("C"));
 
4186
 
 
4187
    mtv_type::position_type pos = db.position(0);
 
4188
    assert(mtv_type::logical_position(pos) == 0);
 
4189
    assert(pos.first->type == mtv::element_type_empty);
 
4190
 
 
4191
    pos = mtv_type::next_position(pos);
 
4192
    assert(mtv_type::logical_position(pos) == 1);
 
4193
    assert(pos.first->type == mtv::element_type_empty);
 
4194
 
 
4195
    pos = mtv_type::next_position(pos);
 
4196
    assert(mtv_type::logical_position(pos) == 2);
 
4197
    assert(pos.first->type == mtv::element_type_numeric);
 
4198
    assert(mtv_type::get<mtv::numeric_element_block>(pos) == 1.1);
 
4199
 
 
4200
    pos = mtv_type::next_position(pos);
 
4201
    assert(mtv_type::logical_position(pos) == 3);
 
4202
    assert(pos.first->type == mtv::element_type_numeric);
 
4203
    assert(mtv_type::get<mtv::numeric_element_block>(pos) == 1.2);
 
4204
 
 
4205
    pos = mtv_type::next_position(pos);
 
4206
    assert(mtv_type::logical_position(pos) == 4);
 
4207
    assert(pos.first->type == mtv::element_type_string);
 
4208
    assert(mtv_type::get<mtv::string_element_block>(pos) == "A");
 
4209
 
 
4210
    pos = mtv_type::next_position(pos);
 
4211
    assert(mtv_type::logical_position(pos) == 5);
 
4212
    assert(pos.first->type == mtv::element_type_string);
 
4213
    assert(mtv_type::get<mtv::string_element_block>(pos) == "B");
 
4214
 
 
4215
    pos = mtv_type::next_position(pos);
 
4216
    assert(mtv_type::logical_position(pos) == 6);
 
4217
    assert(pos.first->type == mtv::element_type_string);
 
4218
    assert(mtv_type::get<mtv::string_element_block>(pos) == "C");
 
4219
 
 
4220
    pos = mtv_type::next_position(pos);
 
4221
    assert(mtv_type::logical_position(pos) == 7);
 
4222
    assert(pos.first->type == mtv::element_type_empty);
 
4223
 
 
4224
    pos = mtv_type::next_position(pos);
 
4225
    assert(mtv_type::logical_position(pos) == 8);
 
4226
    assert(pos.first->type == mtv::element_type_empty);
 
4227
 
 
4228
    pos = mtv_type::next_position(pos);
 
4229
    assert(mtv_type::logical_position(pos) == 9);
 
4230
    assert(pos.first->type == mtv::element_type_empty);
 
4231
 
 
4232
    pos = mtv_type::next_position(pos);
 
4233
    assert(pos.first == db.end());
 
4234
}
 
4235
 
 
4236
void mtv_test_swap_range()
 
4237
{
 
4238
    stack_printer __stack_printer__("::mtv_test_swap_range");
 
4239
    mtv_type db1(10), db2(10);
 
4240
    db1.set(2, 1.1);
 
4241
    db1.set(3, 1.2);
 
4242
    db1.set(4, 1.3);
 
4243
 
 
4244
    db2.set(2, 2.1);
 
4245
    db2.set(3, 2.2);
 
4246
    db2.set(4, 2.3);
 
4247
 
 
4248
    db1.swap(2, 4, db2, 2);
 
4249
    assert(db1.get<double>(2) == 2.1);
 
4250
    assert(db1.get<double>(3) == 2.2);
 
4251
    assert(db1.get<double>(4) == 2.3);
 
4252
    assert(db2.get<double>(2) == 1.1);
 
4253
    assert(db2.get<double>(3) == 1.2);
 
4254
    assert(db2.get<double>(4) == 1.3);
 
4255
 
 
4256
    // Source is empty but destination is not.
 
4257
    db1 = mtv_type(3);
 
4258
    db2 = mtv_type(3, 12.3);
 
4259
    db1.swap(1, 2, db2, 1);
 
4260
    assert(db1.is_empty(0));
 
4261
    assert(db1.get<double>(1) == 12.3);
 
4262
    assert(db1.get<double>(2) == 12.3);
 
4263
    assert(db1.block_size() == 2);
 
4264
    assert(db2.get<double>(0) == 12.3);
 
4265
    assert(db2.is_empty(1));
 
4266
    assert(db2.is_empty(2));
 
4267
    assert(db2.block_size() == 2);
 
4268
 
 
4269
    // Go to the opposite direction.
 
4270
    db1.swap(1, 2, db2, 1);
 
4271
    assert(db1.block_size() == 1);
 
4272
    mtv_type::iterator it = db1.begin();
 
4273
    assert(it->type == mtv::element_type_empty);
 
4274
    assert(it->size == 3);
 
4275
    it = db2.begin();
 
4276
    assert(it->type == mtv::element_type_numeric);
 
4277
    assert(it->size == 3);
 
4278
 
 
4279
    int int_val = 2;
 
4280
    short short_val = 5;
 
4281
    db1 = mtv_type(5, int_val);
 
4282
    db2 = mtv_type(5, short_val);
 
4283
    db1.set(1, 2.3);
 
4284
    db1.set(2, 2.4);
 
4285
    db2.set(3, string("abc"));
 
4286
    db2.set(4, string("def"));
 
4287
    db1.swap(1, 2, db2, 3); // Swap 1-2 of source with 3-4 of destination.
 
4288
    assert(db1.get<int>(0) == int_val);
 
4289
    assert(db1.get<string>(1) == "abc");
 
4290
    assert(db1.get<string>(2) == "def");
 
4291
    assert(db1.get<int>(3) == int_val);
 
4292
    assert(db1.get<int>(4) == int_val);
 
4293
    assert(db1.block_size() == 3);
 
4294
 
 
4295
    assert(db2.get<short>(0) == short_val);
 
4296
    assert(db2.get<short>(1) == short_val);
 
4297
    assert(db2.get<short>(2) == short_val);
 
4298
    assert(db2.get<double>(3) == 2.3);
 
4299
    assert(db2.get<double>(4) == 2.4);
 
4300
    assert(db2.block_size() == 2);
 
4301
 
 
4302
    // Merge with the next block in the destination.
 
4303
    db1 = mtv_type(5, int_val);
 
4304
    db2 = mtv_type(5, 12.3);
 
4305
    db2.set(0, string("A"));
 
4306
    db2.set(1, string("B"));
 
4307
    db1.set(3, 1.1);
 
4308
    db1.set(4, 1.2);
 
4309
    db1.swap(3, 4, db2, 0);
 
4310
    assert(db1.get<int>(0) == int_val);
 
4311
    assert(db1.get<int>(1) == int_val);
 
4312
    assert(db1.get<int>(2) == int_val);
 
4313
    assert(db1.get<string>(3) == "A");
 
4314
    assert(db1.get<string>(4) == "B");
 
4315
    assert(db1.block_size() == 2);
 
4316
 
 
4317
    assert(db2.get<double>(0) == 1.1);
 
4318
    assert(db2.get<double>(1) == 1.2);
 
4319
    assert(db2.get<double>(2) == 12.3);
 
4320
    assert(db2.get<double>(3) == 12.3);
 
4321
    assert(db2.get<double>(4) == 12.3);
 
4322
    assert(db2.block_size() == 1);
 
4323
 
 
4324
    // Merge with the previous block in the destination.
 
4325
    db1 = mtv_type(5, int_val);
 
4326
    db1.set(2, string("A"));
 
4327
    db1.set(3, string("B"));
 
4328
 
 
4329
    db2 = mtv_type(5, string("default"));
 
4330
    db2.set(3, short_val);
 
4331
    db2.set(4, short_val);
 
4332
 
 
4333
    db1.swap(2, 3, db2, 3);
 
4334
    assert(db1.get<int>(0) == int_val);
 
4335
    assert(db1.get<int>(1) == int_val);
 
4336
    assert(db1.get<short>(2) == short_val);
 
4337
    assert(db1.get<short>(3) == short_val);
 
4338
    assert(db1.get<int>(4) == int_val);
 
4339
    assert(db1.block_size() == 3);
 
4340
 
 
4341
    assert(db2.get<string>(0) == "default");
 
4342
    assert(db2.get<string>(1) == "default");
 
4343
    assert(db2.get<string>(2) == "default");
 
4344
    assert(db2.get<string>(3) == "A");
 
4345
    assert(db2.get<string>(4) == "B");
 
4346
    assert(db2.block_size() == 1);
 
4347
 
 
4348
    // Merge with both the previous and next blocks in the destination.
 
4349
    db1 = mtv_type(5, int_val);
 
4350
    db1.set(2, string("C"));
 
4351
    db1.set(3, string("D"));
 
4352
 
 
4353
    db2 = mtv_type(6, string("default"));
 
4354
    db2.set(3, short_val);
 
4355
    db2.set(4, short_val);
 
4356
 
 
4357
    db1.swap(2, 3, db2, 3);
 
4358
    assert(db1.get<int>(0) == int_val);
 
4359
    assert(db1.get<int>(1) == int_val);
 
4360
    assert(db1.get<short>(2) == short_val);
 
4361
    assert(db1.get<short>(3) == short_val);
 
4362
    assert(db1.get<int>(4) == int_val);
 
4363
    assert(db1.block_size() == 3);
 
4364
 
 
4365
    assert(db2.get<string>(0) == "default");
 
4366
    assert(db2.get<string>(1) == "default");
 
4367
    assert(db2.get<string>(2) == "default");
 
4368
    assert(db2.get<string>(3) == "C");
 
4369
    assert(db2.get<string>(4) == "D");
 
4370
    assert(db2.get<string>(5) == "default");
 
4371
    assert(db2.block_size() == 1);
 
4372
 
 
4373
    // Set the new elements to the top of a block in the destination.
 
4374
    db1 = mtv_type(5, int_val);
 
4375
    db1.set(3, string("E"));
 
4376
    db1.set(4, string("F"));
 
4377
    db2 = mtv_type(5, short_val);
 
4378
    db1.swap(3, 4, db2, 0);
 
4379
    assert(db1.get<int>(0) == int_val);
 
4380
    assert(db1.get<int>(1) == int_val);
 
4381
    assert(db1.get<int>(2) == int_val);
 
4382
    assert(db1.get<short>(3) == short_val);
 
4383
    assert(db1.get<short>(4) == short_val);
 
4384
    assert(db1.block_size() == 2);
 
4385
    assert(db2.get<string>(0) == "E");
 
4386
    assert(db2.get<string>(1) == "F");
 
4387
    assert(db2.get<short>(2) == short_val);
 
4388
    assert(db2.get<short>(3) == short_val);
 
4389
    assert(db2.get<short>(4) == short_val);
 
4390
    assert(db2.block_size() == 2);
 
4391
 
 
4392
    // Do the same as before, but merge with the previous block.
 
4393
    db1 = mtv_type(5, int_val);
 
4394
    db1.set(3, string("G"));
 
4395
    db1.set(4, string("H"));
 
4396
    db2 = mtv_type(5, short_val);
 
4397
    db2.set(0, string("F"));
 
4398
    db1.swap(3, 4, db2, 1);
 
4399
    assert(db1.get<int>(0) == int_val);
 
4400
    assert(db1.get<int>(1) == int_val);
 
4401
    assert(db1.get<int>(2) == int_val);
 
4402
    assert(db1.get<short>(3) == short_val);
 
4403
    assert(db1.get<short>(4) == short_val);
 
4404
    assert(db1.block_size() == 2);
 
4405
    assert(db2.get<string>(0) == "F");
 
4406
    assert(db2.get<string>(1) == "G");
 
4407
    assert(db2.get<string>(2) == "H");
 
4408
    assert(db2.get<short>(3) == short_val);
 
4409
    assert(db2.get<short>(4) == short_val);
 
4410
    assert(db2.block_size() == 2);
 
4411
 
 
4412
    // Set the new element to the middle of a destination block.
 
4413
    db1 = mtv_type(5, int_val);
 
4414
    db1.set(3, string("I"));
 
4415
    db1.set(4, string("J"));
 
4416
    db2 = mtv_type(5, short_val);
 
4417
    db2.set(0, string("top"));
 
4418
    db1.swap(3, 4, db2, 2);
 
4419
    assert(db1.get<int>(0) == int_val);
 
4420
    assert(db1.get<int>(1) == int_val);
 
4421
    assert(db1.get<int>(2) == int_val);
 
4422
    assert(db1.get<short>(3) == short_val);
 
4423
    assert(db1.get<short>(4) == short_val);
 
4424
    assert(db1.block_size() == 2);
 
4425
 
 
4426
    assert(db2.get<string>(0) == "top");
 
4427
    assert(db2.get<short>(1) == short_val);
 
4428
    assert(db2.get<string>(2) == "I");
 
4429
    assert(db2.get<string>(3) == "J");
 
4430
    assert(db2.get<short>(4) == short_val);
 
4431
    assert(db2.block_size() == 4);
 
4432
 
 
4433
    // Set the new element to the lower part of a destination block.
 
4434
    db1 = mtv_type(5, int_val);
 
4435
    db1.set(0, string("A1"));
 
4436
    db1.set(1, string("A2"));
 
4437
    db2 = mtv_type(5, short_val);
 
4438
    db1.swap(0, 1, db2, 3);
 
4439
 
 
4440
    assert(db1.get<short>(0) == short_val);
 
4441
    assert(db1.get<short>(1) == short_val);
 
4442
    assert(db1.get<int>(2) == int_val);
 
4443
    assert(db1.get<int>(3) == int_val);
 
4444
    assert(db1.get<int>(4) == int_val);
 
4445
    assert(db1.block_size() == 2);
 
4446
 
 
4447
    assert(db2.get<short>(0) == short_val);
 
4448
    assert(db2.get<short>(1) == short_val);
 
4449
    assert(db2.get<short>(2) == short_val);
 
4450
    assert(db2.get<string>(3) == "A1");
 
4451
    assert(db2.get<string>(4) == "A2");
 
4452
    assert(db2.block_size() == 2);
 
4453
 
 
4454
    // Same as above, except that the new element will be merged with the next
 
4455
    // block in the destination.
 
4456
    db1 = mtv_type(5, int_val);
 
4457
    db1.set(0, string("A1"));
 
4458
    db1.set(1, string("A2"));
 
4459
    db2 = mtv_type(6, short_val);
 
4460
    db2.set(5, string("A3"));
 
4461
    db1.swap(0, 1, db2, 3);
 
4462
 
 
4463
    assert(db1.get<short>(0) == short_val);
 
4464
    assert(db1.get<short>(1) == short_val);
 
4465
    assert(db1.get<int>(2) == int_val);
 
4466
    assert(db1.get<int>(3) == int_val);
 
4467
    assert(db1.get<int>(4) == int_val);
 
4468
    assert(db1.block_size() == 2);
 
4469
 
 
4470
    assert(db2.get<short>(0) == short_val);
 
4471
    assert(db2.get<short>(1) == short_val);
 
4472
    assert(db2.get<short>(2) == short_val);
 
4473
    assert(db2.get<string>(3) == "A1");
 
4474
    assert(db2.get<string>(4) == "A2");
 
4475
    assert(db2.get<string>(5) == "A3");
 
4476
    assert(db2.block_size() == 2);
 
4477
 
 
4478
    // Swap the top part of source block.
 
4479
    db1 = mtv_type(5, int_val);
 
4480
    db2 = mtv_type(5, short_val);
 
4481
    db1.swap(0, 1, db2, 0);
 
4482
 
 
4483
    assert(db1.get<short>(0) == short_val);
 
4484
    assert(db1.get<short>(1) == short_val);
 
4485
    assert(db1.get<int>(2) == int_val);
 
4486
    assert(db1.get<int>(3) == int_val);
 
4487
    assert(db1.get<int>(4) == int_val);
 
4488
 
 
4489
    assert(db2.get<int>(0) == int_val);
 
4490
    assert(db2.get<int>(1) == int_val);
 
4491
    assert(db2.get<short>(2) == short_val);
 
4492
    assert(db2.get<short>(3) == short_val);
 
4493
    assert(db2.get<short>(4) == short_val);
 
4494
 
 
4495
    // Do the same, and merge with the previous block in the source.
 
4496
    db1 = mtv_type(5, int_val);
 
4497
    db1.set(0, string("A"));
 
4498
    db2 = mtv_type(5, short_val);
 
4499
    db2.set(0, string("B"));
 
4500
    db2.set(1, string("C"));
 
4501
    db1.swap(1, 2, db2, 0);
 
4502
 
 
4503
    assert(db1.get<string>(0) == "A");
 
4504
    assert(db1.get<string>(1) == "B");
 
4505
    assert(db1.get<string>(2) == "C");
 
4506
    assert(db1.get<int>(3) == int_val);
 
4507
    assert(db1.get<int>(4) == int_val);
 
4508
    assert(db1.block_size() == 2);
 
4509
 
 
4510
    assert(db2.get<int>(0) == int_val);
 
4511
    assert(db2.get<int>(1) == int_val);
 
4512
    assert(db2.get<short>(2) == short_val);
 
4513
    assert(db2.get<short>(3) == short_val);
 
4514
    assert(db2.get<short>(4) == short_val);
 
4515
    assert(db2.block_size() == 2);
 
4516
 
 
4517
    // Replace the bottom part of existing source block.
 
4518
    db1 = mtv_type(2, true);
 
4519
    db2 = mtv_type(1, int_val);
 
4520
    db1.swap(1, 1, db2, 0);
 
4521
    assert(db1.get<bool>(0) == true);
 
4522
    assert(db1.get<int>(1) == int_val);
 
4523
    assert(db2.get<bool>(0) == true);
 
4524
 
 
4525
    // Do the same, but merge with the next block in the source.
 
4526
    db1 = mtv_type(3, true);
 
4527
    db1.set<int>(2, int_val+1);
 
4528
    db2 = mtv_type(1, int_val);
 
4529
    db1.swap(1, 1, db2, 0);
 
4530
    assert(db1.get<bool>(0) == true);
 
4531
    assert(db1.get<int>(1) == int_val);
 
4532
    assert(db1.get<int>(2) == int_val+1);
 
4533
    assert(db2.get<bool>(0) == true);
 
4534
 
 
4535
    // Replace the middle of existing source block.
 
4536
    db1 = mtv_type(5);
 
4537
    db1.set<char>(0, 'a');
 
4538
    db1.set<char>(1, 'b');
 
4539
    db1.set<char>(2, 'c');
 
4540
    db1.set<char>(3, 'd');
 
4541
    db1.set<char>(4, 'e');
 
4542
    db2 = mtv_type(2);
 
4543
    db2.set(0, 1.1);
 
4544
    db2.set(1, -1.1);
 
4545
    db1.swap(2, 3, db2, 0);
 
4546
    assert(db1.get<char>(0) == 'a');
 
4547
    assert(db1.get<char>(1) == 'b');
 
4548
    assert(db1.get<double>(2) == 1.1);
 
4549
    assert(db1.get<double>(3) == -1.1);
 
4550
    assert(db1.get<char>(4) == 'e');
 
4551
    assert(db1.block_size() == 3);
 
4552
 
 
4553
    assert(db2.get<char>(0) == 'c');
 
4554
    assert(db2.get<char>(1) == 'd');
 
4555
    assert(db2.block_size() == 1);
 
4556
 
 
4557
    // Swap single empty block with multiple destination blocks.
 
4558
    db1 = mtv_type(5);
 
4559
    db2 = mtv_type(5);
 
4560
    db2.set(0, 1.1);
 
4561
    db2.set(1, 2.1);
 
4562
    db2.set(2, 3.1);
 
4563
    db2.set(3, string("abc"));
 
4564
    db2.set(4, string("def"));
 
4565
    db1.swap(0, 3, db2, 1);
 
4566
    assert(db1.get<double>(0) == 2.1);
 
4567
    assert(db1.get<double>(1) == 3.1);
 
4568
    assert(db1.get<string>(2) == "abc");
 
4569
    assert(db1.get<string>(3) == "def");
 
4570
    assert(db1.is_empty(4));
 
4571
    assert(db1.block_size() == 3);
 
4572
    assert(db2.get<double>(0) == 1.1);
 
4573
    assert(db2.is_empty(1));
 
4574
    assert(db2.is_empty(2));
 
4575
    assert(db2.is_empty(3));
 
4576
    assert(db2.is_empty(4));
 
4577
    assert(db2.block_size() == 2);
 
4578
 
 
4579
    // Swap non-empty single block with multiple destination blocks.
 
4580
    db1 = mtv_type(4, int_val);
 
4581
    db2 = mtv_type(5);
 
4582
    db2.set(0, 1.1);
 
4583
    db2.set(1, 2.1);
 
4584
    db2.set(2, 3.1);
 
4585
    db2.set(3, string("abc"));
 
4586
    db2.set(4, string("def"));
 
4587
    db1.swap(0, 3, db2, 1);
 
4588
    assert(db1.get<double>(0) == 2.1);
 
4589
    assert(db1.get<double>(1) == 3.1);
 
4590
    assert(db1.get<string>(2) == "abc");
 
4591
    assert(db1.get<string>(3) == "def");
 
4592
    assert(db1.block_size() == 2);
 
4593
    assert(db2.get<double>(0) == 1.1);
 
4594
    assert(db2.get<int>(1) == int_val);
 
4595
    assert(db2.get<int>(2) == int_val);
 
4596
    assert(db2.get<int>(3) == int_val);
 
4597
    assert(db2.get<int>(4) == int_val);
 
4598
    assert(db2.block_size() == 2);
 
4599
 
 
4600
    // Another scenario.
 
4601
    db1 = mtv_type(2, short_val);
 
4602
    db2 = mtv_type(2);
 
4603
    db2.set(0, string("A"));
 
4604
    db2.set<char>(1, 'A');
 
4605
    db1.swap(0, 1, db2, 0);
 
4606
    assert(db1.get<string>(0) == "A");
 
4607
    assert(db1.get<char>(1) == 'A');
 
4608
    assert(db2.get<short>(0) == short_val);
 
4609
    assert(db2.get<short>(1) == short_val);
 
4610
 
 
4611
    // Another scenario.
 
4612
    db1 = mtv_type(2, 3.14);
 
4613
    db2 = mtv_type(3);
 
4614
    db2.set(0, string("abc"));
 
4615
    db2.set<unsigned char>(1, 'z');
 
4616
    db2.set<unsigned char>(2, 'y');
 
4617
    db1.swap(0, 1, db2, 0);
 
4618
    assert(db1.get<string>(0) == "abc");
 
4619
    assert(db1.get<unsigned char>(1) == 'z');
 
4620
    assert(db2.get<double>(0) == 3.14);
 
4621
    assert(db2.get<double>(1) == 3.14);
 
4622
    assert(db2.get<unsigned char>(2) == 'y');
 
4623
 
 
4624
    // Another scenario.
 
4625
    db1 = mtv_type(5);
 
4626
    db1.set<int>(0, 1);
 
4627
    db1.set<int>(1, 2);
 
4628
    db1.set<int>(2, 3);
 
4629
    db1.set<int>(3, 4);
 
4630
    db1.set<int>(4, 5);
 
4631
    db2 = mtv_type(3);
 
4632
    db2.set(0, 2.3);
 
4633
    db2.set<char>(1, 'B');
 
4634
    db2.set<long>(2, 123);
 
4635
    db1.swap(0, 2, db2, 0);
 
4636
    assert(db1.get<double>(0) == 2.3);
 
4637
    assert(db1.get<char>(1) == 'B');
 
4638
    assert(db1.get<long>(2) == 123);
 
4639
    assert(db1.get<int>(3) == 4);
 
4640
    assert(db1.get<int>(4) == 5);
 
4641
    assert(db2.get<int>(0) == 1);
 
4642
    assert(db2.get<int>(1) == 2);
 
4643
    assert(db2.get<int>(2) == 3);
 
4644
    assert(db2.block_size() == 1);
 
4645
 
 
4646
    // Another one.
 
4647
    db1 = mtv_type(3, string("test"));
 
4648
    db2 = mtv_type(2);
 
4649
    db2.set(0, -99.1);
 
4650
    db2.set(1, string("foo"));
 
4651
    db1.swap(1, 2, db2, 0);
 
4652
    assert(db1.get<string>(0) == "test");
 
4653
    assert(db1.get<double>(1) == -99.1);
 
4654
    assert(db1.get<string>(2) == "foo");
 
4655
    assert(db2.get<string>(0) == "test");
 
4656
    assert(db2.get<string>(1) == "test");
 
4657
 
 
4658
    // The source range is in the middle of a block.
 
4659
    db1 = mtv_type(8);
 
4660
    for (int i = 0; i < 8; ++i)
 
4661
        db1.set<int>(i, i+2);
 
4662
    db2 = mtv_type(4);
 
4663
    db2.set<int>(0, 12);
 
4664
    db2.set<short>(1, 13);
 
4665
    db2.set<long>(2, 14);
 
4666
    db2.set<double>(3, 15.0);
 
4667
    db1.swap(3, 5, db2, 1);
 
4668
 
 
4669
    assert(db1.get<int>(0) == 2);
 
4670
    assert(db1.get<int>(1) == 3);
 
4671
    assert(db1.get<int>(2) == 4);
 
4672
    assert(db1.get<short>(3) == 13);
 
4673
    assert(db1.get<long>(4) == 14);
 
4674
    assert(db1.get<double>(5) == 15.0);
 
4675
    assert(db1.get<int>(6) == 8);
 
4676
    assert(db1.get<int>(7) == 9);
 
4677
 
 
4678
    assert(db2.get<int>(0) == 12);
 
4679
    assert(db2.get<int>(1) == 5);
 
4680
    assert(db2.get<int>(2) == 6);
 
4681
    assert(db2.get<int>(3) == 7);
 
4682
    assert(db2.block_size() == 1);
 
4683
 
 
4684
    // Try swapping in a multi-to-single block direction.
 
4685
    db1 = mtv_type(2);
 
4686
    db1.set(0, 1.2);
 
4687
    db1.set(1, string("123"));
 
4688
    db2 = mtv_type(10, short_val);
 
4689
    db1.swap(0, 1, db2, 4);
 
4690
    assert(db1.get<short>(0) == short_val);
 
4691
    assert(db1.get<short>(1) == short_val);
 
4692
 
 
4693
    assert(db2.get<short>(0) == short_val);
 
4694
    assert(db2.get<short>(1) == short_val);
 
4695
    assert(db2.get<short>(2) == short_val);
 
4696
    assert(db2.get<short>(3) == short_val);
 
4697
    assert(db2.get<double>(4) == 1.2);
 
4698
    assert(db2.get<string>(5) == "123");
 
4699
    assert(db2.get<short>(6) == short_val);
 
4700
    assert(db2.get<short>(7) == short_val);
 
4701
    assert(db2.get<short>(8) == short_val);
 
4702
    assert(db2.get<short>(9) == short_val);
 
4703
 
 
4704
    // Multi-to-multi block swapping. Very simple case.
 
4705
    db1 = mtv_type(2);
 
4706
    db1.set(0, 2.1);
 
4707
    db1.set(1, string("test"));
 
4708
    db2 = mtv_type(2);
 
4709
    db2.set(0, int_val);
 
4710
    db2.set(1, short_val);
 
4711
    db1.swap(0, 1, db2, 0);
 
4712
 
 
4713
    assert(db1.get<int>(0) == int_val);
 
4714
    assert(db1.get<short>(1) == short_val);
 
4715
    assert(db2.get<double>(0) == 2.1);
 
4716
    assert(db2.get<string>(1) == "test");
 
4717
 
 
4718
    // More complex case.
 
4719
    db1 = mtv_type(10);
 
4720
    db1.set<int>(0, 2);
 
4721
    db1.set<int>(1, 3);
 
4722
    db1.set<int>(2, 4);
 
4723
    db1.set<string>(3, "A");
 
4724
    db1.set<string>(4, "B");
 
4725
    db1.set<string>(5, "C");
 
4726
    // Leave some empty range.
 
4727
    db2 = mtv_type(10);
 
4728
    for (int i = 0; i < 10; ++i)
 
4729
        db2.set<int>(i, 10+i);
 
4730
    db2.set<char>(5, 'Z');
 
4731
    db1.swap(1, 7, db2, 2);
 
4732
 
 
4733
    assert(db1.get<int>(0) == 2);
 
4734
    assert(db1.get<int>(1) == 12);
 
4735
    assert(db1.get<int>(2) == 13);
 
4736
    assert(db1.get<int>(3) == 14);
 
4737
    assert(db1.get<char>(4) == 'Z');
 
4738
    assert(db1.get<int>(5) == 16);
 
4739
    assert(db1.get<int>(6) == 17);
 
4740
    assert(db1.get<int>(7) == 18);
 
4741
    assert(db1.is_empty(8));
 
4742
    assert(db1.is_empty(9));
 
4743
    assert(db1.block_size() == 4);
 
4744
 
 
4745
    assert(db2.get<int>(0) == 10);
 
4746
    assert(db2.get<int>(1) == 11);
 
4747
    assert(db2.get<int>(2) == 3);
 
4748
    assert(db2.get<int>(3) == 4);
 
4749
    assert(db2.get<string>(4) == "A");
 
4750
    assert(db2.get<string>(5) == "B");
 
4751
    assert(db2.get<string>(6) == "C");
 
4752
    assert(db2.is_empty(7));
 
4753
    assert(db2.is_empty(8));
 
4754
    assert(db2.get<int>(9) == 19);
 
4755
    assert(db2.block_size() == 4);
 
4756
}
 
4757
 
 
4758
struct block_node_printer : unary_function<mtv_type::value_type, void>
 
4759
{
 
4760
    void operator() (const mtv_type::value_type& node) const
 
4761
    {
 
4762
        cout << "type: " << node.type << "  size: " << node.size << "  data: " << node.data << endl;
 
4763
    }
 
4764
};
 
4765
 
 
4766
void mtv_test_value_type()
 
4767
{
 
4768
    stack_printer __stack_printer__("::mtv_test_value_type");
 
4769
    mtv_type db(5);
 
4770
    db.set(0, 1.1);
 
4771
    db.set(1, string("A"));
 
4772
    db.set(2, string("B"));
 
4773
    db.set(3, int(12));
 
4774
    db.set(4, short(8));
 
4775
    for_each(db.begin(), db.end(), block_node_printer());
 
4776
}
 
4777
 
 
4778
void mtv_test_block_identifier()
 
4779
{
 
4780
    stack_printer __stack_printer__("::mtv_test_block_identifier");
 
4781
    assert(mtv::numeric_element_block::block_type == mtv::element_type_numeric);
 
4782
    assert(mtv::string_element_block::block_type == mtv::element_type_string);
 
4783
    assert(mtv::short_element_block::block_type == mtv::element_type_short);
 
4784
    assert(mtv::ushort_element_block::block_type == mtv::element_type_ushort);
 
4785
    assert(mtv::int_element_block::block_type == mtv::element_type_int);
 
4786
    assert(mtv::uint_element_block::block_type == mtv::element_type_uint);
 
4787
    assert(mtv::long_element_block::block_type == mtv::element_type_long);
 
4788
    assert(mtv::ulong_element_block::block_type == mtv::element_type_ulong);
 
4789
    assert(mtv::boolean_element_block::block_type == mtv::element_type_boolean);
 
4790
    assert(mtv::char_element_block::block_type == mtv::element_type_char);
 
4791
    assert(mtv::uchar_element_block::block_type == mtv::element_type_uchar);
4149
4792
}
4150
4793
 
4151
4794
}
4152
4795
 
4153
4796
int main (int argc, char **argv)
4154
4797
{
4155
 
    cmd_options opt;
4156
 
    if (!parse_cmd_options(argc, argv, opt))
4157
 
        return EXIT_FAILURE;
4158
 
 
4159
 
    if (opt.test_func)
4160
 
    {
4161
 
        mtv_test_types();
4162
 
        mtv_test_construction();
4163
 
        mtv_test_basic();
4164
 
        mtv_test_empty_cells();
4165
 
        mtv_test_swap();
4166
 
        mtv_test_equality();
4167
 
        mtv_test_clone();
4168
 
        mtv_test_resize();
4169
 
        mtv_test_erase();
4170
 
        mtv_test_insert_empty();
4171
 
        mtv_test_set_cells();
4172
 
        mtv_test_insert_cells();
4173
 
        mtv_test_iterators();
4174
 
        mtv_test_data_iterators();
4175
 
        mtv_test_non_const_data_iterators();
4176
 
        mtv_test_iterator_private_data();
4177
 
        mtv_test_set_return_iterator();
4178
 
        mtv_test_set2_return_iterator();
4179
 
        mtv_test_insert_cells_return_iterator();
4180
 
        mtv_test_set_empty_return_iterator();
4181
 
        mtv_test_insert_empty_return_iterator();
4182
 
        mtv_test_set_with_position();
4183
 
        mtv_test_set_cells_with_position();
4184
 
        mtv_test_insert_cells_with_position();
4185
 
        mtv_test_set_empty_with_position();
4186
 
        mtv_test_insert_empty_with_position();
4187
 
        mtv_test_position();
4188
 
    }
4189
 
 
4190
 
    if (opt.test_perf)
4191
 
    {
4192
 
        mtv_perf_test_block_position_lookup();
4193
 
    }
 
4798
    mtv_test_types();
 
4799
    mtv_test_construction();
 
4800
    mtv_test_basic();
 
4801
    mtv_test_empty_cells();
 
4802
    mtv_test_swap();
 
4803
    mtv_test_equality();
 
4804
    mtv_test_clone();
 
4805
    mtv_test_resize();
 
4806
    mtv_test_erase();
 
4807
    mtv_test_insert_empty();
 
4808
    mtv_test_set_cells();
 
4809
    mtv_test_insert_cells();
 
4810
    mtv_test_iterators();
 
4811
    mtv_test_data_iterators();
 
4812
    mtv_test_non_const_data_iterators();
 
4813
    mtv_test_iterator_private_data();
 
4814
    mtv_test_set_return_iterator();
 
4815
    mtv_test_set2_return_iterator();
 
4816
    mtv_test_insert_cells_return_iterator();
 
4817
    mtv_test_set_empty_return_iterator();
 
4818
    mtv_test_insert_empty_return_iterator();
 
4819
    mtv_test_set_with_position();
 
4820
    mtv_test_set_cells_with_position();
 
4821
    mtv_test_insert_cells_with_position();
 
4822
    mtv_test_set_empty_with_position();
 
4823
    mtv_test_insert_empty_with_position();
 
4824
    mtv_test_position();
 
4825
    mtv_test_next_position();
 
4826
    mtv_test_swap_range();
 
4827
    mtv_test_value_type();
 
4828
    mtv_test_block_identifier();
4194
4829
 
4195
4830
    cout << "Test finished successfully!" << endl;
4196
4831
    return EXIT_SUCCESS;