Sha256: 8dbb0c870ea263beae4092c928c55856ce4a1a6760dde799b6be79e15e1acbd2

Contents?: true

Size: 1.23 KB

Versions: 105

Compression:

Stored size: 1.23 KB

Contents

import ceylon.test { ... }

// Tests adapted from x-common version 1.0.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
  ["AGA", "AGG", 1],
  // non-unique character in second strand
  ["AGG", "AGA", 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

105 entries across 105 versions & 1 rubygems

Version Path
trackler-2.2.1.30 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.29 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.28 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.27 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.26 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.25 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.24 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.23 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.22 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.21 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.20 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.19 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.18 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.17 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.16 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.15 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.14 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.13 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.12 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon
trackler-2.2.1.11 tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon