dither 0.2.6 → 0.2.7

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b006159a1b729a73db618c798df025d7ac71584f
4
- data.tar.gz: d53268fc1aaa144bedd5e216d887235cc573af4d
3
+ metadata.gz: 01b92d7c2a5378b386ca65f4d71df1120c3782cf
4
+ data.tar.gz: 6c44ca627b200e9188f4aad2dab3575cf6a4742b
5
5
  SHA512:
6
- metadata.gz: e06c1afdd9e517e00c70a8dcf8984425059d4024ec86cc0fafc1a0a8a1049c7de825dd0daf5bcafeacc5f8ea04b2f441c29b6ddf679b394787a4f89e83a096bc
7
- data.tar.gz: af4aa4e4434de024b19b50552aa63ed3cf29a50aaf8646a2278f8418e3fbffa95271af6bf1bc6497fc69c4124e2d3d0822edaa9e8c49d13acdbb1f5bd16da7fd
6
+ metadata.gz: 5318e78b9eb0b81b49441b7c1a3784bca2c73be27a569170b5e9e7889258af4b846806f39b10a25cb21828b5b0dc5ff219afc576739a8f6c2b85cf3d721087e5
7
+ data.tar.gz: 1aa0885ecffc700a43937bef1f79fccb2c5985816825e0d07390c0b2b65b5a1f4d97166b40f14ac905a00b50f2767ad03bca8a6af41276110a1e740b5e84d942
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  Collection of combinatorial test generation strategies.
3
3
 
4
4
  # Requirements
5
- a c++ compiler is required when installing on mri.
5
+ a c++ compiler is required when installing on mri. tested on gcc 4.6, gcc 5.3, and clang 3.7.
6
6
 
7
7
  # Usage
8
8
 
@@ -122,19 +122,28 @@ void Ipog::run() {
122
122
 
123
123
  if (!case_covered) {
124
124
  bool is_merged = false;
125
-
126
- for (auto next = unbound_.begin(); next != unbound_.end(); ++next) {
125
+ auto prev = unbound_.before_begin();
126
+ auto next = unbound_.begin();
127
+ auto end = unbound_.end();
128
+ while (next != end) {
127
129
  const int merge_result = merge(k, *next, test_case);
128
130
 
129
- if (merge_result > 0) {
130
- dtest_case tmp = *next;
131
+ if (merge_result >= 0) {
131
132
  for (std::size_t i = 0; i < t_; i++) {
132
133
  const param *it = test_case[i];
133
- tmp[it->first] = it->second;
134
+ (*next)[it->first] = it->second;
134
135
  }
135
136
  is_merged = true;
137
+ }
138
+ if (merge_result == 0) {
139
+ bound_.push_front(*next);
140
+ unbound_.erase_after(prev);
141
+ break;
142
+ } else if (merge_result == 1) {
136
143
  break;
137
144
  }
145
+ ++prev;
146
+ ++next;
138
147
  }
139
148
 
140
149
  if (!is_merged) {
@@ -150,6 +159,7 @@ void Ipog::run() {
150
159
  }
151
160
  }
152
161
  }
162
+
153
163
  ground_solutions();
154
164
  }
155
165
 
@@ -206,32 +216,39 @@ inline bool Ipog::is_covered(const dtest_case &test_case,
206
216
  inline const int Ipog::maximize_coverage(const int k, dtest_case &test_case,
207
217
  std::forward_list<param **> &pi) {
208
218
  const std::vector<param> &param_range = param_cache_[k];
209
- int current_max = -1;
210
- param max_param = param_range[0];
211
- std::forward_list<std::forward_list<param **>::iterator> covered;
212
-
213
- for (auto it = param_range.cbegin(); it != param_range.cend(); ++it) {
214
- std::forward_list<std::forward_list<param **>::iterator> tmp_covered;
215
- const param current_param = *it;
216
-
217
- test_case[current_param.first] = current_param.second;
218
- if (!constraint_handler->violate_constraints(test_case)) {
219
- int count = 0;
220
- auto prev = pi.before_begin();
221
- for (auto params = pi.begin(); params != pi.end(); ++params, ++prev) {
222
- if (is_covered(test_case, *params)) {
223
- tmp_covered.push_front(prev);
224
- count++;
225
- }
226
- }
219
+ std::vector<std::forward_list<std::forward_list<param **>::iterator>> covered(
220
+ param_range.size());
221
+ std::vector<int> counts(param_range.size());
222
+ const std::size_t index = param_range[0].first;
223
+ std::vector<std::size_t> valid_indexes;
224
+ valid_indexes.reserve(counts.size());
225
+ for (std::size_t i = 0; i < counts.size(); i++) {
226
+ test_case[index] = param_range[i].second;
227
+ if (constraint_handler->violate_constraints(test_case)) {
228
+ counts[i] = -1;
229
+ } else {
230
+ valid_indexes.push_back(i);
231
+ }
232
+ }
227
233
 
228
- if (count > current_max) {
229
- current_max = count;
230
- max_param = current_param;
231
- covered = tmp_covered;
234
+ auto prev = pi.before_begin();
235
+ for (auto params = pi.begin(); params != pi.end(); ++params, ++prev) {
236
+ for (auto i : valid_indexes) {
237
+ test_case[index] = param_range[i].second;
238
+ if (is_covered(test_case, *params)) {
239
+ covered[i].push_front(prev);
240
+ ++counts[i];
232
241
  }
233
242
  }
234
- test_case[current_param.first] = -1;
243
+ }
244
+
245
+ int current_max = -1;
246
+ std::size_t max_index = 0;
247
+ for (auto i : valid_indexes) {
248
+ if (current_max < counts[i]) {
249
+ current_max = counts[i];
250
+ max_index = i;
251
+ }
235
252
  }
236
253
 
237
254
  if (current_max == -1) {
@@ -239,11 +256,12 @@ inline const int Ipog::maximize_coverage(const int k, dtest_case &test_case,
239
256
  }
240
257
 
241
258
  /* remove covered */
242
- for (auto it = covered.begin(); it != covered.end(); ++it) {
259
+ for (auto it = covered[max_index].begin(); it != covered[max_index].end();
260
+ ++it) {
243
261
  pi.erase_after(*it);
244
262
  }
245
263
 
246
- test_case[max_param.first] = max_param.second;
264
+ test_case[index] = param_range[max_index].second;
247
265
  return current_max;
248
266
  }
249
267
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.2.6'
3
+ VERSION = '0.2.7'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dither
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Gowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project: dither
153
- rubygems_version: 2.4.5
153
+ rubygems_version: 2.2.0
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: Collection of test generation strategies