Skip to content

Commit de48277

Browse files
committed
Sync hamming tests to problem-description data (exercism#775)
1 parent dad723f commit de48277

File tree

2 files changed

+72
-20
lines changed

2 files changed

+72
-20
lines changed

exercises/practice/hamming/.meta/tests.toml

+40-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[f6dcb64f-03b0-4b60-81b1-3c9dbf47e887]
613
description = "empty strands"
@@ -19,12 +26,42 @@ description = "long different strands"
1926

2027
[919f8ef0-b767-4d1b-8516-6379d07fcb28]
2128
description = "disallow first strand longer"
29+
include = false
30+
31+
[b9228bb1-465f-4141-b40f-1f99812de5a8]
32+
description = "disallow first strand longer"
33+
reimplements = "919f8ef0-b767-4d1b-8516-6379d07fcb28"
2234

2335
[8a2d4ed0-ead5-4fdd-924d-27c4cf56e60e]
2436
description = "disallow second strand longer"
37+
include = false
38+
39+
[dab38838-26bb-4fff-acbe-3b0a9bfeba2d]
40+
description = "disallow second strand longer"
41+
reimplements = "8a2d4ed0-ead5-4fdd-924d-27c4cf56e60e"
2542

2643
[5dce058b-28d4-4ca7-aa64-adfe4e17784c]
2744
description = "disallow left empty strand"
45+
include = false
46+
47+
[db92e77e-7c72-499d-8fe6-9354d2bfd504]
48+
description = "disallow left empty strand"
49+
include = false
50+
reimplements = "5dce058b-28d4-4ca7-aa64-adfe4e17784c"
51+
52+
[b764d47c-83ff-4de2-ab10-6cfe4b15c0f3]
53+
description = "disallow empty first strand"
54+
reimplements = "db92e77e-7c72-499d-8fe6-9354d2bfd504"
2855

2956
[38826d4b-16fb-4639-ac3e-ba027dec8b5f]
3057
description = "disallow right empty strand"
58+
include = false
59+
60+
[920cd6e3-18f4-4143-b6b8-74270bb8f8a3]
61+
description = "disallow right empty strand"
62+
include = false
63+
reimplements = "38826d4b-16fb-4639-ac3e-ba027dec8b5f"
64+
65+
[9ab9262f-3521-4191-81f5-0ed184a5aa89]
66+
description = "disallow empty second strand"
67+
reimplements = "920cd6e3-18f4-4143-b6b8-74270bb8f8a3"

exercises/practice/hamming/hamming_test.cpp

+32-17
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,64 @@
66
#include "test/catch.hpp"
77
#endif
88

9-
TEST_CASE("no_difference_between_identical_strands")
9+
// UUID: 54681314-eee2-439a-9db0-b0636c656156
10+
TEST_CASE("single letter identical strands")
1011
{
1112
REQUIRE(0 == hamming::compute("A", "A"));
1213
}
1314

1415
#if defined(EXERCISM_RUN_ALL_TESTS)
15-
TEST_CASE("complete_hamming_distance_for_single_nucleotide_strand")
16+
// UUID: f6dcb64f-03b0-4b60-81b1-3c9dbf47e887
17+
TEST_CASE("empty strands")
1618
{
17-
REQUIRE(1 == hamming::compute("A", "G"));
19+
REQUIRE(0 == hamming::compute("", ""));
1820
}
1921

20-
TEST_CASE("complete_hamming_distance_for_small_strand")
22+
// UUID: 294479a3-a4c8-478f-8d63-6209815a827b
23+
TEST_CASE("single letter different strands")
2124
{
22-
REQUIRE(2 == hamming::compute("AG", "CT"));
25+
REQUIRE(1 == hamming::compute("G", "T"));
2326
}
2427

25-
TEST_CASE("small_hamming_distance")
28+
// UUID: 9aed5f34-5693-4344-9b31-40c692fb5592
29+
TEST_CASE("long identical strands")
2630
{
27-
REQUIRE(1 == hamming::compute("AT", "CT"));
31+
REQUIRE(0 == hamming::compute("GGACTGAAATCTG", "GGACTGAAATCTG"));
2832
}
2933

30-
TEST_CASE("small_hamming_distance_in_longer_strand")
34+
// UUID: cd2273a5-c576-46c8-a52b-dee251c3e6e5
35+
TEST_CASE("long different strands")
3136
{
32-
REQUIRE(1 == hamming::compute("GGACG", "GGTCG"));
37+
REQUIRE(9 == hamming::compute("GGACGGATTCTG", "AGGACGGATTCT"));
3338
}
3439

35-
TEST_CASE("domain_error_when_first_string_is_longer")
40+
// UUID: b9228bb1-465f-4141-b40f-1f99812de5a8
41+
TEST_CASE("disallow first strand longer")
3642
{
37-
REQUIRE_THROWS_AS(hamming::compute("AAAG", "AAA"), std::domain_error);
43+
REQUIRE_THROWS_AS(hamming::compute("AATG", "AAA"), std::domain_error);
3844
}
3945

40-
TEST_CASE("domain_error_when_second_string_is_longer")
46+
// UUID: dab38838-26bb-4fff-acbe-3b0a9bfeba2d
47+
TEST_CASE("disallow second strand longer")
4148
{
42-
REQUIRE_THROWS_AS(hamming::compute("AAA", "AAAG"), std::domain_error);
49+
REQUIRE_THROWS_AS(hamming::compute("ATA", "AGTG"), std::domain_error);
4350
}
4451

45-
TEST_CASE("large_hamming_distance")
52+
// UUID: db92e77e-7c72-499d-8fe6-9354d2bfd504
53+
TEST_CASE("disallow left empty strand")
4654
{
47-
REQUIRE(4 == hamming::compute("GATACA", "GCATAA"));
55+
REQUIRE_THROWS_AS(hamming::compute("", "G"), std::domain_error);
4856
}
4957

50-
TEST_CASE("hamming_distance_in_very_long_strand")
58+
// UUID: b764d47c-83ff-4de2-ab10-6cfe4b15c0f3
59+
TEST_CASE("disallow empty first strand")
5160
{
52-
REQUIRE(9 == hamming::compute("GGACGGATTCTG", "AGGACGGATTCT"));
61+
REQUIRE_THROWS_AS(hamming::compute("", "G"), std::domain_error);
62+
}
63+
64+
// UUID: 9ab9262f-3521-4191-81f5-0ed184a5aa89
65+
TEST_CASE("disallow empty second strand")
66+
{
67+
REQUIRE_THROWS_AS(hamming::compute("G", ""), std::domain_error);
5368
}
5469
#endif

0 commit comments

Comments
 (0)