-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae79a9d
commit d6eaf87
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,10 @@ public double x2() { | |
return x2; | ||
} | ||
|
||
public double h() { | ||
return h; | ||
} | ||
|
||
public int n() { | ||
return n; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package by.andd3dfx.math; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
|
||
class IntervalTest { | ||
|
||
@Test | ||
void defaultConstructor() { | ||
var interval = new Interval(); | ||
|
||
assertThat(interval.x1()).isEqualTo(0.0); | ||
assertThat(interval.x2()).isEqualTo(1.0); | ||
assertThat(interval.h()).isEqualTo(1.0); | ||
assertThat(interval.n()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
void paramsConstructorWithN() { | ||
var interval = new Interval(2.5, 10.5, 10); | ||
|
||
assertThat(interval.x1()).isEqualTo(2.5); | ||
assertThat(interval.x2()).isEqualTo(10.5); | ||
assertThat(interval.h()).isEqualTo(0.8); | ||
assertThat(interval.n()).isEqualTo(10); | ||
} | ||
|
||
@Test | ||
void paramsConstructorWithH() { | ||
var interval = new Interval(2.5, 10.5, 0.1); | ||
|
||
assertThat(interval.x1()).isEqualTo(2.5); | ||
assertThat(interval.x2()).isEqualTo(10.5); | ||
assertThat(interval.h()).isEqualTo(0.1); | ||
assertThat(interval.n()).isEqualTo(80); | ||
} | ||
|
||
@Test | ||
void rebornWithN() { | ||
var interval = new Interval(2.5, 10.5, 10); | ||
|
||
interval.reborn(5.0, 10.0, 100); | ||
|
||
assertThat(interval.x1()).isEqualTo(5.0); | ||
assertThat(interval.x2()).isEqualTo(10.0); | ||
assertThat(interval.h()).isEqualTo(0.05); | ||
assertThat(interval.n()).isEqualTo(100); | ||
} | ||
|
||
@Test | ||
void rebornWithH() { | ||
var interval = new Interval(2.5, 10.5, 10); | ||
|
||
interval.reborn(5.0, 10.0, 0.2); | ||
|
||
assertThat(interval.x1()).isEqualTo(5.0); | ||
assertThat(interval.x2()).isEqualTo(10.0); | ||
assertThat(interval.h()).isEqualTo(0.2); | ||
assertThat(interval.n()).isEqualTo(25); | ||
} | ||
|
||
@Test | ||
void x() { | ||
var interval = new Interval(2.0, 12.0, 5); | ||
|
||
assertThat(interval.x(0)).isEqualTo(2.0); | ||
assertThat(interval.x(2)).isEqualTo(6.0); | ||
} | ||
|
||
@Test | ||
void i() { | ||
var interval = new Interval(2.0, 12.0, 5); | ||
|
||
assertThat(interval.i(2.0)).isEqualTo(0); | ||
assertThat(interval.i(5.9)).isEqualTo(1); | ||
assertThat(interval.i(6.1)).isEqualTo(2); | ||
} | ||
|
||
@Test | ||
void saveFuncSimple() { | ||
// TODO | ||
} | ||
|
||
@Test | ||
void saveFuncForParameterizedXAndY() { | ||
// TODO | ||
} | ||
} |