Sha256: 10f5b5dae44d2d42eb14ba4d7ebe564fa8161e2d52dd4233d6091191dfd5a657

Contents?: true

Size: 1.87 KB

Versions: 6

Compression:

Stored size: 1.87 KB

Contents

$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.'
. "$here\$sut"

Describe "HammingTest" {
    It "tests identical strands" {
    Get-HammingDifference 'A' 'A' | Should be 0
    }

    It "tests log identical strands" {
        Get-HammingDifference "GGACTGA" "GGACTGA" | Should be 0
    }

    It "tests complete distance in single nucleotide strands" {
        Get-HammingDifference "A" "G" | Should be 1
    }

    It "tests complete distance in small strands" {
        Get-HammingDifference "AG" "CT" | Should be 2
    }

    It "tests small distance in small strands" {
        Get-HammingDifference "AT"  "CT" | Should be 1
    }

    It "tests small distance" {
        Get-HammingDifference "GGACG" "GGTCG" | Should be 1
    }

    It "tests small distance in long strands" {
        Get-HammingDifference "ACCAGGG" "ACTATGG" | Should be 2
    }

    It "tests non unique character in first strand" {
        Get-HammingDifference "AGA" "AGG" | Should be 1
    }

    It "tests non unique character in second strand" {
        Get-HammingDifference "AGG" "AGA" | Should be 1
    }

    It "tests same nucleotides in different position" {
        Get-HammingDifference "TAG" "GAT" | Should be 2
    }

    It "tests large distance" {
        Get-HammingDifference "GATACA" "GCATAA" | Should be 4
    }

    It "tests large distance in off by one strand" {
        Get-HammingDifference "GGACGGATTCTG" "AGGACGGATTCT" | Should be 9
    }

    It "tests empty strands" {
        Get-HammingDifference "" "" | Should be 0
    }

    It "tests disallow first strand longer" {
        { Get-HammingDifference "AATG" "AAA" } | Should Throw "Mismatching string lengths"
    }

    It "tests disallow second strand longer" {
        { Get-HammingDifference "ATA" "AGTG" } | Should Throw "Mismatching string lengths"
    }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trackler-2.2.1.150 tracks/powershell/exercises/hamming/HammingDifference.tests.ps1
trackler-2.2.1.149 tracks/powershell/exercises/hamming/HammingDifference.tests.ps1
trackler-2.2.1.148 tracks/powershell/exercises/hamming/HammingDifference.tests.ps1
trackler-2.2.1.147 tracks/powershell/exercises/hamming/HammingDifference.tests.ps1
trackler-2.2.1.146 tracks/powershell/exercises/hamming/HammingDifference.tests.ps1
trackler-2.2.1.145 tracks/powershell/exercises/hamming/HammingDifference.tests.ps1