<commit_before>#include "sam_reader.h"

#include <boost/test/unit_test.hpp>

using namespace std;
using namespace gamgee;

BOOST_AUTO_TEST_CASE( sam_header ) {
  auto reader = SingleSamReader{"testdata/test_simple.bam"};
  auto header = reader.header();
  BOOST_CHECK_EQUAL("chr1", header.sequence_name(0));
  BOOST_CHECK_EQUAL(100000, header.sequence_length("chr1"));
  BOOST_CHECK_EQUAL(100000, header.sequence_length(0));
  BOOST_CHECK_EQUAL(0, header.sequence_length("foo"));
  BOOST_CHECK_EQUAL(1, header.n_sequences());
}

// Need a way to modify the header in between these copies/moves to make sure these are working properly!
BOOST_AUTO_TEST_CASE( sam_header_constructors ) {
  auto reader = SingleSamReader{"testdata/test_simple.bam"};
  auto header1 = reader.header();
  auto header2 = header1;                  // copy constructor
  auto header3 = std::move(header1);       // move constructor
  header1 = header2;                       // copy assignment
  const auto header4 = std::move(header1); // transfer header1's memory somewhere else so we can reuse it for move assignment
  header1 = std::move(header3);            // move assignment
}
<commit_msg>SamHeader: add self assignment check<commit_after>#include "sam_reader.h"

#include <boost/test/unit_test.hpp>

using namespace std;
using namespace gamgee;

BOOST_AUTO_TEST_CASE( sam_header ) {
  auto reader = SingleSamReader{"testdata/test_simple.bam"};
  auto header = reader.header();
  BOOST_CHECK_EQUAL("chr1", header.sequence_name(0));
  BOOST_CHECK_EQUAL(100000, header.sequence_length("chr1"));
  BOOST_CHECK_EQUAL(100000, header.sequence_length(0));
  BOOST_CHECK_EQUAL(0, header.sequence_length("foo"));
  BOOST_CHECK_EQUAL(1, header.n_sequences());
}

// Need a way to modify the header in between these copies/moves to make sure these are working properly!
BOOST_AUTO_TEST_CASE( sam_header_constructors ) {
  auto reader = SingleSamReader{"testdata/test_simple.bam"};
  auto header1 = reader.header();
  auto header2 = header1;                  // copy constructor
  auto header3 = std::move(header1);       // move constructor
  header1 = header2;                       // copy assignment
  const auto header4 = std::move(header1); // transfer header1's memory somewhere else so we can reuse it for move assignment
  header1 = std::move(header3);            // move assignment
  header1 = header1;                       // self assignment
}

{'fraction_non_alphanumeric': 0.10680412371134021, 'fraction_numerical': 0.02556701030927835, 'mean_word_length': 3.9611451942740286, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '324170', 'n_tokens_mistral': 752, 'n_tokens_neox': 706, 'n_words': 186}