text:
package org.assertj.core.api;

import static org.assertj.core.api.Assertions.catchThrowable;

import java.io.File;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.net.URL;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicMarkableReference;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.atomic.AtomicStampedReference;

import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.util.CanIgnoreReturnValue;
import org.assertj.core.util.CheckReturnValue;

/**
 * AbstractBDDSoftAssertions compatible with Android. Duplicated from {@link BDDSoftAssertionsProvider}.
 *
 * @see BDDSoftAssertionsProvider
 *
 * @since 2.5.0 / 3.5.0
 */
@CheckReturnValue
public interface Java6BDDSoftAssertionsProvider extends SoftAssertionsProvider {
  // then* methods duplicated from BDDAssertions

  /**
   * Creates a new instance of {@link BigDecimalAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default BigDecimalAssert then(BigDecimal actual) {
    return proxy(BigDecimalAssert.class, BigDecimal.class, actual);
  }

  /**
   * Creates a new instance of {@link BigIntegerAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  default BigIntegerAssert then(BigInteger actual) {
    return proxy(BigIntegerAssert.class, BigInteger.class, actual);
  }

  /**
   * Creates a new instance of {@link BooleanAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default BooleanAssert then(boolean actual) {
    return proxy(BooleanAssert.class, Boolean.class, actual);
  }

  /**
   * Creates a new instance of {@link BooleanAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default BooleanAssert then(Boolean actual) {
    return proxy(BooleanAssert.class, Boolean.class, actual);
  }

  /**
   * Creates a new instance of {@link BooleanArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default BooleanArrayAssert then(boolean[] actual) {
    return proxy(BooleanArrayAssert.class, boolean[].class, actual);
  }

  /**
   * Creates a new instance of {@link Boolean2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Boolean2DArrayAssert then(boolean[][] actual) {
    return proxy(Boolean2DArrayAssert.class, boolean[][].class, actual);
  }

  /**
   * Creates a new instance of {@link ByteAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ByteAssert then(byte actual) {
    return proxy(ByteAssert.class, Byte.class, actual);
  }

  /**
   * Creates a new instance of {@link ByteAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ByteAssert then(Byte actual) {
    return proxy(ByteAssert.class, Byte.class, actual);
  }

  /**
   * Creates a new instance of {@link ByteArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ByteArrayAssert then(byte[] actual) {
    return proxy(ByteArrayAssert.class, byte[].class, actual);
  }

  /**
   * Creates a new instance of {@link Byte2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Byte2DArrayAssert then(byte[][] actual) {
    return proxy(Byte2DArrayAssert.class, byte[][].class, actual);
  }

  /**
   * Creates a new instance of {@link CharacterAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default CharacterAssert then(char actual) {
    return proxy(CharacterAssert.class, Character.class, actual);
  }

  /**
   * Creates a new instance of {@link CharArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default CharArrayAssert then(char[] actual) {
    return proxy(CharArrayAssert.class, char[].class, actual);
  }

  /**
   * Creates a new instance of {@link Char2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Char2DArrayAssert then(char[][] actual) {
    return proxy(Char2DArrayAssert.class, char[][].class, actual);
  }

  /**
   * Creates a new instance of {@link CharacterAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default CharacterAssert then(Character actual) {
    return proxy(CharacterAssert.class, Character.class, actual);
  }

  /**
   * Creates a new instance of {@link ClassAssert}
   *

   * We don't return {@link ClassAssert} as it has overridden methods to annotated with {@link SafeVarargs}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ProxyableClassAssert then(Class<?> actual) {
    return proxy(ProxyableClassAssert.class, Class.class, actual);
  }

  /**
   * Creates a new instance of {@link org.assertj.core.api.GenericComparableAssert} with
   * standard comparison semantics.
   *
   * @param <T> the type of actual.
   * @param actual the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <T extends Comparable<? super T>> AbstractComparableAssert<?, T> then(T actual) {
    return proxy(GenericComparableAssert.class, Comparable.class, actual);
  }

  /**
   * Creates a new instance of {@link IterableAssert}.
   *
   * @param <T> the type of elements.
   * @param actual the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <T> ProxyableIterableAssert<T> then(Iterable<? extends T> actual) {
    return proxy(ProxyableIterableAssert.class, Iterable.class, actual);
  }

  /**
   * Creates a new instance of {@link IteratorAssert}.
   *

   * This is a breaking change in version 3.12.0: this method used to return an {@link ProxyableIterableAssert}.
   *
   * @param <T> the type of elements.
   * @param actual the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <T> IteratorAssert<T> then(Iterator<? extends T> actual) {
    return proxy(IteratorAssert.class, Iterator.class, actual);
  }

  /**
   * Creates a new instance of {@link DoubleAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default DoubleAssert then(double actual) {
    return proxy(DoubleAssert.class, Double.class, actual);
  }

  /**
   * Creates a new instance of {@link DoubleAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default DoubleAssert then(Double actual) {
    return proxy(DoubleAssert.class, Double.class, actual);
  }

  /**
   * Creates a new instance of {@link DoubleArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default DoubleArrayAssert then(double[] actual) {
    return proxy(DoubleArrayAssert.class, double[].class, actual);
  }

  /**
   * Creates a new instance of {@link Double2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Double2DArrayAssert then(double[][] actual) {
    return proxy(Double2DArrayAssert.class, double[][].class, actual);
  }

  /**
   * Creates a new instance of {@link FileAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default FileAssert then(File actual) {
    return proxy(FileAssert.class, File.class, actual);
  }

  /**
   * Creates a new instance of {@link FutureAssert}.
   *
   * @param <RESULT> the type of the value contained in the {@link java.util.concurrent.Future}.
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <RESULT> FutureAssert<RESULT> then(Future<RESULT> actual) {
    return proxy(FutureAssert.class, Future.class, actual);
  }

  /**
   * Creates a new instance of {@link InputStreamAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default InputStreamAssert then(InputStream actual) {
    return proxy(InputStreamAssert.class, InputStream.class, actual);
  }

  /**
   * Creates a new instance of {@link FloatAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default FloatAssert then(float actual) {
    return proxy(FloatAssert.class, Float.class, actual);
  }

  /**
   * Creates a new instance of {@link FloatAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default FloatAssert then(Float actual) {
    return proxy(FloatAssert.class, Float.class, actual);
  }

  /**
   * Creates a new instance of {@link FloatArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default FloatArrayAssert then(float[] actual) {
    return proxy(FloatArrayAssert.class, float[].class, actual);
  }

  /**
   * Creates a new instance of {@link Float2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Float2DArrayAssert then(float[][] actual) {
    return proxy(Float2DArrayAssert.class, float[][].class, actual);
  }

  /**
   * Creates a new instance of {@link IntegerAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default IntegerAssert then(int actual) {
    return proxy(IntegerAssert.class, Integer.class, actual);
  }

  /**
   * Creates a new instance of {@link IntArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default IntArrayAssert then(int[] actual) {
    return proxy(IntArrayAssert.class, int[].class, actual);
  }

  /**
   * Creates a new instance of {@link Int2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Int2DArrayAssert then(int[][] actual) {
    return proxy(Int2DArrayAssert.class, int[][].class, actual);
  }

  /**
   * Creates a new instance of {@link IntegerAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default IntegerAssert then(Integer actual) {
    return proxy(IntegerAssert.class, Integer.class, actual);
  }

  /**
   * Creates a new instance of {@link ListAssert}.
   *
   * @param <T> the type of elements.
   * @param actual the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <T> ProxyableListAssert<T> then(List<? extends T> actual) {
    return proxy(ProxyableListAssert.class, List.class, actual);
  }

  /**
   * Creates a new instance of {@link LongAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default LongAssert then(long actual) {
    return proxy(LongAssert.class, Long.class, actual);
  }

  /**
   * Creates a new instance of {@link LongAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default LongAssert then(Long actual) {
    return proxy(LongAssert.class, Long.class, actual);
  }

  /**
   * Creates a new instance of {@link LongArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default LongArrayAssert then(long[] actual) {
    return proxy(LongArrayAssert.class, long[].class, actual);
  }

  /**
   * Creates a new instance of {@link Long2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Long2DArrayAssert then(long[][] actual) {
    return proxy(Long2DArrayAssert.class, long[][].class, actual);
  }

  /**
   * Creates a new instance of {@link ObjectAssert}.
   *
   * @param actual the actual value.
   * @param <T> the type of the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <T> ProxyableObjectAssert<T> then(T actual) {
    return proxy(ProxyableObjectAssert.class, Object.class, actual);
  }

  /**
   * Creates a new instance of {@link ObjectArrayAssert}.
   *
   * @param <T> the type of elements.
   * @param actual the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <T> ProxyableObjectArrayAssert<T> then(T[] actual) {
    return proxy(ProxyableObjectArrayAssert.class, Object[].class, actual);
  }

  /**
   * Creates a new instance of {@link Object2DArrayAssert}.
   *
   * @param <T> the type of elements.
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  @SuppressWarnings("unchecked")
  default <T> Object2DArrayAssert<T> then(T[][] actual) {
    return proxy(Object2DArrayAssert.class, Object[][].class, actual);
  }

  /**
   * Creates a new instance of {@link MapAssert}.
   *

   * We don't return {@link MapAssert} as it has overridden methods to annotated with {@link SafeVarargs}.
   *
   * @param <K> the type of keys in the map.
   * @param <V> the type of values in the map.
   * @param actual the actual value.
   * @return the created assertion object.
   */
  @SuppressWarnings("unchecked")
  default <K, V> ProxyableMapAssert<K, V> then(Map<K, V> actual) {
    return proxy(ProxyableMapAssert.class, Map.class, actual);
  }

  /**
   * Creates a new instance of {@link ShortAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ShortAssert then(short actual) {
    return proxy(ShortAssert.class, Short.class, actual);
  }

  /**
   * Creates a new instance of {@link ShortAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ShortAssert then(Short actual) {
    return proxy(ShortAssert.class, Short.class, actual);
  }

  /**
   * Creates a new instance of {@link ShortArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default ShortArrayAssert then(short[] actual) {
    return proxy(ShortArrayAssert.class, short[].class, actual);
  }

  /**
   * Creates a new instance of {@link Short2DArrayAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.17.0
   */
  default Short2DArrayAssert then(short[][] actual) {
    return proxy(Short2DArrayAssert.class, short[][].class, actual);
  }

  /**
   * Creates a new instance of {@link CharSequenceAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default CharSequenceAssert then(CharSequence actual) {
    return proxy(CharSequenceAssert.class, CharSequence.class, actual);
  }

  /**
   * Creates a new instance of {@link CharSequenceAssert} from a {@link StringBuilder}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.11.0
   */
  default CharSequenceAssert then(StringBuilder actual) {
    return proxy(CharSequenceAssert.class, CharSequence.class, actual);
  }

  /**
   * Creates a new instance of {@link CharSequenceAssert} from a {@link StringBuffer}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.11.0
   */
  default CharSequenceAssert then(StringBuffer actual) {
    return proxy(CharSequenceAssert.class, CharSequence.class, actual);
  }

  /**
   * Creates a new instance of {@link StringAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default StringAssert then(String actual) {
    return proxy(StringAssert.class, String.class, actual);
  }

  /**
   * Creates a new instance of {@link DateAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default DateAssert then(Date actual) {
    return proxy(DateAssert.class, Date.class, actual);
  }

  /**
   * Create assertion for {@link AtomicBoolean}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  default AtomicBooleanAssert then(AtomicBoolean actual) {
    return proxy(AtomicBooleanAssert.class, AtomicBoolean.class, actual);
  }

  /**
   * Create assertion for {@link AtomicInteger}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  default AtomicIntegerAssert then(AtomicInteger actual) {
    return proxy(AtomicIntegerAssert.class, AtomicInteger.class, actual);
  }

  /**
   * Create assertion for {@link AtomicIntegerArray}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  default AtomicIntegerArrayAssert then(AtomicIntegerArray actual) {
    return proxy(AtomicIntegerArrayAssert.class, AtomicIntegerArray.class, actual);
  }

  /**
   * Create assertion for {@link AtomicIntegerFieldUpdater}.
   *
   * @param <OBJECT> The type of the object holding the updatable field
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> then(AtomicIntegerFieldUpdater<OBJECT> actual) {
    return proxy(AtomicIntegerFieldUpdaterAssert.class, AtomicIntegerFieldUpdater.class, actual);
  }

  /**
   * Create assertion for {@link AtomicLong}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  default AtomicLongAssert then(AtomicLong actual) {
    return proxy(AtomicLongAssert.class, AtomicLong.class, actual);
  }

  /**
   * Create assertion for {@link AtomicLongArray}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  default AtomicLongArrayAssert then(AtomicLongArray actual) {
    return proxy(AtomicLongArrayAssert.class, AtomicLongArray.class, actual);
  }

  /**
   * Create assertion for {@link AtomicLongFieldUpdater}.
   *
   * @param actual the actual value.
   * @param <OBJECT> the type of the object holding the updatable field
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> then(AtomicLongFieldUpdater<OBJECT> actual) {
    return proxy(AtomicLongFieldUpdaterAssert.class, AtomicLongFieldUpdater.class, actual);
  }

  /**
   * Create assertion for {@link AtomicReference}.
   *
   * @param actual the actual value.
   * @param <VALUE> the type of object referred to by this reference
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <VALUE> AtomicReferenceAssert<VALUE> then(AtomicReference<VALUE> actual) {
    return proxy(AtomicReferenceAssert.class, AtomicReference.class, actual);
  }

  /**
   * Create assertion for {@link AtomicReferenceArray}.
   *
   * @param actual the actual value.
   * @param <ELEMENT> the type of object referred to by the {@link AtomicReferenceArray}.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> then(AtomicReferenceArray<ELEMENT> actual) {
    return proxy(AtomicReferenceArrayAssert.class, AtomicReferenceArray.class, actual);
  }

  /**
   * Create assertion for {@link AtomicReferenceFieldUpdater}.
   *
   * @param <FIELD> The type of the field
   * @param <OBJECT> the type of the object holding the updatable field
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <FIELD, OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD, OBJECT> then(AtomicReferenceFieldUpdater<OBJECT, FIELD> actual) {
    return proxy(AtomicReferenceFieldUpdaterAssert.class, AtomicReferenceFieldUpdater.class, actual);
  }

  /**
   * Create assertion for {@link AtomicMarkableReference}.
   *
   * @param <VALUE> the type of object referred to by this reference
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <VALUE> AtomicMarkableReferenceAssert<VALUE> then(AtomicMarkableReference<VALUE> actual) {
    return proxy(AtomicMarkableReferenceAssert.class, AtomicMarkableReference.class, actual);
  }

  /**
   * Create assertion for {@link AtomicStampedReference}.
   *
   * @param <VALUE> the type of value referred to by this reference
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 2.7.0 / 3.7.0
   */
  @SuppressWarnings("unchecked")
  default <VALUE> AtomicStampedReferenceAssert<VALUE> then(AtomicStampedReference<VALUE> actual) {
    return proxy(AtomicStampedReferenceAssert.class, AtomicStampedReference.class, actual);
  }

  /**
   * Creates a new instance of {@link ThrowableAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion Throwable.
   */
  default ThrowableAssert then(Throwable actual) {
    return proxy(ThrowableAssert.class, Throwable.class, actual);
  }

  /**
   * Allows to capture and then assert on a {@link Throwable} more easily when used with Java 8 lambdas.
   *
   *

   * Java 8 example :
   *
 {@literal @}Test
   *  default void testException() {
   *    BDDSoftAssertions softly = new BDDSoftAssertions();
   *    softly.thenThrownBy(() -> { throw new Exception("boom!"); }).isInstanceOf(Exception.class)
   *                                                                .hasMessageContaining("boom");
   *  }

   *
   * Java 7 example :
   *
 BDDSoftAssertions softly = new BDDSoftAssertions();
   * softly.thenThrownBy(new ThrowingCallable() {
   *
   *   {@literal @}Override
   *   default Void call() throws Exception {
   *     throw new Exception("boom!");
   *   }
   *
   * }).isInstanceOf(Exception.class)
   *   .hasMessageContaining("boom");

   *
   * If the provided {@link ThrowingCallable} does not raise an exception, an error is immediately thrown,
   * in that case the test description provided with {@link AbstractAssert#as(String, Object...) as(String, Object...)} is not honored.

   * To use a test description, use {@link Assertions#catchThrowable(ThrowableAssert.ThrowingCallable)} as shown below:
   *
 // assertion will fail but "display me" won't appear in the error
   * softly.thenThrownBy(() -> {}).as("display me")
   *                              .isInstanceOf(Exception.class);
   *
   * // assertion will fail AND "display me" will appear in the error
   * Throwable thrown = catchThrowable(() -> {});
   * softly.then(thrown).as("display me")
   *                    .isInstanceOf(Exception.class);

   *
   * Alternatively you can also use {@code thenCode(ThrowingCallable)} for the test description provided
   * with {@link AbstractAssert#as(String, Object...) as(String, Object...)} to always be honored.
   *
   * @param shouldRaiseThrowable The {@link ThrowingCallable} or lambda with the code that should raise the throwable.
   * @return The captured exception or null if none was raised by the callable.
   */
  @CanIgnoreReturnValue
  default AbstractThrowableAssert<?, ? extends Throwable> thenThrownBy(ThrowingCallable shouldRaiseThrowable) {
    return then(catchThrowable(shouldRaiseThrowable)).hasBeenThrown();
  }

  /**
   * Allows to capture and then assert on a {@link Throwable} like {@code thenThrownBy(ThrowingCallable)} but this method
   * let you set the assertion description the same way you do with {@link AbstractAssert#as(String, Object...) as(String, Object...)}.
   *

   * Example:
   *
 {@literal @}Test
   *  default void testException() {
   *    BDDSoftAssertions softly = new BDDSoftAssertions();
   *    // if this assertion failed (but it doesn't), the error message would start with [Test explosive code]
   *    softly.thenThrownBy(() -> { throw new IOException("boom!") }, "Test explosive code")
   *             .isInstanceOf(IOException.class)
   *             .hasMessageContaining("boom");
   * }

   *
   * If the provided {@link ThrowingCallable ThrowingCallable} does not raise an exception, an error is immediately thrown.
   *

   * The test description provided is honored but not the one with {@link AbstractAssert#as(String, Object...) as(String, Object...)}, example:
   *
 // assertion will fail but "display me" won't appear in the error message
   * softly.thenThrownBy(() -> {}).as("display me")
   *                              .isInstanceOf(Exception.class);
   *
   * // assertion will fail AND "display me" will appear in the error message
   * softly.thenThrownBy(() -> {}, "display me")
   *                               .isInstanceOf(Exception.class);

   *
   * @param shouldRaiseThrowable The {@link ThrowingCallable} or lambda with the code that should raise the throwable.
   * @param description the new description to set.
   * @param args optional parameter if description is a format String.
   *
   * @return the created {@link ThrowableAssert}.
   *
   * @since 3.9.0
   */
  @CanIgnoreReturnValue
  default AbstractThrowableAssert<?, ? extends Throwable> thenThrownBy(ThrowingCallable shouldRaiseThrowable,
                                                                       String description, Object... args) {
    return then(catchThrowable(shouldRaiseThrowable)).as(description, args).hasBeenThrown();
  }

  /**
   * Allows to capture and then assert on a {@link Throwable} more easily when used with Java 8 lambdas.
   *
   *

   * Example :
   *

   *
   *
 ThrowingCallable callable = () -> {
   *   throw new Exception("boom!");
   * };
   *
   * // assertion succeeds
   * thenCode(callable).isInstanceOf(Exception.class)
   *                   .hasMessageContaining("boom");
   *
   * // assertion fails
   * thenCode(callable).doesNotThrowAnyException();

   *
   * Contrary to {@code thenThrownBy(ThrowingCallable)} the test description provided with
   * {@link AbstractAssert#as(String, Object...) as(String, Object...)} is always honored as shown below.
   *
   *
 ThrowingCallable doNothing = () -> {
   *   // do nothing
   * };
   *
   * // assertion fails and "display me" appears in the assertion error
   * thenCode(doNothing).as("display me")
   *                    .isInstanceOf(Exception.class);

   *

   * This method was not named {@code then} because the java compiler reported it ambiguous when used directly with a lambda :(
   *
   * @param shouldRaiseOrNotThrowable The {@link ThrowingCallable} or lambda with the code that should raise the throwable.
   * @return The captured exception or null if none was raised by the callable.
   * @since 3.7.0
   */
  default AbstractThrowableAssert<?, ? extends Throwable> thenCode(ThrowingCallable shouldRaiseOrNotThrowable) {
    return then(catchThrowable(shouldRaiseOrNotThrowable));
  }

  /**
   * Creates a new instance of {@link org.assertj.core.api.ObjectAssert} for any object.
   *
   *

   * This overload is useful, when an overloaded method of then(...) takes precedence over the generic {@link #then(Object)}.
   *

   *
   *

   * Example:
   *

   *
   * Cast necessary because {@link #then(List)} "forgets" actual type:
   *
{@code then(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc")); }

   * No cast needed, but also no additional list assertions:
   *
{@code thenObject(new LinkedList<>(asList("abc"))).matches(list -> list.getFirst().equals("abc")); }

   *
   * @param <T> the type of the actual value.
   * @param actual the actual value.
   * @return the created assertion object.
   * @since 3.12.0
   */
  default <T> ProxyableObjectAssert<T> thenObject(T actual) {
    return then(actual);
  }

  /**
   * Creates a new instance of {@link UriAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default UriAssert then(URI actual) {
    return proxy(UriAssert.class, URI.class, actual);
  }

  /**
   * Creates a new instance of {@link UrlAssert}.
   *
   * @param actual the actual value.
   * @return the created assertion object.
   */
  default AbstractUrlAssert<?> then(URL actual) {
    return proxy(UrlAssert.class, URL.class, actual);
  }

}


text:
#include "config.h"

#include "threads.h"

#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include "uintmap.h"

extern inline althrd_t althrd_current(void);
extern inline int althrd_equal(althrd_t thr0, althrd_t thr1);
extern inline void althrd_exit(int res);
extern inline void althrd_yield(void);

extern inline int almtx_lock(almtx_t *mtx);
extern inline int almtx_unlock(almtx_t *mtx);
extern inline int almtx_trylock(almtx_t *mtx);

extern inline void *altss_get(altss_t tss_id);
extern inline int altss_set(altss_t tss_id, void *val);

#ifndef UNUSED
#if defined(__cplusplus)
#define UNUSED(x)
#elif defined(__GNUC__)
#define UNUSED(x) UNUSED_##x __attribute__((unused))
#elif defined(__LCLINT__)
#define UNUSED(x) /*@unused@*/ x
#else
#define UNUSED(x) x
#endif
#endif

#define THREAD_STACK_SIZE (2*1024*1024) /* 2MB */

#ifdef _WIN32

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>

void althrd_setname(althrd_t thr, const char *name)
{
#if defined(_MSC_VER)
#define MS_VC_EXCEPTION 0x406D1388
#pragma pack(push,8)
    struct {
        DWORD dwType;     // Must be 0x1000.
        LPCSTR szName;    // Pointer to name (in user addr space).
        DWORD dwThreadID; // Thread ID (-1=caller thread).
        DWORD dwFlags;    // Reserved for future use, must be zero.
    } info;
#pragma pack(pop)
    info.dwType = 0x1000;
    info.szName = name;
    info.dwThreadID = thr;
    info.dwFlags = 0;

    __try {
        RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
    }
    __except(EXCEPTION_CONTINUE_EXECUTION) {
    }
#undef MS_VC_EXCEPTION
#else
    (void)thr;
    (void)name;
#endif
}

static UIntMap ThrdIdHandle = UINTMAP_STATIC_INITIALIZE;

static void NTAPI althrd_callback(void* UNUSED(handle), DWORD reason, void* UNUSED(reserved))
{
    if(reason == DLL_PROCESS_DETACH)
        ResetUIntMap(&ThrdIdHandle);
}
#ifdef _MSC_VER
#pragma section(".CRT$XLC",read)
__declspec(allocate(".CRT$XLC")) PIMAGE_TLS_CALLBACK althrd_callback_ = althrd_callback;
#elif defined(__GNUC__)
PIMAGE_TLS_CALLBACK althrd_callback_ __attribute__((section(".CRT$XLC"))) = althrd_callback;
#else
PIMAGE_TLS_CALLBACK althrd_callback_ = althrd_callback;
#endif

typedef struct thread_cntr {
    althrd_start_t func;
    void *arg;
} thread_cntr;

static DWORD WINAPI althrd_starter(void *arg)
{
    thread_cntr cntr;
    memcpy(&cntr, arg, sizeof(cntr));
    free(arg);

    return (DWORD)((*cntr.func)(cntr.arg));
}

int althrd_create(althrd_t *thr, althrd_start_t func, void *arg)
{
    thread_cntr *cntr;
    DWORD thrid;
    HANDLE hdl;

    cntr = malloc(sizeof(*cntr));
    if(!cntr) return althrd_nomem;

    cntr->func = func;
    cntr->arg = arg;

    hdl = CreateThread(NULL, THREAD_STACK_SIZE, althrd_starter, cntr, 0, &thrid);
    if(!hdl)
    {
        free(cntr);
        return althrd_error;
    }
    InsertUIntMapEntry(&ThrdIdHandle, thrid, hdl);

    *thr = thrid;
    return althrd_success;
}

int althrd_detach(althrd_t thr)
{
    HANDLE hdl = RemoveUIntMapKey(&ThrdIdHandle, thr);
    if(!hdl) return althrd_error;

    CloseHandle(hdl);
    return althrd_success;
}

int althrd_join(althrd_t thr, int *res)
{
    DWORD code;

    HANDLE hdl = RemoveUIntMapKey(&ThrdIdHandle, thr);
    if(!hdl) return althrd_error;

    WaitForSingleObject(hdl, INFINITE);
    GetExitCodeThread(hdl, &code);
    CloseHandle(hdl);

    if(res != NULL)
        *res = (int)code;
    return althrd_success;
}

int althrd_sleep(const struct timespec *ts, struct timespec* UNUSED(rem))
{
    DWORD msec;

    if(ts->tv_sec < 0 || ts->tv_sec >= (0x7fffffff / 1000) ||
       ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
        return -2;

    msec  = (DWORD)(ts->tv_sec * 1000);
    msec += (DWORD)((ts->tv_nsec+999999) / 1000000);
    Sleep(msec);

    return 0;
}

int almtx_init(almtx_t *mtx, int type)
{
    if(!mtx) return althrd_error;

    type &= ~almtx_recursive;
    if(type != almtx_plain)
        return althrd_error;

    InitializeCriticalSection(mtx);
    return althrd_success;
}

void almtx_destroy(almtx_t *mtx)
{
    DeleteCriticalSection(mtx);
}

int almtx_timedlock(almtx_t* UNUSED(mtx), const struct timespec* UNUSED(ts))
{
    /* Windows CRITICAL_SECTIONs don't seem to have a timedlock method. */
    return althrd_error;
}

#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
int alcnd_init(alcnd_t *cond)
{
    InitializeConditionVariable(cond);
    return althrd_success;
}

int alcnd_signal(alcnd_t *cond)
{
    WakeConditionVariable(cond);
    return althrd_success;
}

int alcnd_broadcast(alcnd_t *cond)
{
    WakeAllConditionVariable(cond);
    return althrd_success;
}

int alcnd_wait(alcnd_t *cond, almtx_t *mtx)
{
    if(SleepConditionVariableCS(cond, mtx, INFINITE) != 0)
        return althrd_success;
    return althrd_error;
}

int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point)
{
    struct timespec curtime;
    DWORD sleeptime;

    if(altimespec_get(&curtime, AL_TIME_UTC) != AL_TIME_UTC)
        return althrd_error;

    if(curtime.tv_sec > time_point->tv_sec || (curtime.tv_sec == time_point->tv_sec &&
                                               curtime.tv_nsec >= time_point->tv_nsec))
    {
        if(SleepConditionVariableCS(cond, mtx, 0) != 0)
            return althrd_success;
    }
    else
    {
        sleeptime  = (time_point->tv_nsec - curtime.tv_nsec + 999999)/1000000;
        sleeptime += (DWORD)(time_point->tv_sec - curtime.tv_sec)*1000;
        if(SleepConditionVariableCS(cond, mtx, sleeptime) != 0)
            return althrd_success;
    }
    return (GetLastError()==ERROR_TIMEOUT) ? althrd_timedout : althrd_error;
}

void alcnd_destroy(alcnd_t* UNUSED(cond))
{
    /* Nothing to delete? */
}

#else

/* WARNING: This is a rather poor implementation of condition variables, with
 * known problems. However, it's simple, efficient, and good enough for now to
 * not require Vista. Based on "Strategies for Implementing POSIX Condition
 * Variables" by Douglas C. Schmidt and Irfan Pyarali:
 * http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
 */
/* A better solution may be using Wine's implementation. It requires internals
 * (NtCreateKeyedEvent, NtReleaseKeyedEvent, and NtWaitForKeyedEvent) from
 * ntdll, and implemention of exchange and compare-exchange for RefCounts.
 */

typedef struct {
    RefCount wait_count;

    HANDLE events[2];
} _int_alcnd_t;
enum {
    SIGNAL = 0,
    BROADCAST = 1
};

int alcnd_init(alcnd_t *cond)
{
    _int_alcnd_t *icond = calloc(1, sizeof(*icond));
    if(!icond) return althrd_nomem;

    InitRef(&icond->wait_count, 0);

    icond->events[SIGNAL] = CreateEventW(NULL, FALSE, FALSE, NULL);
    icond->events[BROADCAST] = CreateEventW(NULL, TRUE, FALSE, NULL);
    if(!icond->events[SIGNAL] || !icond->events[BROADCAST])
    {
        if(icond->events[SIGNAL])
            CloseHandle(icond->events[SIGNAL]);
        if(icond->events[BROADCAST])
            CloseHandle(icond->events[BROADCAST]);
        free(icond);
        return althrd_error;
    }

    cond->Ptr = icond;
    return althrd_success;
}

int alcnd_signal(alcnd_t *cond)
{
    _int_alcnd_t *icond = cond->Ptr;
    if(ReadRef(&icond->wait_count) > 0)
        SetEvent(icond->events[SIGNAL]);
    return althrd_success;
}

int alcnd_broadcast(alcnd_t *cond)
{
    _int_alcnd_t *icond = cond->Ptr;
    if(ReadRef(&icond->wait_count) > 0)
        SetEvent(icond->events[BROADCAST]);
    return althrd_success;
}

int alcnd_wait(alcnd_t *cond, almtx_t *mtx)
{
    _int_alcnd_t *icond = cond->Ptr;
    int res;

    IncrementRef(&icond->wait_count);
    LeaveCriticalSection(mtx);

    res = WaitForMultipleObjects(2, icond->events, FALSE, INFINITE);

    if(DecrementRef(&icond->wait_count) == 0 && res == WAIT_OBJECT_0+BROADCAST)
        ResetEvent(icond->events[BROADCAST]);
    EnterCriticalSection(mtx);

    return althrd_success;
}

int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point)
{
    _int_alcnd_t *icond = cond->Ptr;
    struct timespec curtime;
    DWORD sleeptime;
    int res;

    if(altimespec_get(&curtime, AL_TIME_UTC) != AL_TIME_UTC)
        return althrd_error;

    if(curtime.tv_sec > time_point->tv_sec || (curtime.tv_sec == time_point->tv_sec &&
                                               curtime.tv_nsec >= time_point->tv_nsec))
        sleeptime = 0;
    else
    {
        sleeptime  = (time_point->tv_nsec - curtime.tv_nsec + 999999)/1000000;
        sleeptime += (DWORD)(time_point->tv_sec - curtime.tv_sec)*1000;
    }

    IncrementRef(&icond->wait_count);
    LeaveCriticalSection(mtx);

    res = WaitForMultipleObjects(2, icond->events, FALSE, sleeptime);

    if(DecrementRef(&icond->wait_count) == 0 && res == WAIT_OBJECT_0+BROADCAST)
        ResetEvent(icond->events[BROADCAST]);
    EnterCriticalSection(mtx);

    return (res == WAIT_TIMEOUT) ? althrd_timedout : althrd_success;
}

void alcnd_destroy(alcnd_t *cond)
{
    _int_alcnd_t *icond = cond->Ptr;
    CloseHandle(icond->events[SIGNAL]);
    CloseHandle(icond->events[BROADCAST]);
    free(icond);
}
#endif /* defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 */

/* An associative map of uint:void* pairs. The key is the TLS index (given by
 * TlsAlloc), and the value is the altss_dtor_t callback. When a thread exits,
 * we iterate over the TLS indices for their thread-local value and call the
 * destructor function with it if they're both not NULL. To avoid using
 * DllMain, a PIMAGE_TLS_CALLBACK function pointer is placed in a ".CRT$XLx"
 * section (where x is a character A to Z) which will be called by the CRT.
 */
static UIntMap TlsDestructors = UINTMAP_STATIC_INITIALIZE;

static void NTAPI altss_callback(void* UNUSED(handle), DWORD reason, void* UNUSED(reserved))
{
    ALsizei i;

    if(reason == DLL_PROCESS_DETACH)
    {
        ResetUIntMap(&TlsDestructors);
        return;
    }
    if(reason != DLL_THREAD_DETACH)
        return;

    LockUIntMapRead(&TlsDestructors);
    for(i = 0;i < TlsDestructors.size;i++)
    {
        void *ptr = altss_get(TlsDestructors.keys[i]);
        altss_dtor_t callback = (altss_dtor_t)TlsDestructors.values[i];
        if(ptr && callback)
            callback(ptr);
    }
    UnlockUIntMapRead(&TlsDestructors);
}
#ifdef _MSC_VER
#pragma section(".CRT$XLB",read)
__declspec(allocate(".CRT$XLB")) PIMAGE_TLS_CALLBACK altss_callback_ = altss_callback;
#elif defined(__GNUC__)
PIMAGE_TLS_CALLBACK altss_callback_ __attribute__((section(".CRT$XLB"))) = altss_callback;
#else
#warning "No TLS callback support, thread-local contexts may leak references on poorly written applications."
PIMAGE_TLS_CALLBACK altss_callback_ = altss_callback;
#endif

int altss_create(altss_t *tss_id, altss_dtor_t callback)
{
    DWORD key = TlsAlloc();
    if(key == TLS_OUT_OF_INDEXES)
        return althrd_error;

    *tss_id = key;
    if(callback != NULL)
        InsertUIntMapEntry(&TlsDestructors, key, callback);
    return althrd_success;
}

void altss_delete(altss_t tss_id)
{
    RemoveUIntMapKey(&TlsDestructors, tss_id);
    TlsFree(tss_id);
}

int altimespec_get(struct timespec *ts, int base)
{
    static_assert(sizeof(FILETIME) == sizeof(ULARGE_INTEGER),
                  "Size of FILETIME does not match ULARGE_INTEGER");
    if(base == AL_TIME_UTC)
    {
        union {
            FILETIME ftime;
            ULARGE_INTEGER ulint;
        } systime;
        GetSystemTimeAsFileTime(&systime.ftime);
        /* FILETIME is in 100-nanosecond units, or 1/10th of a microsecond. */
        ts->tv_sec = systime.ulint.QuadPart/10000000;
        ts->tv_nsec = (systime.ulint.QuadPart%10000000) * 100;
        return base;
    }

    return 0;
}

void alcall_once(alonce_flag *once, void (*callback)(void))
{
    LONG ret;
    while((ret=InterlockedExchange(once, 1)) == 1)
        althrd_yield();
    if(ret == 0)
        (*callback)();
    InterlockedExchange(once, 2);
}

#else

#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif

extern inline int althrd_sleep(const struct timespec *ts, struct timespec *rem);
extern inline void alcall_once(alonce_flag *once, void (*callback)(void));

void althrd_setname(althrd_t thr, const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP)
#if defined(PTHREAD_SETNAME_NP_ONE_PARAM)
    if(althrd_equal(thr, althrd_current()))
        pthread_setname_np(name);
#elif defined(PTHREAD_SETNAME_NP_THREE_PARAMS)
    pthread_setname_np(thr, "%s", (void*)name);
#else
    pthread_setname_np(thr, name);
#endif
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
    pthread_set_name_np(thr, name);
#else
    (void)thr;
    (void)name;
#endif
}

typedef struct thread_cntr {
    althrd_start_t func;
    void *arg;
} thread_cntr;

static void *althrd_starter(void *arg)
{
    thread_cntr cntr;
    memcpy(&cntr, arg, sizeof(cntr));
    free(arg);

    return (void*)(intptr_t)((*cntr.func)(cntr.arg));
}

int althrd_create(althrd_t *thr, althrd_start_t func, void *arg)
{
    thread_cntr *cntr;
    pthread_attr_t attr;
    size_t stackmult = 1;
    int err;

    cntr = malloc(sizeof(*cntr));
    if(!cntr) return althrd_nomem;

    if(pthread_attr_init(&attr) != 0)
    {
        free(cntr);
        return althrd_error;
    }
retry_stacksize:
    if(pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE*stackmult) != 0)
    {
        pthread_attr_destroy(&attr);
        free(cntr);
        return althrd_error;
    }

    cntr->func = func;
    cntr->arg = arg;
    if((err=pthread_create(thr, &attr, althrd_starter, cntr)) == 0)
    {
        pthread_attr_destroy(&attr);
        return althrd_success;
    }

    if(err == EINVAL)
    {
        /* If an invalid stack size, try increasing it (limit x4, 8MB). */
        if(stackmult < 4)
        {
            stackmult *= 2;
            goto retry_stacksize;
        }
        /* If still nothing, try defaults and hope they're good enough. */
        if(pthread_create(thr, NULL, althrd_starter, cntr) == 0)
        {
            pthread_attr_destroy(&attr);
            return althrd_success;
        }
    }
    pthread_attr_destroy(&attr);
    free(cntr);
    return althrd_error;
}

int althrd_detach(althrd_t thr)
{
    if(pthread_detach(thr) != 0)
        return althrd_error;
    return althrd_success;
}

int althrd_join(althrd_t thr, int *res)
{
    void *code;

    if(pthread_join(thr, &code) != 0)
        return althrd_error;
    if(res != NULL)
        *res = (int)(intptr_t)code;
    return althrd_success;
}

int almtx_init(almtx_t *mtx, int type)
{
    int ret;

    if(!mtx) return althrd_error;
#ifdef HAVE_PTHREAD_MUTEX_TIMEDLOCK
    if((type&~(almtx_recursive|almtx_timed)) != 0)
        return althrd_error;
#else
    if((type&~almtx_recursive) != 0)
        return althrd_error;
#endif

    type &= ~almtx_timed;
    if(type == almtx_plain)
        ret = pthread_mutex_init(mtx, NULL);
    else
    {
        pthread_mutexattr_t attr;

        ret = pthread_mutexattr_init(&attr);
        if(ret) return althrd_error;

        if(type == almtx_recursive)
        {
            ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#ifdef HAVE_PTHREAD_MUTEXATTR_SETKIND_NP
            if(ret != 0)
                ret = pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE);
#endif
        }
        else
            ret = 1;
        if(ret == 0)
            ret = pthread_mutex_init(mtx, &attr);
        pthread_mutexattr_destroy(&attr);
    }
    return ret ? althrd_error : althrd_success;
}

void almtx_destroy(almtx_t *mtx)
{
    pthread_mutex_destroy(mtx);
}

int almtx_timedlock(almtx_t *mtx, const struct timespec *ts)
{
    return althrd_error;
}

int alcnd_init(alcnd_t *cond)
{
    if(pthread_cond_init(cond, NULL) == 0)
        return althrd_success;
    return althrd_error;
}

int alcnd_signal(alcnd_t *cond)
{
    if(pthread_cond_signal(cond) == 0)
        return althrd_success;
    return althrd_error;
}

int alcnd_broadcast(alcnd_t *cond)
{
    if(pthread_cond_broadcast(cond) == 0)
        return althrd_success;
    return althrd_error;
}

int alcnd_wait(alcnd_t *cond, almtx_t *mtx)
{
    if(pthread_cond_wait(cond, mtx) == 0)
        return althrd_success;
    return althrd_error;
}

int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point)
{
    if(pthread_cond_timedwait(cond, mtx, time_point) == 0)
        return althrd_success;
    return althrd_error;
}

void alcnd_destroy(alcnd_t *cond)
{
    pthread_cond_destroy(cond);
}

int altss_create(altss_t *tss_id, altss_dtor_t callback)
{
    if(pthread_key_create(tss_id, callback) != 0)
        return althrd_error;
    return althrd_success;
}

void altss_delete(altss_t tss_id)
{
    pthread_key_delete(tss_id);
}

int altimespec_get(struct timespec *ts, int base)
{
    if(base == AL_TIME_UTC)
    {
        int ret;
#if _POSIX_TIMERS > 0
        ret = clock_gettime(CLOCK_REALTIME, ts);
        if(ret == 0) return base;
#else /* _POSIX_TIMERS > 0 */
        struct timeval tv;
        ret = gettimeofday(&tv, NULL);
        if(ret == 0)
        {
            ts->tv_sec = tv.tv_sec;
            ts->tv_nsec = tv.tv_usec * 1000;
            return base;
        }
#endif
    }

    return 0;
}

#endif

void al_nssleep(unsigned long nsec)
{
    struct timespec ts, rem;
    ts.tv_sec = nsec / 1000000000ul;
    ts.tv_nsec = nsec % 1000000000ul;

    while(althrd_sleep(&ts, &rem) == -1)
        ts = rem;
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.taverna.workbench.ui.impl.configuration.colour;

import static java.awt.Color.WHITE;
import static java.awt.Color.decode;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import org.apache.taverna.configuration.AbstractConfigurable;
import org.apache.taverna.configuration.ConfigurationManager;

import org.apache.taverna.workbench.configuration.colour.ColourManager;

/**
 * A factory class that determines the colour that a Colourable UI component
 * should be displayed as, according to a schema configured by the user.
 *
 * @author Stuart Owen
 * @author Ian Dunlop
 * @see Colourable
 */
public class ColourManagerImpl extends AbstractConfigurable implements
		ColourManager {
	// Names of things that may be coloured
	private static final String WORKFLOW_PORT_OBJECT = "org.apache.taverna.scufl2.api.port.WorkflowPort";
	private static final String PROCESSOR_PORT_OBJECT = "org.apache.taverna.scufl2.api.port.ProcessorPort";
	private static final String PROCESSOR_OBJECT = "org.apache.taverna.scufl2.api.core.Processor";
	private static final String MERGE_OBJECT = "org.apache.taverna.workflowmodel.Merge";
	private static final String NONEXECUTABLE_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/nonExecutable";
	private static final String XML_SPLITTER_OUT_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/xml-splitter/out";
	private static final String XML_SPLITTER_IN_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/xml-splitter/in";
	private static final String LOCALWORKER_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/localworker";
	private static final String WSDL_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/wsdl";
	private static final String CONSTANT_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/constant";
	private static final String SOAPLAB_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/soaplab";
	private static final String RSHELL_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/rshell";
	private static final String NESTED_WORKFLOW = "http://ns.taverna.org.uk/2010/activity/nested-workflow";
	private static final String MOBY_PARSER_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomoby/parser";
	private static final String MOBY_OBJECT_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomoby/object";
	private static final String MOBY_SERVICE_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomoby/service";
	private static final String BIOMART_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/biomart";
	private static final String BEANSHELL_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/beanshell";
	private static final String APICONSUMER_ACTIVITY = "http://ns.taverna.org.uk/2010/activity/apiconsumer";

	// Names of colours used
	private static final String burlywood2 = "#deb887";
	private static final String darkgoldenrod1 = "#ffb90f";
	private static final String darkolivegreen3 = "#a2cd5a";
	private static final String gold = "#ffd700";
	private static final String grey = "#777777";
	private static final String lightcyan2 = "#d1eeee";
	private static final String lightgoldenrodyellow = "#fafad2";
	// light purple non standard
	private static final String lightpurple = "#ab92ea";
	private static final String lightsteelblue = "#b0c4de";
	private static final String mediumorchid2 = "#d15fee";
	private static final String palegreen = "#98fb98";
	private static final String pink = "#ffc0cb";
	private static final String purplish = "#8070ff";
	// ShadedLabel.Orange
	private static final String shadedorange = "#eece8f";
	// ShadedLabel.Green
	private static final String shadedgreen = "#a1c69d";
	// slightly lighter than the real steelblue4
	private static final String steelblue4 = "#648faa";
	private static final String turquoise = "#77aadd";
	private static final String white = "#ffffff";

	private Map<String, String> defaultPropertyMap;
	private Map<Object, Color> cachedColours;

	public ColourManagerImpl(ConfigurationManager configurationManager) {
		super(configurationManager);
		initialiseDefaults();
	}

	@Override
	public String getCategory() {
		return "colour";
	}

	@Override
	public Map<String, String> getDefaultPropertyMap() {
		if (defaultPropertyMap == null)
			initialiseDefaults();
		return defaultPropertyMap;
	}

	@Override
	public String getDisplayName() {
		return "Colour Management";
	}

	@Override
	public String getFilePrefix() {
		return "ColourManagement";
	}

	/**
	 * Unique identifier for this ColourManager
	 */
	@Override
	public String getUUID() {
		return "a2148420-5967-11dd-ae16-0800200c9a66";
	}

	private void initialiseDefaults() {
		defaultPropertyMap = new HashMap<>();
		cachedColours = new HashMap<>();

		defaultPropertyMap.put(APICONSUMER_ACTIVITY, palegreen);
		defaultPropertyMap.put(BEANSHELL_ACTIVITY, burlywood2);
		defaultPropertyMap.put(BIOMART_ACTIVITY, lightcyan2);
		defaultPropertyMap.put(CONSTANT_ACTIVITY, lightsteelblue);
		defaultPropertyMap.put(LOCALWORKER_ACTIVITY, mediumorchid2);
		defaultPropertyMap.put(MOBY_SERVICE_ACTIVITY, darkgoldenrod1);
		defaultPropertyMap.put(MOBY_OBJECT_ACTIVITY, gold);
		defaultPropertyMap.put(MOBY_PARSER_ACTIVITY, white);
		defaultPropertyMap.put(NESTED_WORKFLOW, pink);
		defaultPropertyMap.put(RSHELL_ACTIVITY, steelblue4);
		defaultPropertyMap.put(SOAPLAB_ACTIVITY, lightgoldenrodyellow);
		defaultPropertyMap.put(WSDL_ACTIVITY, darkolivegreen3);
		defaultPropertyMap.put(XML_SPLITTER_IN_ACTIVITY, lightpurple);
		defaultPropertyMap.put(XML_SPLITTER_OUT_ACTIVITY, lightpurple);

		defaultPropertyMap.put(NONEXECUTABLE_ACTIVITY, grey);

		defaultPropertyMap.put(MERGE_OBJECT, turquoise);
		defaultPropertyMap.put(PROCESSOR_OBJECT, shadedgreen);
		defaultPropertyMap.put(PROCESSOR_PORT_OBJECT, purplish);
		defaultPropertyMap.put(WORKFLOW_PORT_OBJECT, shadedorange);
	}

	@Override
	public Color getPreferredColour(String itemKey) {
		Color colour = cachedColours.get(itemKey);
		if (colour == null) {
			String colourString = (String) getProperty(itemKey);
			colour = colourString == null ? WHITE : decode(colourString);
			cachedColours.put(itemKey, colour);
		}
		return colour;
	}

	@Override
	public void setPreferredColour(String itemKey, Color colour) {
		cachedColours.put(itemKey, colour);
	}

	@Override
	public void restoreDefaults() {
		super.restoreDefaults();
		if (cachedColours == null)
			cachedColours = new HashMap<>();
		else
			cachedColours.clear();
	}
}


text:
package org.apache.tinkerpop.gremlin.process.computer;

import org.apache.tinkerpop.gremlin.process.computer.util.MemoryHelper;

import java.io.Serializable;
import java.util.function.BinaryOperator;

/**
 * A {@code MemoryComputeKey} specifies what keys will be used by a {@link Memory} during a {@link GraphComputer} computation.
 * A MemoryComputeKey maintains a {@link BinaryOperator} which specifies how to reduce parallel values into a single value.
 * A MemoryComputeKey can be broadcasted and as such, the workers will receive mutations to the {@link Memory} value.
 * A MemoryComputeKey can be transient and thus, will not be accessible once the {@link GraphComputer} computation is complete.
 *
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public final class MemoryComputeKey<A> implements Serializable {

    private final String key;
    private final BinaryOperator<A> reducer;
    private final boolean isTransient;
    private final boolean isBroadcast;

    private MemoryComputeKey(final String key, final BinaryOperator<A> reducer, final boolean isBroadcast, final boolean isTransient) {
        this.key = key;
        this.reducer = reducer;
        this.isTransient = isTransient;
        this.isBroadcast = isBroadcast;
        MemoryHelper.validateKey(key);
    }

    public String getKey() {
        return this.key;
    }

    public boolean isTransient() {
        return this.isTransient;
    }

    public boolean isBroadcast() {
        return this.isBroadcast;
    }

    public BinaryOperator<A> getReducer() {
        return this.reducer;
    }

    @Override
    public int hashCode() {
        return this.key.hashCode();
    }

    @Override
    public boolean equals(final Object object) {
        return object instanceof MemoryComputeKey && ((MemoryComputeKey) object).key.equals(this.key);
    }

    public static <A> MemoryComputeKey of(final String key, final BinaryOperator<A> reducer, final boolean isBroadcast, final boolean isTransient) {
        return new MemoryComputeKey<>(key, reducer, isBroadcast, isTransient);
    }
}


text:
{include file="header.html"}

{$lang.integrate_successed}

            <input type="button" class="button" value="{$lang.frontend}" onclick="window.location.href='{$site_url}'" />
            <input type="button" class="button" value="{$lang.backend}" onclick="window.location.href='{$site_url}/admin'" />

{include file="footer.html"}


text:
/* global gon, createSelect2, createTagSelect, processResults, queryTransform */
var galleryIds, oldTemplate;
var galleryGroupIds = [];
var galleryGroups = {};
var characterIconsBox;

$(document).ready(function() {
  characterIconsBox = $('#character-icon-selector .character-galleries-simple');
  gon.gallery_groups.forEach(function(galleryGroup) {
    galleryGroups[galleryGroup.id] = galleryGroup;
  });
  galleryIds = $("#character_ungrouped_gallery_ids").val() || [];
  galleryGroupIds = $("#character_gallery_group_ids").val() || [];

  createSelect2("#character_setting_ids", {
    minimumResultsForSearch: 10,
    placeholder: 'Setting',
    tags: true
  });

  createSelect2("#character_ungrouped_gallery_ids", {
    minimumResultsForSearch: 10,
    placeholder: 'Default Gallery'
  });

  bindIcons();

  oldTemplate = $("#character_template_id").val();
  $("#new_template").change(function() {
    $("#character_template_attributes_name").val('');
    $("#character_template_attributes_id").val('');

    if ($("#new_template").is(":checked")) {
      $("#create_template").show();
      oldTemplate = $("#character_template_id").val();
      $("#character_template_id").attr("disabled", true).val('').trigger("change.select2");
    } else {
      $("#create_template").hide();
      $("#character_template_id").attr("disabled", false).val(oldTemplate).trigger("change.select2");
    }
  });

  $("#character_template_id").change(function() {
    $("#character_template_attributes_id").val('');
    $("#character_template_attributes_name").val('');
  });

  $("#character_ungrouped_gallery_ids").change(function() {
    $("#character_default_icon_id").val('');

    var newGalleryIds = $(this).val() || [];

    // a gallery was removed
    if (galleryIds.length > newGalleryIds.length) {
      var removedGallery = $(galleryIds).not(newGalleryIds).get(0);
      galleryIds = newGalleryIds;
      if (findGalleryInGroups(removedGallery)) return;
      characterIconsBox.find("#gallery"+removedGallery).remove();

      // if no more galleries are left, display galleryless icons
      if (characterIconsBox.find("[id^='gallery']").length === 0) {
        displayGallery('0');
      }
      return;
    }

    var newId = $(newGalleryIds).not(galleryIds).get(0);
    galleryIds = newGalleryIds;
    characterIconsBox.find("#gallery0").remove();

    // display only if not visible (for gallery groups)
    if (characterIconsBox.find("#gallery" + newId).length === 0) displayGallery(newId);
  });

  $("#character_gallery_group_ids").change(function() {
    $("#character_default_icon_id").val('');

    var newGalleryGroupIds = $(this).val() || [];

    // a gallery group was removed
    if (galleryGroupIds.length > newGalleryGroupIds.length) {
      var removedGroup = $(galleryGroupIds).not(newGalleryGroupIds).get(0);
      galleryGroupIds = newGalleryGroupIds;
      if (removedGroup.substring(0, 1) === '_') return; // skip uncreated tags

      var group = galleryGroups[parseInt(removedGroup)];
      delete galleryGroups[parseInt(removedGroup)];

      // delete unfound galleries from icons list
      group.gallery_ids.forEach(function(galleryId) {
        if (findGalleryInGroups(galleryId) || galleryIds.indexOf(galleryId.toString()) >= 0) return;
        characterIconsBox.find("#gallery" + galleryId).remove();
        galleryIds = $.makeArray($(galleryIds).not([galleryId.toString()]));
      });

      // if no more galleries remain, display galleryless icons
      if (characterIconsBox.find("[id^='gallery']").length === 0) {
        displayGallery('0');
      }
      return;
    }

    var newId = $(newGalleryGroupIds).not(galleryGroupIds).get(0);
    galleryGroupIds = newGalleryGroupIds;
    if (typeof newId === 'undefined') return;
    if (newId.substring(0, 1) === '_') return; // skip uncreated tags

    // fetch galleryGroup galleryIds
    $.authenticatedGet('/api/v1/tags/'+newId, {user_id: gon.user_id}, function(resp) {
      var ids = resp.gallery_ids;
      galleryGroups[resp.id] = {gallery_ids: ids};

      if (ids.length === 0) return; // return if empty

      characterIconsBox.find("#gallery0").remove();
      ids.forEach(function(id) {
        if (characterIconsBox.find("#gallery" + id).length === 0) {
          displayGallery(id);
        }
      });
    });
  });

  createTagSelect("Setting", "setting", "character");
  createSelect2("#character_gallery_group_ids", {
    placeholder: 'Enter gallery group(s) separated by commas',
    ajax: {
      url: '/api/v1/tags',
      data: function(params) {
        var data = queryTransform(params);
        data.t = 'GalleryGroup';
        data.user_id = gon.user_id;
        return data;
      },
      processResults: function(data, params) {
        params.page = params.page || 1;
        var total = this._request.getResponseHeader('Total');
        var results = processResults(data, params, total);

        // Remove duplicates
        var existingIds = $("#character_gallery_group_ids").val() || [];
        var validResults = [];
        results.results.forEach(function(gallery) {
          if (!existingIds.includes(gallery.id.toString())) validResults.push(gallery);
        });
        results.results = validResults;

        return results;
      },
    },
    width: '300px'
  });
});

function findGalleryInGroups(galleryId) {
  galleryId = parseInt(galleryId);
  var found = false;
  Object.keys(galleryGroups).forEach(function(groupId) {
    if (galleryGroups[groupId].gallery_ids.indexOf(galleryId) >= 0) found = true;
  });
  return found;
}

function displayGallery(newId) {
  $.authenticatedGet('/api/v1/galleries/'+newId, {}, function(resp) {
    var galleryObj = $("
").attr({id: 'gallery'+newId}).data('id', newId);
    galleryObj.append("
");
    galleryObj.append($("").attr({class: 'gallery-name'}).text(resp.name));
    galleryObj.append("
");
    var galleryIcons = $("
").attr({class: 'gallery-icons'});
    galleryObj.append(galleryIcons);
    for (var i = 0; i < resp.icons.length; i++) {
      var url = resp.icons[i].url;
      var keyword = resp.icons[i].keyword;
      var id = resp.icons[i].id;
      var galleryIcon = $("").attr({src: url, alt: keyword, title: keyword, class: 'icon character-icon'}).data('id', id);
      galleryIcons.append(galleryIcon);
    }
    characterIconsBox.append(galleryObj);
    bindIcons(galleryObj);
  }, 'json');
}

function bindIcons(obj) {
  if (gon.mod_editing) return; // Mods can't change icons, so don't present the UI
  obj = obj || window.body;
  $(".character-icon", obj).click(function() {
    if ($(this).hasClass('selected-icon')) {
      $(this).removeClass('selected-icon');
      updateIcon('');
      return;
    }

    $(".selected-icon").removeClass('selected-icon');
    $(this).addClass('selected-icon');
    updateIcon($(this).data('id'));
  });
}

function updateIcon(id) {
  if (gon.character_id) {
    $.authenticatedAjax({
      url: '/api/v1/characters/'+gon.character_id,
      type: 'PUT',
      data: {character: {default_icon_id: id}},
    });
  } else {
    $("#character_default_icon_id").val(id);
  }
}


text:
/*
 *  A labelled statement can only be followed by a statement, not a
 *  source element, even at the top level.  Concretely, a function
 *  declaration cannot follow a label, nor can an expression statement
 *  begin with 'function'.
 *
 *  This is the E5 standards compliant behavior.  However, this test
 *  case tests for the default Duktape behavior (modelled after V8):
 *  function declarations are allowed outside top level in non-strict
 *  mode, and are treated like ordinary function declarations.  In
 *  strict mode they are not allowed.
 */

/*---
{
    "custom": true
}
---*/

/*===
try finished
SyntaxError
try finished
===*/

try {
    /* Function f2 declaration follows label which is not allowed.
     * Also, an expression statement  cannot begin (directly) with
     * 'function', so this should result in SyntaxError in a fully
     * compliant implementation.
     *
     * V8 allows this in non-strict mode (as function statement).
     * This is also Duktape behavior now (unless DUK_OPT_NO_NONSTD_FUNC_STMT
     * is used).
     */

    eval("function f1() { mylabel: function f2() {} }");
    print("try finished");
} catch (e) {
    print(e.name);
}

try {
    /* Strict mode should have no effect on this, but this test
     * illustrates V8 behavior (i.e. V8 gives a SyntaxError here
     * but only in strict mode).
     */
    eval("function f1() { 'use strict'; mylabel: function f2() {} }");
    print("try finished");
} catch (e) {
    print(e.name);
}

try {
    /* Here function f2 is a function expression, so it is OK. */
    eval("function f1() { mylabel: (function f2() {}) }");
    print("try finished");
} catch (e) {
    print(e.name);
}


text:
package org.opl.alg.bitset;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opl.access.block.MemoryBlockFactory;
import org.opl.allocator.Allocators;
import org.opl.util.OplUtils;

public class OplBitSetImplTest {

    private MemoryBlockFactory factory;

    private OplBitSet set;

    @Before
    public void setUp() throws Exception {
        factory = Allocators.createTestMemoryBlockFactory();
        set = new OplBitSetImpl(factory, 100 * 1024);
    }

    @After
    public void tearDown() throws Exception {
        OplUtils.closeQuietly(set);
        OplUtils.closeQuietly(factory);
    }

    @Test
    public void operations() throws Exception {
        set.set(10001);
        Assert.assertFalse(set.get(10000));
        Assert.assertFalse(set.get(10002));
        Assert.assertTrue(set.get(10001));

        set.toggle(10002);
        Assert.assertFalse(set.get(10000));
        Assert.assertTrue(set.get(10002));
        Assert.assertTrue(set.get(10001));

        set.clean(10002);
        Assert.assertFalse(set.get(10000));
        Assert.assertFalse(set.get(10002));
        Assert.assertTrue(set.get(10001));
    }

    @Test
    public void last() throws Exception {
        long index = set.size() - 1;
        Assert.assertFalse(set.get(index));

        set.set(index);
        Assert.assertTrue(set.get(index));

        set.toggle(index);
        Assert.assertFalse(set.get(index));
    }
}


text:
package net.orangemile.informatica.powercenter.domain.constant;

public enum Nullable {
	NOTNULL,
	NULL
}


text:
using namespace std;

class TextContour {
public:
	TextContour();
	~TextContour();

	void SetFont(ofxFontStash *fontStash);
	void SetAlign(ofAlignHorz aln);
	void SetFontSize(int size);
	void SetCoord(float xx, float yy);
	void SetBound(float minx, float miny, float maxx, float maxy);

	void PutText(string text);
	string GetText();
	void ClearText();

	bool ComputeContour();
	vector<ofRectangle> GetContour();

	ofPoint GetPosition();

	bool JudgeBound(ofRectangle rect);

private:
	vector<string> textVector;
	vector<ofRectangle> contour;

	ofxFontStash *font;
	ofAlignHorz align;
	int fontSize;

	float x, y;
	float drawX, drawY;
	float minX, minY, maxX, maxY;
};


text:
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/layout1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_above="@+id/layoutSwitcher"
        android:id="@+id/layout2">

        <ImageView
            android:layout_marginLeft="20dp"
            android:layout_width="63dp"
            android:layout_marginRight="10dp"
            android:layout_height="0dp"
            android:background="@drawable/tutorial5_num"
            android:id="@+id/instr5"
            android:layout_alignTop="@+id/direction1"
            android:layout_alignBottom="@+id/direction1"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"/>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/direction1"
            android:layout_marginTop="90dp"
            android:textSize="35sp"
            android:background="@drawable/tutorial5_pic"
            android:layout_marginLeft="45dp"
            android:layout_marginRight="45dp"
            android:layout_marginBottom="110dp"
            android:id="@+id/textView3"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/interaction_feature1"
            android:textSize="59sp"
            android:id="@+id/direction1"
            android:layout_marginTop="45dp"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/instr5"
            android:layout_toEndOf="@+id/instr5" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="More Info"
            android:textSize="38sp"
            android:textColor="#ff648a9f"
            android:id="@+id/more_info_frag3"
            android:layout_below="@+id/instr5"
            android:layout_toRightOf="@+id/instr5"
            android:layout_toEndOf="@+id/instr5" />

        ImageView
            android:layout_width="33dp"
            android:layout_height="40dp"
            android:background="@drawable/instr4"
            android:id="@+id/instr3"
            android:layout_alignTop="@+id/direction2"
            android:layout_toLeftOf="@+id/direction2"
            android:layout_toStartOf="@+id/direction2"
            android:layout_alignBottom="@+id/direction2" />

        TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/tutorial_instruction_four"
            android:textSize="31sp"
            android:layout_marginLeft="10dp"
            android:id="@+id/direction2"
            android:layout_below="@+id/instr1"
            android:layout_alignLeft="@+id/textView3"
            android:layout_alignStart="@+id/textView3" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:id="@+id/layoutSwitcher"
        android:layout_marginBottom="35dp">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/tutorial_positive_button"
            android:padding="5dp"
            android:textColor="#FFFFFF"
            android:textSize="72sp"
            android:background="@drawable/tutorial_btn_selector_positive_large"
            android:gravity="center_horizontal"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:layout_marginRight="25dp"
            android:layout_marginTop="15dp"
            android:id="@+id/frag_3_next"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/tutorial_negative_button"
            android:padding="5dp"
            android:textSize="72sp"
            android:textColor="#FFFFFF"
            android:background="@drawable/tutorial_btn_selector_negative_large"
            android:gravity="center_horizontal"
            android:id="@+id/frag_3_previous"
            android:layout_alignTop="@+id/frag_3_next"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="25dp" />

    </RelativeLayout>

</RelativeLayout>


text:
/*
    Este programa genera soluciones al azar para el problema de las reinas
*/

extern crate rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};

use std::io;
use std::io::prelude::*;

fn pause() {
    let mut stdin = io::stdin();
    let mut stdout = io::stdout();

    // We want the cursor to stay at the end of the line, so we print without a newline and flush manually.
    write!(stdout, "Press any key to continue...").unwrap();
    stdout.flush().unwrap();

    // Read a single byte and discard
    let _ = stdin.read(&mut [0u8]).unwrap();
}

fn main() {
    let rep = 10000;

    let mut vector_of_queens = Vec::<(isize,isize)>::with_capacity(8);

    let step =  Range::new(1, 9);
    let mut rng = rand::thread_rng();

    get_random_vector(& mut vector_of_queens, & step, & mut rng);

    let mut collisions = get_collisions( & vector_of_queens );
    let mut mincollisions = collisions;

    for _ in 0..rep {
        collisions =  get_collisions(& vector_of_queens);

        if collisions < mincollisions {
            mincollisions = collisions;
            println!("{} con {:?}", mincollisions, vector_of_queens);
        }
        get_random_vector(& mut vector_of_queens, & step, & mut rng);
    }
    println!("TERMINADO");
    pause();
}
fn get_collisions (vec : & Vec<(isize,isize)> ) -> isize {

    let mut collisions = 0;
    for a in 0..8 {
        for b in a+1 .. 8 {
            if vec[a].0 == vec[b].0 {
                collisions += 1;
            }
            if vec[a].1 == vec[b].1 {
                collisions += 1;
            }
            if ( vec[a].0 - vec[b].1 ).abs() == ( vec[a].1 - vec[b].0 ).abs() {
                collisions += 1;
            }
        }
    }
    collisions
}
fn get_random_vector(vec: & mut Vec<(isize,isize)>, step: & Range<isize>, mut rng: & mut Rng ) {
    vec.clear();
    for _ in 0..8 {
        vec.push((step.ind_sample(&mut rng),step.ind_sample(&mut rng)));
    }
}


text:
package com.facebook.buck.android.resources;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

import com.facebook.buck.io.filesystem.ProjectFilesystem;
import com.facebook.buck.io.filesystem.TestProjectFilesystems;
import com.facebook.buck.testutil.MoreAsserts;
import com.facebook.buck.testutil.integration.TemporaryPaths;
import com.facebook.buck.testutil.integration.TestDataHelper;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipFile;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

public class ResTablePackageTest {
  private static final String APK_NAME = "example.apk";

  @Rule public TemporaryPaths tmpFolder = new TemporaryPaths();
  private ProjectFilesystem filesystem;
  private Path apkPath;

  @Before
  public void setUp() throws InterruptedException, IOException {
    filesystem =
        TestProjectFilesystems.createProjectFilesystem(
            TestDataHelper.getTestDataDirectory(this).resolve("aapt_dump"));
    apkPath = filesystem.resolve(filesystem.getPath(APK_NAME));
  }

  @Test
  public void testGetAndSerialize() throws Exception {
    try (ZipFile apkZip = new ZipFile(apkPath.toFile())) {
      ByteBuffer buf =
          ResChunk.wrap(
              ByteStreams.toByteArray(apkZip.getInputStream(apkZip.getEntry("resources.arsc"))));

      List<Integer> offsets = ChunkUtils.findChunks(buf, ResChunk.CHUNK_RES_TABLE_PACKAGE);
      assertEquals(ImmutableList.of(372), offsets);

      int offset = 372;
      ByteBuffer data = ResChunk.slice(buf, offset);
      ResTablePackage resPackage = ResTablePackage.get(data);

      byte[] expected =
          Arrays.copyOfRange(
              data.array(), data.arrayOffset(), data.arrayOffset() + resPackage.getTotalSize());
      byte[] actual = resPackage.serialize();

      assertArrayEquals(expected, actual);
    }
  }

  @Test
  public void testFullSliceResTablePackage() throws Exception {
    try (ZipFile apkZip = new ZipFile(apkPath.toFile())) {
      ByteBuffer buf =
          ResChunk.wrap(
              ByteStreams.toByteArray(apkZip.getInputStream(apkZip.getEntry("resources.arsc"))));

      ResourceTable resourceTable = ResourceTable.get(buf);
      ResTablePackage resPackage = resourceTable.getPackage();
      Map<Integer, Integer> counts = new HashMap<>();
      for (ResTableTypeSpec spec : resPackage.getTypeSpecs()) {
        counts.put(spec.getResourceType(), spec.getEntryCount());
      }
      ResTablePackage copy = ResTablePackage.slice(resPackage, counts);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      resPackage.dump(resourceTable.getStrings(), new PrintStream(baos));
      String expected = new String(baos.toByteArray(), Charsets.UTF_8);

      baos = new ByteArrayOutputStream();
      copy.dump(resourceTable.getStrings(), new PrintStream(baos));
      String content = new String(baos.toByteArray(), Charsets.UTF_8);

      MoreAsserts.assertLargeStringsEqual(expected, content);
    }
  }
}