Skip to content

Conversation

@wolf99
Copy link
Contributor

@wolf99 wolf99 commented Dec 29, 2020

Fixes #504

Again here the question of semantics in the spec.
Does empty mean a zero-length string (i.e. ""), or NULL?

@wolf99 wolf99 requested a review from a team December 29, 2020 23:05
@ryanplusplus
Copy link
Member

Again here the question of semantics in the spec.
Does empty mean a zero-length string (i.e. ""), or NULL?

IMO, empty means "" instead of NULL. Assuming that NULL can be passed as the "zero"/empty/whatever value is a common problem I see. I'd rather not muddy the waters between empty and missing.

Comment on lines 77 to 63

static void test_large_hamming_distance(void)
static void test_disallow_left_empty_strand(void)
{
TEST_IGNORE();
TEST_ASSERT_EQUAL(4, compute("GATACA", "GCATAA"));
TEST_ASSERT_EQUAL(-1, compute(NULL, "G"));
}

static void test_hamming_distance_in_very_long_strand(void)
static void test_disallow_right_empty_strand(void)
{
TEST_IGNORE();
TEST_ASSERT_EQUAL(9, compute("GGACGGATTCTG", "AGGACGGATTCT"));
TEST_ASSERT_EQUAL(-1, compute("G", NULL));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, now I'm having second thoughts about my earlier comment regarding "" and NULL. I don't think that the spec makes much sense here. The name and the check don't match. An empty strand ("") shouldn't be an error , but a missing strand (NULL) should be. Further confusing things is that because the strand lengths don't match, it would be an error regardless of whether it was empty or missing so it's confusing to say that an empty strand should be treated as an error.

I think these tests would make far more sense if named test_disallow_<which>_strand_missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the logic means that these two tests don't make sense.
I've removed them and set the related UUIDs to false in the TOML file.
Have also opened an issue on the problem specs repo about it (exercism/problem-specifications#1761).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍

@ryanplusplus ryanplusplus merged commit e0da781 into master Dec 30, 2020
@ryanplusplus ryanplusplus deleted the hamming-update branch December 30, 2020 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hamming: update to most recent canonical specification

3 participants