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.1.0.49 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.48 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.47 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.46 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.45 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.44 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.43 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.42 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.41 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.40 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.39 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.38 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.37 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.36 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.34 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.33 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.32 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.31 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.30 tracks/bash/exercises/hamming/hamming_test.sh
trackler-2.1.0.29 tracks/bash/exercises/hamming/hamming_test.sh