diff --git a/exercises/practice/book-store/.meta/tests.toml b/exercises/practice/book-store/.meta/tests.toml index 9c7bc8d08..4b7ce98be 100644 --- a/exercises/practice/book-store/.meta/tests.toml +++ b/exercises/practice/book-store/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [17146bd5-2e80-4557-ab4c-05632b6b0d01] description = "Only a single book" @@ -33,16 +40,25 @@ description = "Two groups of four is cheaper than groups of five and three" description = "Group of four plus group of two is cheaper than two groups of three" [68ea9b78-10ad-420e-a766-836a501d3633] -description = "Two each of first 4 books and 1 copy each of rest" +description = "Two each of first four books and one copy each of rest" [c0a779d5-a40c-47ae-9828-a340e936b866] description = "Two copies of each book" [18fd86fe-08f1-4b68-969b-392b8af20513] -description = "Three copies of first book and 2 each of remaining" +description = "Three copies of first book and two each of remaining" [0b19a24d-e4cf-4ec8-9db2-8899a41af0da] -description = "Three each of first 2 books and 2 each of remaining books" +description = "Three each of first two books and two each of remaining books" [bb376344-4fb2-49ab-ab85-e38d8354a58d] description = "Four groups of four are cheaper than two groups each of five and three" + +[5260ddde-2703-4915-b45a-e54dbbac4303] +description = "Check that groups of four are created properly even when there are more groups of three than groups of five" + +[b0478278-c551-4747-b0fc-7e0be3158b1f] +description = "One group of one and four is cheaper than one group of two and three" + +[cf868453-6484-4ae1-9dfc-f8ee85bbde01] +description = "One group of one and two plus three groups of four is cheaper than one group of each size" diff --git a/exercises/practice/book-store/.meta/version b/exercises/practice/book-store/.meta/version deleted file mode 100644 index 88c5fb891..000000000 --- a/exercises/practice/book-store/.meta/version +++ /dev/null @@ -1 +0,0 @@ -1.4.0 diff --git a/exercises/practice/book-store/src/test/java/BookStoreTest.java b/exercises/practice/book-store/src/test/java/BookStoreTest.java index bf298a207..2405ba951 100644 --- a/exercises/practice/book-store/src/test/java/BookStoreTest.java +++ b/exercises/practice/book-store/src/test/java/BookStoreTest.java @@ -1,14 +1,14 @@ -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collections; -import java.util.List; -import java.util.Arrays; - import org.assertj.core.api.Assertions; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class BookStoreTest { // This is sufficient accuracy since we're handling currency values, which should be equal @@ -26,7 +26,7 @@ public void setUp() { public void onlyASingleBook() { List books = Collections.singletonList(1); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(8.00, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(8.00, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -34,7 +34,7 @@ public void onlyASingleBook() { public void twoOfSameBook() { List books = Arrays.asList(2, 2); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(16.00, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(16.00, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -42,7 +42,7 @@ public void twoOfSameBook() { public void emptyBasket() { List books = Collections.emptyList(); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(0.00, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(0.00, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -50,7 +50,7 @@ public void emptyBasket() { public void twoDifferentBooks() { List books = Arrays.asList(1, 2); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(15.20, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(15.20, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -58,7 +58,7 @@ public void twoDifferentBooks() { public void threeDifferentBooks() { List books = Arrays.asList(1, 2, 3); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(21.60, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(21.60, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -66,7 +66,7 @@ public void threeDifferentBooks() { public void fourDifferentBooks() { List books = Arrays.asList(1, 2, 3, 4); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(25.60, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(25.60, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -74,7 +74,7 @@ public void fourDifferentBooks() { public void fiveDifferentBooks() { List books = Arrays.asList(1, 2, 3, 4, 5); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(30.00, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(30.00, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -82,7 +82,7 @@ public void fiveDifferentBooks() { public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree() { List books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -90,7 +90,7 @@ public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree() { public void twoGroupsOfFourIsCheaperThanGroupsOfFiveAndThree() { List books = Arrays.asList(1, 1, 2, 3, 4, 4, 5, 5); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -98,7 +98,7 @@ public void twoGroupsOfFourIsCheaperThanGroupsOfFiveAndThree() { public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree() { List books = Arrays.asList(1, 1, 2, 2, 3, 4); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(40.80, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(40.80, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -106,7 +106,7 @@ public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree() { public void twoEachOfFirst4BooksAnd1CopyEachOfRest() { List books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(55.60, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(55.60, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -114,7 +114,7 @@ public void twoEachOfFirst4BooksAnd1CopyEachOfRest() { public void twoCopiesOfEachBook() { List books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(60.00, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(60.00, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -122,7 +122,7 @@ public void twoCopiesOfEachBook() { public void threeCopiesOfFirstBookAnd2EachOfRemaining() { List books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(68.00, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(68.00, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -130,7 +130,7 @@ public void threeCopiesOfFirstBookAnd2EachOfRemaining() { public void threeEachOFirst2BooksAnd2EachOfRemainingBooks() { List books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(75.20, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(75.20, Assertions.offset(EQUALITY_TOLERANCE)); } @Ignore("Remove to run test") @@ -138,6 +138,30 @@ public void threeEachOFirst2BooksAnd2EachOfRemainingBooks() { public void fourGroupsOfFourAreCheaperThanTwoGroupsEachOfFiveAndThree() { List books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5); assertThat(bookStore.calculateBasketCost(books)) - .isCloseTo(102.4, Assertions.offset(EQUALITY_TOLERANCE)); + .isCloseTo(102.4, Assertions.offset(EQUALITY_TOLERANCE)); + } + + @Ignore("Remove to run test") + @Test + public void groupsOfFourAreCreatedEvenWhenThereAreMoreGroupsOfThreeThanGroupsOfFive() { + List books = Arrays.asList(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5); + assertThat(bookStore.calculateBasketCost(books)) + .isCloseTo(145.6, Assertions.offset(EQUALITY_TOLERANCE)); + } + + @Ignore("Remove to run test") + @Test + public void oneGroupOfOneAndFourIsCheaperThanOneGroupOfTwoAndThree() { + List books = Arrays.asList(1, 1, 2, 3, 4); + assertThat(bookStore.calculateBasketCost(books)) + .isCloseTo(33.6, Assertions.offset(EQUALITY_TOLERANCE)); + } + + @Ignore("Remove to run test") + @Test + public void oneGroupOfOneAndTwoPlusThreeGroupsOfFourIsCheaperThanOneGroupOfEachSize() { + List books = Arrays.asList(1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5); + assertThat(bookStore.calculateBasketCost(books)) + .isCloseTo(100.0, Assertions.offset(EQUALITY_TOLERANCE)); } }