Skip to content

Commit d750552

Browse files
Sync tests for practice exercise book-store (#2531)
1 parent 64b400c commit d750552

File tree

3 files changed

+67
-28
lines changed

3 files changed

+67
-28
lines changed

exercises/practice/book-store/.meta/tests.toml

Lines changed: 22 additions & 6 deletions
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
[17146bd5-2e80-4557-ab4c-05632b6b0d01]
613
description = "Only a single book"
@@ -33,16 +40,25 @@ description = "Two groups of four is cheaper than groups of five and three"
3340
description = "Group of four plus group of two is cheaper than two groups of three"
3441

3542
[68ea9b78-10ad-420e-a766-836a501d3633]
36-
description = "Two each of first 4 books and 1 copy each of rest"
43+
description = "Two each of first four books and one copy each of rest"
3744

3845
[c0a779d5-a40c-47ae-9828-a340e936b866]
3946
description = "Two copies of each book"
4047

4148
[18fd86fe-08f1-4b68-969b-392b8af20513]
42-
description = "Three copies of first book and 2 each of remaining"
49+
description = "Three copies of first book and two each of remaining"
4350

4451
[0b19a24d-e4cf-4ec8-9db2-8899a41af0da]
45-
description = "Three each of first 2 books and 2 each of remaining books"
52+
description = "Three each of first two books and two each of remaining books"
4653

4754
[bb376344-4fb2-49ab-ab85-e38d8354a58d]
4855
description = "Four groups of four are cheaper than two groups each of five and three"
56+
57+
[5260ddde-2703-4915-b45a-e54dbbac4303]
58+
description = "Check that groups of four are created properly even when there are more groups of three than groups of five"
59+
60+
[b0478278-c551-4747-b0fc-7e0be3158b1f]
61+
description = "One group of one and four is cheaper than one group of two and three"
62+
63+
[cf868453-6484-4ae1-9dfc-f8ee85bbde01]
64+
description = "One group of one and two plus three groups of four is cheaper than one group of each size"

exercises/practice/book-store/.meta/version

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import static org.assertj.core.api.Assertions.assertThat;
2-
3-
import java.util.Collections;
4-
import java.util.List;
5-
import java.util.Arrays;
6-
71
import org.assertj.core.api.Assertions;
82
import org.junit.Before;
93
import org.junit.Ignore;
104
import org.junit.Test;
115

6+
import java.util.Arrays;
7+
import java.util.Collections;
8+
import java.util.List;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
1212
public class BookStoreTest {
1313

1414
// This is sufficient accuracy since we're handling currency values, which should be equal
@@ -26,118 +26,142 @@ public void setUp() {
2626
public void onlyASingleBook() {
2727
List<Integer> books = Collections.singletonList(1);
2828
assertThat(bookStore.calculateBasketCost(books))
29-
.isCloseTo(8.00, Assertions.offset(EQUALITY_TOLERANCE));
29+
.isCloseTo(8.00, Assertions.offset(EQUALITY_TOLERANCE));
3030
}
3131

3232
@Ignore("Remove to run test")
3333
@Test
3434
public void twoOfSameBook() {
3535
List<Integer> books = Arrays.asList(2, 2);
3636
assertThat(bookStore.calculateBasketCost(books))
37-
.isCloseTo(16.00, Assertions.offset(EQUALITY_TOLERANCE));
37+
.isCloseTo(16.00, Assertions.offset(EQUALITY_TOLERANCE));
3838
}
3939

4040
@Ignore("Remove to run test")
4141
@Test
4242
public void emptyBasket() {
4343
List<Integer> books = Collections.emptyList();
4444
assertThat(bookStore.calculateBasketCost(books))
45-
.isCloseTo(0.00, Assertions.offset(EQUALITY_TOLERANCE));
45+
.isCloseTo(0.00, Assertions.offset(EQUALITY_TOLERANCE));
4646
}
4747

4848
@Ignore("Remove to run test")
4949
@Test
5050
public void twoDifferentBooks() {
5151
List<Integer> books = Arrays.asList(1, 2);
5252
assertThat(bookStore.calculateBasketCost(books))
53-
.isCloseTo(15.20, Assertions.offset(EQUALITY_TOLERANCE));
53+
.isCloseTo(15.20, Assertions.offset(EQUALITY_TOLERANCE));
5454
}
5555

5656
@Ignore("Remove to run test")
5757
@Test
5858
public void threeDifferentBooks() {
5959
List<Integer> books = Arrays.asList(1, 2, 3);
6060
assertThat(bookStore.calculateBasketCost(books))
61-
.isCloseTo(21.60, Assertions.offset(EQUALITY_TOLERANCE));
61+
.isCloseTo(21.60, Assertions.offset(EQUALITY_TOLERANCE));
6262
}
6363

6464
@Ignore("Remove to run test")
6565
@Test
6666
public void fourDifferentBooks() {
6767
List<Integer> books = Arrays.asList(1, 2, 3, 4);
6868
assertThat(bookStore.calculateBasketCost(books))
69-
.isCloseTo(25.60, Assertions.offset(EQUALITY_TOLERANCE));
69+
.isCloseTo(25.60, Assertions.offset(EQUALITY_TOLERANCE));
7070
}
7171

7272
@Ignore("Remove to run test")
7373
@Test
7474
public void fiveDifferentBooks() {
7575
List<Integer> books = Arrays.asList(1, 2, 3, 4, 5);
7676
assertThat(bookStore.calculateBasketCost(books))
77-
.isCloseTo(30.00, Assertions.offset(EQUALITY_TOLERANCE));
77+
.isCloseTo(30.00, Assertions.offset(EQUALITY_TOLERANCE));
7878
}
7979

8080
@Ignore("Remove to run test")
8181
@Test
8282
public void twoGroupsOfFourIsCheaperThanGroupOfFivePlusGroupOfThree() {
8383
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5);
8484
assertThat(bookStore.calculateBasketCost(books))
85-
.isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE));
85+
.isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE));
8686
}
8787

8888
@Ignore("Remove to run test")
8989
@Test
9090
public void twoGroupsOfFourIsCheaperThanGroupsOfFiveAndThree() {
9191
List<Integer> books = Arrays.asList(1, 1, 2, 3, 4, 4, 5, 5);
9292
assertThat(bookStore.calculateBasketCost(books))
93-
.isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE));
93+
.isCloseTo(51.20, Assertions.offset(EQUALITY_TOLERANCE));
9494
}
9595

9696
@Ignore("Remove to run test")
9797
@Test
9898
public void groupOfFourPlusGroupOfTwoIsCheaperThanTwoGroupsOfThree() {
9999
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 4);
100100
assertThat(bookStore.calculateBasketCost(books))
101-
.isCloseTo(40.80, Assertions.offset(EQUALITY_TOLERANCE));
101+
.isCloseTo(40.80, Assertions.offset(EQUALITY_TOLERANCE));
102102
}
103103

104104
@Ignore("Remove to run test")
105105
@Test
106106
public void twoEachOfFirst4BooksAnd1CopyEachOfRest() {
107107
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5);
108108
assertThat(bookStore.calculateBasketCost(books))
109-
.isCloseTo(55.60, Assertions.offset(EQUALITY_TOLERANCE));
109+
.isCloseTo(55.60, Assertions.offset(EQUALITY_TOLERANCE));
110110
}
111111

112112
@Ignore("Remove to run test")
113113
@Test
114114
public void twoCopiesOfEachBook() {
115115
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5);
116116
assertThat(bookStore.calculateBasketCost(books))
117-
.isCloseTo(60.00, Assertions.offset(EQUALITY_TOLERANCE));
117+
.isCloseTo(60.00, Assertions.offset(EQUALITY_TOLERANCE));
118118
}
119119

120120
@Ignore("Remove to run test")
121121
@Test
122122
public void threeCopiesOfFirstBookAnd2EachOfRemaining() {
123123
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1);
124124
assertThat(bookStore.calculateBasketCost(books))
125-
.isCloseTo(68.00, Assertions.offset(EQUALITY_TOLERANCE));
125+
.isCloseTo(68.00, Assertions.offset(EQUALITY_TOLERANCE));
126126
}
127127

128128
@Ignore("Remove to run test")
129129
@Test
130130
public void threeEachOFirst2BooksAnd2EachOfRemainingBooks() {
131131
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2);
132132
assertThat(bookStore.calculateBasketCost(books))
133-
.isCloseTo(75.20, Assertions.offset(EQUALITY_TOLERANCE));
133+
.isCloseTo(75.20, Assertions.offset(EQUALITY_TOLERANCE));
134134
}
135135

136136
@Ignore("Remove to run test")
137137
@Test
138138
public void fourGroupsOfFourAreCheaperThanTwoGroupsEachOfFiveAndThree() {
139139
List<Integer> books = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5);
140140
assertThat(bookStore.calculateBasketCost(books))
141-
.isCloseTo(102.4, Assertions.offset(EQUALITY_TOLERANCE));
141+
.isCloseTo(102.4, Assertions.offset(EQUALITY_TOLERANCE));
142+
}
143+
144+
@Ignore("Remove to run test")
145+
@Test
146+
public void groupsOfFourAreCreatedEvenWhenThereAreMoreGroupsOfThreeThanGroupsOfFive() {
147+
List<Integer> 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);
148+
assertThat(bookStore.calculateBasketCost(books))
149+
.isCloseTo(145.6, Assertions.offset(EQUALITY_TOLERANCE));
150+
}
151+
152+
@Ignore("Remove to run test")
153+
@Test
154+
public void oneGroupOfOneAndFourIsCheaperThanOneGroupOfTwoAndThree() {
155+
List<Integer> books = Arrays.asList(1, 1, 2, 3, 4);
156+
assertThat(bookStore.calculateBasketCost(books))
157+
.isCloseTo(33.6, Assertions.offset(EQUALITY_TOLERANCE));
158+
}
159+
160+
@Ignore("Remove to run test")
161+
@Test
162+
public void oneGroupOfOneAndTwoPlusThreeGroupsOfFourIsCheaperThanOneGroupOfEachSize() {
163+
List<Integer> books = Arrays.asList(1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5);
164+
assertThat(bookStore.calculateBasketCost(books))
165+
.isCloseTo(100.0, Assertions.offset(EQUALITY_TOLERANCE));
142166
}
143167
}

0 commit comments

Comments
 (0)