Changeset 4027


Ignore:
Timestamp:
Jan 17, 2021, 11:46:38 AM (8 months ago)
Author:
Peter
Message:

refs #968; fix implementation of SegmentSet::insert_merge and add some tests to avoid similar regressions.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/segment.cc

    r3661 r4027  
    4141void test_operator(test::Suite& suite);
    4242void test_segment_map(test::Suite& suite);
     43void test_segment_set(test::Suite& suite);
    4344void test_set_bound(test::Suite&);
    4445void test_union(test::Suite&);
     
    6465
    6566  test_segment_map(suite);
     67  test_segment_set(suite);
    6668
    6769  return suite.return_value();
     
    267269}
    268270
     271
    269272void test_segment_map(test::Suite& suite)
    270273{
     
    303306}
    304307
     308
     309void test_segment_set(test::Suite& suite)
     310{
     311  SegmentSet<double> set;
     312  Segment<double> segment(0.12,23.2);
     313  set.insert_merge(segment);
     314  set.insert_merge(Segment<double>(0.12,23.2));
     315  SegmentSet<double>::iterator hint = set.begin();
     316  set.insert_merge(hint, segment);
     317  set.insert_merge(hint, Segment<double>(0.12,23.2));
     318  SegmentSet<double>::const_iterator chint = set.begin();
     319  set.insert_merge(chint, segment);
     320  set.insert_merge(chint, Segment<double>(0.12,23.2));
     321  std::vector<Segment<double>> vec(set.begin(), set.end());
     322  set.insert_merge(vec.begin(), vec.end());
     323
     324  // test functions inherited from SegmentTree
     325  SegmentSet<double>::const_iterator citer = set.begin();
     326  SegmentSet<double>::const_iterator iter = set.begin();
     327
     328  citer = set.end();
     329  iter = set.end();
     330
     331  if (set.count(0.13)!=1) {
     332    suite.add(false);
     333    suite.err() << "error: expected count = 1\n";
     334  }
     335  if (set.count(0.02)!=0) {
     336    suite.add(false);
     337    suite.err() << "error: expected count = 0\n";
     338  }
     339  if (set.empty()) {
     340    suite.add(false);
     341    suite.err() << "error: expected empty() return false";
     342  }
     343  if (set.find(0.15) == set.end()) {
     344    suite.add(false);
     345    suite.err() << "error: find returned end()";
     346  }
     347  set.erase(set.begin());
     348  set.clear();
     349  set.erase(set.begin(), set.end());
     350
     351  set.insert(segment);
     352  set.insert(Segment<double>(102, 200));
     353
     354  iter = set.lower_bound(1.0);
     355  citer = set.lower_bound(1.0);
     356  iter = set.upper_bound(1.0);
     357  citer = set.upper_bound(1.0);
     358  SegmentSet<double>::size_type s = set.size();
     359  test::avoid_compiler_warning(s);
     360}
     361
     362
    305363void test_segment(test::Suite& suite)
    306364{
  • trunk/yat/utility/SegmentSet.h

    r4026 r4027  
    6767      std::pair<typename me::iterator, typename me::iterator> p =
    6868        this->overlap_range(segment);
    69       return insert_merge(p, segment);
     69      Segment<T> tmp(segment);
     70      return move_insert_merge(p, std::move(tmp));
    7071    }
    7172
Note: See TracChangeset for help on using the changeset viewer.