void check_indexed_access(const fixture<T,NA>& fix, const crs_matrix<T,NA>& m) { using idx_t = typename fixture<T,NA>::index; if(fix.expected_items().empty()) return; //check indexed access of stored elements for(const auto& x : fix.expected_items()) { if(m(x.row, x.col) != x.val) throw std::logic_error{"crs_matrix, indexed access of stored values"}; } //check indexed access of non-stored elements for(idx_t r = 0; r < m.rows(); ++r) { for(idx_t c = 0, cols = m.cols(); c < cols; ++c) { bool stored = false; for(const auto& x : fix.expected_items()) { if(x.row == r && x.col == c) { stored = true; break; } } if( !stored && (m(r,c) != m.na_value() || m.has(r,c)) ) { throw std::logic_error{"crs_matrix, indexed access of n/a values"}; } } } }