Sha256: d785852e187a7cd277d68f982f958e35e3ee5820304248a44c905a0042eb5098

Contents?: true

Size: 1.91 KB

Versions: 268

Compression:

Stored size: 1.91 KB

Contents

#!/usr/bin/env bats

@test "Short identical strands have hamming distance of zero" {
  run bash hamming.sh C C

  [ "$status" -eq 0 ]
  [ "$output" -eq 0 ]
}

@test "Long identical strands have hamming distance of zero" {
  run bash hamming.sh CATGCATG CATGCATG

  [ "$status" -eq 0 ]
  [ "$output" -eq 0 ]
}

@test "Single char different strings have hamming distance of one" {
  run bash hamming.sh C A

  [ "$status" -eq 0 ]
  [ "$output" -eq 1 ]
}

@test "Distance with all chars different in small strings" {
  run bash hamming.sh GC AT

  [ "$status" -eq 0 ]
  [ "$output" -eq 2 ]
}

@test "small distance with small strands" {
  run bash hamming.sh GC GT

  [ "$status" -eq 0 ]
  [ "$output" -eq 1 ]
}

@test "small distance" {
  run bash hamming.sh GGACG GGTCG

  [ "$status" -eq 0 ]
  [ "$output" -eq 1 ]
}

@test "small distance in long strands" {
  run bash hamming.sh ACCAGGG ACTATGG

  [ "$status" -eq 0 ]
  [ "$output" -eq 2 ]
}

@test "non unique char in first strand" {
  run bash hamming.sh AGA AGG

  [ "$status" -eq 0 ]
  [ "$output" -eq 1 ]
}

@test "non unique char in second strand" {
  run bash hamming.sh AGG AGA

  [ "$status" -eq 0 ]
  [ "$output" -eq 1 ]
}

@test "large distance" {
  run bash hamming.sh GATACA GCATAA

  [ "$status" -eq 0 ]
  [ "$output" -eq 4 ]
}

@test "large distance in off by one strand" {
  run bash hamming.sh GGACGGATTCTG AGGACGGATTCT

  [ "$status" -eq 0 ]
  [ "$output" -eq 9 ]
}

@test "empty strands" {
  run bash hamming.sh "" ""

  [ "$status" -eq 0 ]
  [ "$output" -eq 0 ]
}

@test "first string longer" {
  run bash hamming.sh AGT AG

  [ "$status" -eq 1 ]
  [ "$output" = "The two strands must have the same length." ]
}

@test "second string longer" {
  run bash hamming.sh AGT AGTC

  [ "$status" -eq 1 ]
  [ "$output" = "The two strands must have the same length." ]
}

@test "no input" {
  run bash hamming.sh

  [ "$status" -eq 1 ]
  [ "$output" = "Usage: hamming.sh <string1> <string2>" ]
}

Version data entries

268 entries across 268 versions & 1 rubygems

Version Path
trackler-2.2.1.66 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.65 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.64 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.63 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.62 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.61 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.60 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.59 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.58 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.57 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.56 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.55 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.54 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.53 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.52 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.51 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.50 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.49 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.48 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.2.1.47 tracks/bash/exercises/hamming/hamming_test.sh