@Test
public void testWriteVectorToCSVFile() throws IOException {

    DenseVector vector = new DenseVector(MathTestConstants.STORAGE_SIZE);
    for (int i = 0; i < vector.size(); i++)
        vector.set(i, Math.random());
    Path file = createTempFile("vector", ".csv");
    Tracer.saveAsCsv(vector, DEFAULT_FORMAT, file.toString());
    System.out.println("Vector exported: " + file.getFileName());
    List<String> strings = Files.readAllLines(file);
    Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
    String[] csvVals = reduce.orElse("").split(",");
    for (int i = 0; i < vector.size(); i++) {
        Double csvVal = Double.valueOf(csvVals[i]);
        assertEquals("Unexpected value.", csvVal, vector.get(i), DEFAULT_DELTA);
    }
    Files.deleteIfExists(file);
}