package jetbrains.mps.internalCollections.test.nullHacks;

/*Generated by MPS */

import jetbrains.mps.internalCollections.test.closures.Util_Test;
import org.junit.jupiter.api.Test;
import jetbrains.mps.internal.collections.runtime.Sequence;
import org.junit.Assert;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import java.util.ArrayList;
import jetbrains.mps.internal.collections.runtime.ISequence;
import jetbrains.mps.internal.collections.runtime.ArrayUtils;

public class NullSequence_Test extends Util_Test {
  @Test
  public void test_nullSequence() throws Exception {
    if (Sequence.USE_NULL_SEQUENCE) {
      Iterable<Integer> nullSeq = null;
      Assert.assertNull(nullSeq);
      Assert.assertNull(Sequence.fromIterable(nullSeq).first());
      Assert.assertNull(Sequence.fromIterable(nullSeq).last());
      Assert.assertEquals(0, Sequence.fromIterable(nullSeq).count());
      Assert.assertEquals(0, Sequence.fromIterable(nullSeq).count());
      List<Integer> list5 = ListSequence.fromListAndArray(new ArrayList<Integer>(), 1, 2, 3, 4, 5);
      ListSequence.fromList(list5).addSequence(Sequence.fromIterable(nullSeq));
      this.assertIterableEquals(this.expect5(), list5);
      ListSequence.fromList(list5).removeSequence(Sequence.fromIterable(nullSeq));
      this.assertIterableEquals(this.expect5(), list5);
    }
  }
  @Test
  public void test_nullCompareOperations() throws Exception {
    if (Sequence.USE_NULL_SEQUENCE) {
      Iterable<Integer> input = this.input5();
      this.assertIterableEquals(this.expect5(), Sequence.fromIterable(input).concat(null));
      this.assertIterableEquals(this.expect5(), Sequence.fromIterable(input).union(null));
      this.assertIterableEquals(this.expectEmpty(), Sequence.fromIterable(input).intersect(null));
      this.assertIterableEquals(this.expect5(), Sequence.fromIterable(input).disjunction(null));
      this.assertIterableEquals(this.expect5(), Sequence.fromIterable(input).subtract(null));
    }
  }
  @Test
  public void test_nullTranslate() throws Exception {
    if (Sequence.USE_NULL_SEQUENCE) {
      Iterable<Integer> input = this.input5();
      Iterable<String> nullSeq = Sequence.fromIterable(input).translate((it) -> ((ISequence<String>) null));
      Assert.assertEquals(0, Sequence.fromIterable(nullSeq).count());
      Assert.assertEquals(0, Sequence.fromIterable(nullSeq).count());
    }
  }
  @Test
  public void test_nullList() throws Exception {
    if (Sequence.USE_NULL_SEQUENCE) {
      List<Integer> nullList = null;
      Assert.assertNull(nullList);
      Assert.assertNull(ListSequence.fromList(nullList).first());
      Assert.assertNull(ListSequence.fromList(nullList).last());
      Assert.assertNull(ListSequence.fromList(nullList).first());
      Assert.assertNull(ListSequence.fromList(nullList).getElement(-1));
      Assert.assertEquals(0, ListSequence.fromList(nullList).count());
      Assert.assertEquals(0, ListSequence.fromList(nullList).count());
    }
  }
  @Test
  public void test_forEach() throws Exception {
    if (Sequence.USE_NULL_SEQUENCE) {
      for (Object foo : Sequence.emptySequence()) {
      }
    }
  }
  @Test
  public void test_nullArray() throws Exception {
    int[] arr = null;
    for (int i : ArrayUtils.fromIntegerArray(arr)) {
      Assert.assertTrue(false);
    }
    Integer[] iarr = null;
    for (Integer i : Sequence.fromIterable(Sequence.fromArray(iarr))) {
      Assert.assertTrue(false);
    }
    Object[] oarr = null;
    for (Object i : Sequence.fromArray(oarr)) {
      Assert.assertTrue(false);
    }
  }
}
