Skip to content

Commit

Permalink
Test case failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Dec 16, 2024
1 parent 0826e29 commit 34a09de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.meeuw.math.Example;
import org.meeuw.math.abstractalgebra.*;

import org.meeuw.math.exceptions.InvalidElementCreationException;

import static org.meeuw.math.text.TextUtils.subscript;

/**
Expand Down Expand Up @@ -38,13 +40,19 @@ private DihedralGroup(int n) {
}

public DihedralSymmetry r(int k) {
if (k < 0 || k >= n) {
throw new InvalidElementCreationException("! 0 <= %d < k".formatted(k));
}
if (rcache[k] == null) {
rcache[k] = DihedralSymmetry.r(k, this);
}
return rcache[k];
}

public DihedralSymmetry s(int k) {
if (k < 0 || k >= n) {
throw new InvalidElementCreationException("! 0 <= %d < k".formatted(k));
}
if (scache[k] == null) {
scache[k] = DihedralSymmetry.s(k, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public void s() {
@Test
public void illegal() {
DihedralGroup group = DihedralGroup.of(4);
assertThatThrownBy(() -> {
group.s(4);
}).isInstanceOf(InvalidElementCreationException.class);
assertThatThrownBy(() -> {
group.r(4);
}).isInstanceOf(InvalidElementCreationException.class);
assertThatThrownBy(() -> {
group.r(-1);
}).isInstanceOf(InvalidElementCreationException.class);
assertThatThrownBy(() ->
group.s(4)
).isInstanceOf(InvalidElementCreationException.class);
assertThatThrownBy(() ->
group.r(4)
).isInstanceOf(InvalidElementCreationException.class);
assertThatThrownBy(() ->
group.r(-1)
).isInstanceOf(InvalidElementCreationException.class);

}

Expand Down

0 comments on commit 34a09de

Please sign in to comment.