Sha256: 0a0dc6ca8ecdcd40075bd39bdfd54edb1b8630e32e62c7f3b8efb269bb5fbee0

Contents?: true

Size: 1.3 KB

Versions: 275

Compression:

Stored size: 1.3 KB

Contents

import org.junit.Test;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class BinaryTest {

    private String binaryNumberAsString;
    private int decimalNumber;

    @Parameters(name = "{index}: expected {1} when converting \"{0}\" from binary to decimal.")
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][]{
                {"1", 1},
                {"10", 2},
                {"11", 3},
                {"100", 4},
                {"1001", 9},
                {"11010", 26},
                {"10001101000", 1128},
                {"2", 0},
                {"5", 0},
                {"9", 0},
                {"134678", 0},
                {"abc10z", 0},
                {"011", 3}
        });
    }

    public BinaryTest(String binaryNumberAsString, int decimalNumber) {
        this.binaryNumberAsString = binaryNumberAsString;
        this.decimalNumber = decimalNumber;
    }


    @Test
    public void test() {
        Binary binary = new Binary(binaryNumberAsString);

        assertEquals(decimalNumber, binary.getDecimal());
    }
}

Version data entries

275 entries across 275 versions & 1 rubygems

Version Path
trackler-2.0.6.7 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.6 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.5 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.4 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.3 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.2 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.1 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.6.0 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.18 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.17 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.16 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.15 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.14 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.13 tracks/java/exercises/binary/src/test/java/BinaryTest.java
trackler-2.0.5.12 tracks/java/exercises/binary/src/test/java/BinaryTest.java