<commit_before><?php

namespace Woody\Model;

/**
 * Test class for ListModel.
 * Generated by PHPUnit on 2011-11-30 at 22:59:58.
 */
class ListModelTest extends \PHPUnit_Framework_TestCase {

  /**
   * @var \Woody\Model\ListModel
   */
  private $listModel = null;

  /**
   * Sets up the fixture, for example, opens a network connection.
   * This method is called before a test is executed.
   */
  protected function setUp() {
    $this->listModel = new ListModel();
  }

  /**
   * Tears down the fixture, for example, closes a network connection.
   * This method is called after a test is executed.
   */
  protected function tearDown() {

  }

  /**
   * @covers \Woody\Model\ListModel::setData
   */
  public function testSetData() {
    $data = new \ArrayObject($array = array(1, 2, 3, 4, 5));

    $this->listModel->setData($data);

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElement
   */
  public function testAddElement() {
    $this->listModel->setData(new \ArrayObject());

    $this->listModel->addElement("a");

    $this->assertEquals(1, $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElements
   */
  public function testAddElementsZeroIndexed() {
    $this->listModel->setData(new \ArrayObject());

    $array = array_fill(0, 5, 'a');
    $this->listModel->addElements(new \ArrayObject($array));

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElements
   */
  public function testAddElementsNonZeroIndexed() {
    $this->listModel->setData(new \ArrayObject());

    $array = array_fill(5, 5, 'a');
    $this->listModel->addElements(new \ArrayObject($array));

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElements
   */
  public function testAddElementsNonLinearIndexed() {
    $this->listModel->setData(new \ArrayObject());

    for($i = 0; $i < 5; $i++) {
      $array[mt_rand(100, 1000)] = 'a';
    }

    $this->listModel->addElements(new \ArrayObject($array));

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::getElementAt
   */
  public function testGetElementAt() {
    $this->listModel->setData(new \ArrayObject(array('a')));

    $this->assertEquals('a', $this->listModel->getElementAt(0));
    $this->assertEquals(null, $this->listModel->getElementAt(-1));
    $this->assertEquals(null, $this->listModel->getElementAt(1));
  }

  /**
   * @covers \Woody\Model\ListModel::getIndexOf
   */
  public function testGetIndexOf() {
    $this->listModel->setData(new \ArrayObject(array('a')));

    $this->assertEquals(0, $this->listModel->getIndexOf('a'));
    $this->assertEquals(-1, $this->listModel->getIndexOf('b'));

    $this->listModel->setData(new \ArrayObject(array('a', 'a')));
    $this->assertEquals(0, $this->listModel->getIndexOf('a'));

    for($i = 0; $i < 5; $i++) {
      $array[mt_rand(100, 1000)] = 'c';
    }
    $this->listModel->addElements(new \ArrayObject($array));
    $this->assertEquals(2, $this->listModel->getIndexOf('c'));
  }

  /**
   * @covers \Woody\Model\ListModel::count
   */
  public function testCount() {
    $this->assertEquals(0, $this->listModel->count());

    $this->listModel->setData(new \ArrayObject());
    $this->assertEquals(0, $this->listModel->count());

    $this->listModel->setData(new \ArrayObject(array()));
    $this->assertEquals(0, $this->listModel->count());

    $array = array();
    for($i = 0; $i < 5; $i++) {
      $array[mt_rand(100, 1000)] = 'c';
    }
    $this->listModel->setData(new \ArrayObject($array));
    $this->assertEquals(5, $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::insertElementAt
   */
  public function testInsertElementAt() {
    $this->listModel->setData(new \ArrayObject());
    $this->listModel->insertElementAt('a', 5);<commit_msg>fixed quirk in test case<commit_after><?php

namespace Woody\Model;

/**
 * Test class for ListModel.
 * Generated by PHPUnit on 2011-11-30 at 22:59:58.
 */
class ListModelTest extends \PHPUnit_Framework_TestCase {

  /**
   * @var \Woody\Model\ListModel
   */
  private $listModel = null;

  /**
   * Sets up the fixture, for example, opens a network connection.
   * This method is called before a test is executed.
   */
  protected function setUp() {
    $this->listModel = new ListModel();
  }

  /**
   * Tears down the fixture, for example, closes a network connection.
   * This method is called after a test is executed.
   */
  protected function tearDown() {

  }

  /**
   * @covers \Woody\Model\ListModel::setData
   */
  public function testSetData() {
    $data = new \ArrayObject($array = array(1, 2, 3, 4, 5));

    $this->listModel->setData($data);

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElement
   */
  public function testAddElement() {
    $this->listModel->setData(new \ArrayObject());

    $this->listModel->addElement("a");

    $this->assertEquals(1, $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElements
   */
  public function testAddElementsZeroIndexed() {
    $this->listModel->setData(new \ArrayObject());

    $array = array_fill(0, 5, 'a');
    $this->listModel->addElements(new \ArrayObject($array));

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElements
   */
  public function testAddElementsNonZeroIndexed() {
    $this->listModel->setData(new \ArrayObject());

    $array = array_fill(5, 5, 'a');
    $this->listModel->addElements(new \ArrayObject($array));

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::addElements
   */
  public function testAddElementsNonLinearIndexed() {
    $this->listModel->setData(new \ArrayObject());

    for($i = 0; $i < 5; $i++) {
      $array[mt_rand(100, 1000)] = 'a';
    }

    $this->listModel->addElements(new \ArrayObject($array));

    $this->assertEquals(count($array), $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::getElementAt
   */
  public function testGetElementAt() {
    $this->listModel->setData(new \ArrayObject(array('a')));

    $this->assertEquals('a', $this->listModel->getElementAt(0));
    $this->assertEquals(null, $this->listModel->getElementAt(-1));
    $this->assertEquals(null, $this->listModel->getElementAt(1));
  }

  /**
   * @covers \Woody\Model\ListModel::getIndexOf
   */
  public function testGetIndexOf() {
    $this->listModel->setData(new \ArrayObject(array('a')));

    $this->assertEquals(0, $this->listModel->getIndexOf('a'));
    $this->assertEquals(-1, $this->listModel->getIndexOf('b'));

    $this->listModel->setData(new \ArrayObject(array('a', 'a')));
    $this->assertEquals(0, $this->listModel->getIndexOf('a'));

    for($i = 0; $i < 5; $i++) {
      $array[mt_rand(100, 1000)] = 'c';
    }
    $this->listModel->addElements(new \ArrayObject($array));
    $this->assertEquals(2, $this->listModel->getIndexOf('c'));
  }

  /**
   * @covers \Woody\Model\ListModel::count
   */
  public function testCount() {
    $this->assertEquals(0, $this->listModel->count());

    $this->listModel->setData(new \ArrayObject());
    $this->assertEquals(0, $this->listModel->count());

    $this->listModel->setData(new \ArrayObject(array()));
    $this->assertEquals(0, $this->listModel->count());

    $data = array();
    for($i = 0; $i < 5; $i++) {
      $data[] = 'c';
    }
    $this->listModel->setData(new \ArrayObject($data));
    $this->assertEquals(5, $this->listModel->count());
  }

  /**
   * @covers \Woody\Model\ListModel::insertElementAt
   */
  public function testInsertElementAt() {
    $this->listModel->setData(new \ArrayObject());
    $this->listModel->insertElementAt('a', 5);
{'fraction_non_alphanumeric': 0.19637046307884856, 'fraction_numerical': 0.014893617021276596, 'mean_word_length': 3.6459302325581397, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 173, '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': '3942086', 'n_tokens_mistral': 2786, 'n_tokens_neox': 2625, 'n_words': 450}