package jetbrains.mps.baseLanguage.collections.unittest.simple_operations;

/*Generated by MPS */

import org.junit.jupiter.api.Test;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import org.junit.Assert;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Null_Test {
  @Test
  public void test__1() throws Exception {
    List<String> l = null;
    ListSequence.fromList(l).addElement("");
    ListSequence.fromList(l).addSequence(ListSequence.fromList(l));
    Assert.assertNull(ListSequence.fromList(l).first());
    Assert.assertNull(ListSequence.fromList(l).last());
    Assert.assertNull(ListSequence.fromList(l).first());
    Assert.assertEquals(-1, ListSequence.fromList(l).indexOf(""));
    Assert.assertTrue(ListSequence.fromList(l).isEmpty());
    Assert.assertFalse(ListSequence.fromList(l).isNotEmpty());
    Assert.assertEquals(0, ListSequence.fromList(l).count());
    ListSequence.fromList(l).removeElement("");
    ListSequence.fromList(l).removeSequence(ListSequence.fromList(l));
  }
  @Test
  public void test_exceptions() throws Exception {
    LinkedList<Integer> llEmpty = new LinkedList<Integer>();
    List<Integer> blEmpty = new ArrayList<Integer>();
    List<Integer> blCEmpty = ListSequence.fromList(new ArrayList<Integer>());
    LinkedList<Integer> llSingle = new LinkedList<Integer>();
    llSingle.add(566);
    List<Integer> cNull = null;
    List<Integer> cEmpty = ListSequence.fromList(new ArrayList<Integer>());
    List<Integer> cBlEmpty = new ArrayList<Integer>();
    try {
      llEmpty.getFirst();
      Assert.fail();
    } catch (NoSuchElementException e) {
      // expected exception
    }
    try {
      llEmpty.getLast();
      Assert.fail();
    } catch (NoSuchElementException e) {
      // expected exception
    }
    try {
      llEmpty.get(0);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      llEmpty.get(-1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      llEmpty.get(1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      blEmpty.get(0);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      blEmpty.get(-1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      blEmpty.get(1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      blCEmpty.get(0);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      blCEmpty.get(-1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      blCEmpty.get(1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    Assert.assertEquals(llSingle.get(0), (Integer) 566);
    try {
      llSingle.get(1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      llSingle.get(-1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    Assert.assertNull(ListSequence.fromList(cNull).getElement(0));
    Assert.assertNull(ListSequence.fromList(cNull).getElement(-1));
    Assert.assertNull(ListSequence.fromList(cNull).getElement(1));
    Assert.assertNull(ListSequence.fromList(cEmpty).getElement(0));
    Assert.assertNull(ListSequence.fromList(cEmpty).getElement(-1));
    try {
      ListSequence.fromList(cEmpty).getElement(1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      ListSequence.fromList(cEmpty).getElement(-2);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    Assert.assertNull(ListSequence.fromList(cBlEmpty).getElement(0));
    Assert.assertNull(ListSequence.fromList(cBlEmpty).getElement(-1));
    try {
      ListSequence.fromList(cBlEmpty).getElement(1);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
    try {
      ListSequence.fromList(cBlEmpty).getElement(-2);
      Assert.fail();
    } catch (IndexOutOfBoundsException e) {
      // expected exception
    }
  }
}
