Sha256: 4989382ce236d46a5483ee999bbc1d5419dcc94b1dc64ddaee99f36b03457711

Contents?: true

Size: 1.32 KB

Versions: 63

Compression:

Stored size: 1.32 KB

Contents

import ceylon.test {
    ...
}

// Tests adapted from problem-specifications version 2.1.0

{[String, String, Integer?]*} cases => {
    // identical strands
    ["A", "A", 0],
    // long identical strands
    ["GGACTGA", "GGACTGA", 0],
    // complete distance in single nucleotide strands
    ["A", "G", 1],
    // complete distance in small strands
    ["AG", "CT", 2],
    // small distance in small strands
    ["AT", "CT", 1],
    // small distance
    ["GGACG", "GGTCG", 1],
    // small distance in long strands
    ["ACCAGGG", "ACTATGG", 2],
    // non-unique character in first strand
    ["AAG", "AAA", 1],
    // non-unique character in second strand
    ["AAA", "AAG", 1],
    // same nucleotides in different positions
    ["TAG", "GAT", 2],
    // large distance
    ["GATACA", "GCATAA", 4],
    // large distance in off-by-one strand
    ["GGACGGATTCTG", "AGGACGGATTCT", 9],
    // empty strands
    ["", "", 0],
    // disallow first strand longer
    ["AATG", "AAA", null],
    // disallow second strand longer
    ["ATA", "AGTG", null]
};

test
parameters (`value cases`)
void testHamming(String s1, String s2, Integer? expected) {
    value result = distance(s1, s2);
    if (exists expected) {
        assertEquals(result, expected);
    } else if (!is Error result) {
        fail("should have errored, but got ``result``");
    }
}

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.179 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.178 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.177 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.176 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.175 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.174 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.173 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.172 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.171 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.170 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.169 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.167 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.166 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.165 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.164 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.163 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.162 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.161 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.160 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon