Skip to content

Commit

Permalink
40 update tests to match those in canonical-data.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jerold committed Oct 4, 2017
1 parent 4af2d5a commit e99cd10
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
4 changes: 1 addition & 3 deletions exercises/hamming/lib/hamming.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
class Hamming {
int compute(String a, String b) {
// Put your code here
}
// Put your code here
}
74 changes: 44 additions & 30 deletions exercises/hamming/test/hamming_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,64 @@ void main() {
final hamming = new Hamming();

group("Hamming", () {
test("no difference between identical strands", () {
final res = hamming.compute("A", "A");
test("empty strands", () {
expect(hamming.compute("", ""), equals(0));
});

expect(res, equals(0));
test("identical strands", () {
expect(hamming.compute("A", "A"), equals(0));
});

test("complete hamming distance for single nucleotide strand", () {
final res = hamming.compute("A", "G");
test("long identical strands", () {
expect(hamming.compute("GGACTGA", "GGACTGA"), equals(0));
});

expect(res, equals(1));
}, skip: true);
test("complete distance in single nucleotide strands", () {
expect(hamming.compute("A", "G"), equals(1));
});

test("complete hamming distance for small strand", () {
final res = hamming.compute("AG", "CT");
test("complete distance in small strands", () {
expect(hamming.compute("AG", "CT"), equals(2));
});

expect(res, equals(2));
}, skip: true);
test("small distance in small strands", () {
expect(hamming.compute("AT", "CT"), equals(1));
});

test("small hamming distance", () {
final res = hamming.compute("AT", "CT");
test("small distance", () {
expect(hamming.compute("GGACG", "GGTCG"), equals(1));
});

expect(res, equals(1));
}, skip: true);
test("small distance in long strands", () {
expect(hamming.compute("ACCAGGG", "ACTATGG"), equals(2));
});

test("small hamming distance in longer strand", () {
final res = hamming.compute("GGACG", "GGTCG");
test("non-unique character in first strand", () {
expect(hamming.compute("AGA", "AGG"), equals(1));
});

expect(res, equals(1));
}, skip: true);
test("non-unique character in second strand", () {
expect(hamming.compute("AGG", "AGA"), equals(1));
});

test("large hamming distance", () {
final res = hamming.compute("GATACA", "GCATAA");
test("same nucleotides in different positions", () {
expect(hamming.compute("TAG", "GAT"), equals(2));
});

expect(res, equals(4));
}, skip: true);
test("large distance", () {
expect(hamming.compute("GATACA", "GCATAA"), equals(4));
});

test("hamming distance in very long strand", () {
final res = hamming.compute("GGACGGATTCTG", "AGGACGGATTCT");
test("large distance in off-by-one strand", () {
expect(hamming.compute("GGACGGATTCTG", "AGGACGGATTCT"), equals(9));
});

expect(res, equals(9));
}, skip: true);
test("disallow first strand longer", () {
expect(() => hamming.compute("AATG", "AAA"), throwsArgumentError);
});

test("throws error when strands are not equal length", () {
expect(() => hamming.compute("GGACGGATTCTG", "AGGAC"), throwsArgumentError);
}, skip: true);
test("disallow second strand longer", () {
expect(() => hamming.compute("ATA", "AGTG"), throwsArgumentError);
});
});
}

0 comments on commit e99cd10

Please sign in to comment.