<commit_before>﻿/* -*- coding: utf-8; mode: c++; tab-width: 3; indent-tabs-mode: nil -*-

Copyright 2015
<NAME>

This file is part of Abaclade.

Abaclade is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

Abaclade is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along with Abaclade. If not, see
<http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------------------------*/

#include <abaclade.hxx>
#include <abaclade/testing/test_case.hxx>
#include <abaclade/list.hxx>


////////////////////////////////////////////////////////////////////////////////////////////////////
// abc::test::list_basic

namespace abc {
namespace test {

ABC_TESTING_TEST_CASE_FUNC(list_basic, "abc::list – basic operations") {
   ABC_TRACE_FUNC(this);

   list<int> l;

   ABC_TESTING_ASSERT_EQUAL(l.size(), 0u);
   ABC_TESTING_ASSERT_TRUE(l.begin() == l.end());

   l.push_front(10);
   ABC_TESTING_ASSERT_EQUAL(l.size(), 1u);

   l.push_back(20);
   ABC_TESTING_ASSERT_EQUAL(l.size(), 2u);

   l.pop_front();
   ABC_TESTING_ASSERT_EQUAL(l.size(), 1u);

   l.pop_back();
   ABC_TESTING_ASSERT_EQUAL(l.size(), 0u);

   l.clear();
   ABC_TESTING_ASSERT_EQUAL(l.size(), 0u);
}

} //namespace test
} //namespace abc<commit_msg>Add more abc::list test assertions<commit_after>﻿/* -*- coding: utf-8; mode: c++; tab-width: 3; indent-tabs-mode: nil -*-

Copyright 2015
<NAME>

This file is part of Abaclade.

Abaclade is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

Abaclade is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along with Abaclade. If not, see
<http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------------------------*/

#include <abaclade.hxx>
#include <abaclade/testing/test_case.hxx>
#include <abaclade/list.hxx>


////////////////////////////////////////////////////////////////////////////////////////////////////
// abc::test::list_basic

namespace abc {
namespace test {

ABC_TESTING_TEST_CASE_FUNC(list_basic, "abc::list – basic operations") {
   ABC_TRACE_FUNC(this);

   list<int> l;

   ABC_TESTING_ASSERT_EQUAL(l.size(), 0u);
   // These assertions target const begin/end.
   ABC_TESTING_ASSERT_TRUE(l.cbegin() == l.cend());
   ABC_TESTING_ASSERT_TRUE(l.crbegin() == l.crend());

   l.push_front(10);
   ABC_TESTING_ASSERT_EQUAL(l.size(), 1u);
   {
      /* This uses begin(), not cbegin(), so we can test equality comparison between const/non-const
      iterators. */
      auto it(l.begin());
      ABC_TESTING_ASSERT_EQUAL(*it, 10);
      ++it;
      ABC_TESTING_ASSERT_TRUE(it == l.cend());
   }

   l.push_back(20);
   ABC_TESTING_ASSERT_EQUAL(l.size(), 2u);
   {
      // This iterates backwards and is longer than, but symmetrical to, the block above.
      auto it(l.rbegin());
      ABC_TESTING_ASSERT_EQUAL(*it, 20);
      ++it;
      ABC_TESTING_ASSERT_EQUAL(*it, 10);
      ++it;
      ABC_TESTING_ASSERT_TRUE(it == l.crend());
   }

   l.pop_front();
   ABC_TESTING_ASSERT_EQUAL(l.size(), 1u);
   {
      // Now iterate backwards using a forward iterator.
      auto it(l.end());
      --it;
      ABC_TESTING_ASSERT_EQUAL(*it, 20);
      ABC_TESTING_ASSERT_TRUE(it == l.cbegin());
   }

   l.pop_back();
   ABC_TESTING_ASSERT_EQUAL(l.size(), 0u);
   // These assertions target non-const begin/end.
   ABC_TESTING_ASSERT_TRUE(l.begin() == l.end());
   ABC_TESTING_ASSERT_TRUE(l.rbegin() == l.rend());

   l.push_front(30);
   ABC_TESTING_ASSERT_EQUAL(l.size(), 1u);

   l.clear();
   ABC_TESTING_ASSERT_EQUAL(l.size(), 0u);
}

} //namespace test
} //namespace abc
{'fraction_non_alphanumeric': 0.2023082145281738, 'fraction_numerical': 0.010183299389002037, 'mean_word_length': 2.5934959349593494, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5494753', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1338, 'n_words': 392}