Skip to content

test(PythagoreanTriplet): Add version and test case. - #1561

Merged
FridaTveit merged 6 commits into
exercism:masterfrom
princerachit:pythagorean-triplet-test
Dec 17, 2018
Merged

FridaTveit merged 6 commits into
exercism:masterfrom
princerachit:pythagorean-triplet-test

Conversation

@princerachit

@princerachit princerachit commented Oct 1, 2018 •

Copy link
Copy Markdown
Contributor
  1. Add version file in .meta folder.
  2. Add missing test cases a/c to canonical data.
  3. Update source file logic to save triplet in order a<=b<=c.
  4. Reformat test file (eclipse deafult formatting).

Signed-off-by: Prince Rachit Sinha prince.rachit@mayadata.io


Reviewer Resources:

Track Policies

1. Add version file in .meta folder.
2. Add missing test cases a/c to canonical data.
3. Update source file logic to save triplet in order a<=b<=c.
4. Reformat test file (eclipse deafult formatting).

Signed-off-by: Prince Rachit Sinha <prince.rachit@mayadata.io>

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for tackling this @princerachit! 😄

I've left a few comments, feel free to ask questions or comment if you disagree with anything 🙂

assertEquals(expected, actual);
}

@Test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Each test apart from the first one should be ignored by adding @Ignore("Remove to run test") above the @Test line. See our policies doc for more information 🙂

@princerachit princerachit changed the title test(PythagoreanTriplet): Add version and test case. [wip]test(PythagoreanTriplet): Add version and test case. Oct 1, 2018
@princerachit
princerachit force-pushed the pythagorean-triplet-test branch 2 times, most recently from e0a4ec8 to ca2e025 Compare October 1, 2018 18:02
Signed-off-by: princerachit <prince.rachit@mayadata.io>
@princerachit
princerachit force-pushed the pythagorean-triplet-test branch from ca2e025 to fcfbc9a Compare October 14, 2018 09:51
Signed-off-by: princerachit <prince.rachit@mayadata.io>
@princerachit princerachit changed the title [wip]test(PythagoreanTriplet): Add version and test case. test(PythagoreanTriplet): Add version and test case. Oct 14, 2018
@princerachit

Copy link
Copy Markdown
Contributor Author

@FridaTveit @sjwarner-bp Sorry for the delay, was involved in a lot of hacktoberfest meetups. I have addressed all the changes.

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking good, thanks for tackling this @princerachit! 🙂 I've left a few comments, feel free to ask questions or disagree with me 🙂

@@ -20,6 +20,156 @@ public void shouldCalculateSum() {
assertEquals(expected, actual);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test doesn't appear to be in the canonical data? 🙂

}
}

@Ignore("Remove to run test")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test and all the ones below it don't appear to be in the canonical data? In which case they should be removed 🙂

List<PythagoreanTriplet> actual
= PythagoreanTriplet
.makeTripletsList()
.withFactorsLessThanOrEqualTo(12)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The statement above doesn't appear to be a constraint in the canonical data?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this restriction needed @princerachit? 🙂 The same holds for many of the other tests. The restriction withFactorsLessThanOrEqualTo isn't mentioned in the canonical data so I don't think it's needed?

It's only a minor thing though so if you would prefer for me to open a separate issue to fix it then I'm happy to do that. Just let me know what you would prefer 🙂


assertEquals(expected.size(), actual.size());
for (int i = 0; i < expected.size(); ++i) {
assertEquals(expected.get(i), actual.get(i));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason why you can't just compare the list here instead of iterating over it and comparing individual elements? 🙂


List<PythagoreanTriplet> expected
= Arrays.asList(
new PythagoreanTriplet(3, 4, 5));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This statement looks short enough to all be on one line 🙂 And you can use Collections.singletonList since the list just has one element 🙂

.thatSumTo(1001)
.build();

List<PythagoreanTriplet> expected = Arrays.asList();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use Collections.emptyList here 🙂

@princerachit

Copy link
Copy Markdown
Contributor Author

will incorporate all changes and push the commits this weekend. Thanks

Signed-off-by: princerachit <prince.rachit@mayadata.io>

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking very close to being ready to merge @princerachit! Thanks for being patient and making the changes 🙂

I've left one comment and there's one comment from last time that I think you haven't addressed. There are also now some conflicts with the main branch so you'll have to rebase on the master branch (or merge the master branch into this one) before this can be merged. Let us know if you have any problems with that! 🙂


public class PythagoreanTripletTest {

@Ignore("Remove to run test")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The first test shouldn't have an Ignore statement above it. All tests apart from the first one should have an Ignore statement. That way the users can deal with making one test pass at a time 🙂

List<PythagoreanTriplet> actual
= PythagoreanTriplet
.makeTripletsList()
.withFactorsLessThanOrEqualTo(12)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this restriction needed @princerachit? 🙂 The same holds for many of the other tests. The restriction withFactorsLessThanOrEqualTo isn't mentioned in the canonical data so I don't think it's needed?

It's only a minor thing though so if you would prefer for me to open a separate issue to fix it then I'm happy to do that. Just let me know what you would prefer 🙂

@princerachit

Copy link
Copy Markdown
Contributor Author

Will incorporate the changes soon!

@FridaTveit

Copy link
Copy Markdown
Contributor

Great, thanks @princerachit! 🙂

@FridaTveit

Copy link
Copy Markdown
Contributor

@princerachit how are you getting on with this? I think the only thing that needs to be changed is that the @Ignore above the first test must be removed, then it's ready to merge 🙂 Let us know if you need any help with anything! 🙂

Signed-off-by: princerachit <prince.rachit@mayadata.io>
@princerachit

Copy link
Copy Markdown
Contributor Author

@FridaTveit can you help in resolving conflicts please?

@FridaTveit

Copy link
Copy Markdown
Contributor

@princerachit The only change that has happened since you opened this PR is that we've added a linter. So I think you should:

  • Merge master into your branch
  • When you get merge conflicts, prioritise your changes in the test file.
  • Run the linter and fix any errors that occur

Does that make sense? 🙂

@princerachit

Copy link
Copy Markdown
Contributor Author

@FridaTveit done

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Thanks @princerachit! 😄

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.

3 participants