-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes erroneous use of
==
in PricePlot (issue #1237)
- Loading branch information
1 parent
6d857b7
commit 2cc3b0c
Showing
2 changed files
with
50 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tech.tablesaw.plotly; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import tech.tablesaw.api.DateTimeColumn; | ||
import tech.tablesaw.api.DoubleColumn; | ||
import tech.tablesaw.api.Table; | ||
import tech.tablesaw.plotly.api.OHLCPlot; | ||
import tech.tablesaw.plotly.components.Figure; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class OchlTest { | ||
|
||
@Test | ||
void ochlPlotDoesNotThrowIllegalArgumentException() { | ||
// Test to fix bug reported at https://github.com/jtablesaw/tablesaw/issues/1237 | ||
String timeTitle = "time"; | ||
String openTitle = "open"; | ||
String closeTitle = "close"; | ||
String highTitle = "high"; | ||
String lowTitle = "low"; | ||
String graphTitle = "title"; | ||
|
||
LocalDateTime now = LocalDateTime.now(); | ||
List<LocalDateTime> time = List.of(now, now.plusSeconds(5), now.plusSeconds(10)); | ||
List<Double> open = List.of(1d, 2d, 3d); | ||
List<Double> close = List.of(1d, 2d, 3d); | ||
List<Double> high = List.of(1d, 2d, 3d); | ||
List<Double> low = List.of(1d, 2d, 3d); | ||
|
||
DateTimeColumn timeColumn = DateTimeColumn.create(timeTitle, time); | ||
DoubleColumn openColumn = DoubleColumn.create(openTitle, open); | ||
DoubleColumn closeColumn = DoubleColumn.create(closeTitle, close); | ||
DoubleColumn highColumn = DoubleColumn.create(highTitle, high); | ||
DoubleColumn lowColumn = DoubleColumn.create(lowTitle, low); | ||
|
||
Table priceTable = Table.create(timeColumn, openColumn, closeColumn, highColumn, lowColumn); | ||
Figure figure = OHLCPlot.create(graphTitle, priceTable, timeTitle, openTitle, highTitle, lowTitle, closeTitle); | ||
|
||
assertNotNull(figure); | ||
assertDoesNotThrow(() -> IllegalArgumentException.class); | ||
} | ||
} |