Additional column and bar chart tests.

This commit is contained in:
John McNamara 2016-05-08 23:27:21 +01:00
parent 87e92d31b1
commit fe793bdcb2
16 changed files with 359 additions and 0 deletions

View File

@ -0,0 +1,44 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_bar08.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_BAR);
/* For testing, copy the randomly generated axis ids in the target file. */
chart->axis_id_1 = 40522880;
chart->axis_id_2 = 40524416;
uint8_t data[5][3] = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9},
{4, 8, 12},
{5, 10, 15}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 3; col++)
worksheet_write_number(worksheet, row, col, data[row][col] , NULL);
worksheet_write_url(worksheet, CELL("A7"), "http://www.perl.com/" , NULL);
chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5");
chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5");
chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5");
worksheet_insert_chart(worksheet, CELL("E9"), chart);
return workbook_close(workbook);
}

View File

@ -0,0 +1,60 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_bar11.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart1 = workbook_add_chart(workbook, LXW_CHART_BAR);
lxw_chart *chart2 = workbook_add_chart(workbook, LXW_CHART_BAR);
lxw_chart *chart3 = workbook_add_chart(workbook, LXW_CHART_BAR);
/* For testing, copy the randomly generated axis ids in the target file. */
chart1->axis_id_1 = 40274944;
chart1->axis_id_2 = 40294272;
chart2->axis_id_1 = 62355328;
chart2->axis_id_2 = 62356864;
chart3->axis_id_1 = 79538816;
chart3->axis_id_2 = 65422464;
uint8_t data[5][3] = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9},
{4, 8, 12},
{5, 10, 15}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 3; col++)
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
worksheet_write_url(worksheet, CELL("A7"), "http://www.perl.com/", NULL);
worksheet_write_url(worksheet, CELL("A8"), "http://www.perl.org/", NULL);
worksheet_write_url(worksheet, CELL("A9"), "http://www.perl.net/", NULL);
chart_add_series(chart1, NULL, "=Sheet1!$A$1:$A$5");
chart_add_series(chart1, NULL, "=Sheet1!$B$1:$B$5");
chart_add_series(chart1, NULL, "=Sheet1!$C$1:$C$5");
chart_add_series(chart2, NULL, "=Sheet1!$A$1:$A$5");
chart_add_series(chart2, NULL, "=Sheet1!$B$1:$B$5");
chart_add_series(chart3, NULL, "=Sheet1!$A$1:$A$5");
worksheet_insert_chart(worksheet, CELL("E9"), chart1);
worksheet_insert_chart(worksheet, CELL("D25"), chart2);
worksheet_insert_chart(worksheet, CELL("L32"), chart3);
return workbook_close(workbook);
}

View File

@ -0,0 +1,42 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_column05.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, "Foo");
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
/* For testing, copy the randomly generated axis ids in the target file. */
chart->axis_id_1 = 47292800;
chart->axis_id_2 = 47295104;
uint8_t data[5][3] = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9},
{4, 8, 12},
{5, 10, 15}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 3; col++)
worksheet_write_number(worksheet, row, col, data[row][col] , NULL);
chart_add_series(chart, NULL, "=Foo!$A$1:$A$5");
chart_add_series(chart, NULL, "=Foo!$B$1:$B$5");
chart_add_series(chart, NULL, "=Foo!$C$1:$C$5");
worksheet_insert_chart(worksheet, CELL("E9"), chart);
return workbook_close(workbook);
}

View File

@ -0,0 +1,43 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_column06.xlsx");
lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
/* For testing, copy the randomly generated axis ids in the target file. */
chart->axis_id_1 = 47363584;
chart->axis_id_2 = 49673344;
uint8_t data[5][3] = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9},
{4, 8, 12},
{5, 10, 15}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 3; col++)
worksheet_write_number(worksheet1, row, col, data[row][col], NULL);
chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5");
chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5");
chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5");
worksheet_insert_chart(worksheet2, CELL("E9"), chart);
return workbook_close(workbook);
}

View File

@ -0,0 +1,52 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_column07.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
/* For testing, copy the randomly generated axis ids in the target file. */
chart->axis_id_1 = 68810240;
chart->axis_id_2 = 68811776;
uint8_t data[5][3] = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9},
{4, 8, 12},
{5, 10, 15}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 3; col++)
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
lxw_chart_series *series1 = chart_add_series(chart, NULL, "=(Sheet1!$A$1:$A$2,Sheet1!$A$4:$A$5)");
worksheet_insert_chart(worksheet, CELL("E9"), chart);
/* Add the cached data for testing. */
uint8_t test_data[4][3] = {
{1, 2, 3},
{2, 4, 6},
{4, 8, 12},
{5, 10, 15}
};
lxw_chart_add_data_cache(series1->values, test_data[0], 4, 3, 0);
return workbook_close(workbook);
}

View File

@ -0,0 +1,55 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_column08.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
/* For testing, copy the randomly generated axis ids in the target file. */
chart->axis_id_1 = 68809856;
chart->axis_id_2 = 68811392;
uint8_t data[5][3] = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9},
{4, 8, 12},
{5, 10, 15}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 3; col++)
worksheet_write_number(worksheet, row, col, data[row][col] , NULL);
lxw_chart_series *series1 = chart_add_series(chart,
"=(Sheet1!$A$1:$A$2,Sheet1!$A$4:$A$5)",
"=(Sheet1!$B$1:$B$2,Sheet1!$B$4:$B$5)");
worksheet_insert_chart(worksheet, CELL("E9"), chart);
/* Add the cached data for testing. */
uint8_t test_data[4][3] = {
{1, 2, 3},
{2, 4, 6},
{4, 8, 12},
{5, 10, 15}
};
lxw_chart_add_data_cache(series1->categories, test_data[0], 4, 3, 0);
lxw_chart_add_data_cache(series1->values, test_data[0], 4, 3, 1);
return workbook_close(workbook);
}

View File

@ -0,0 +1,42 @@
/*****************************************************************************
* Test cases for libxlsxwriter.
*
* Test to compare output against Excel files.
*
* Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = new_workbook("test_chart_column09.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
/* For testing, copy the randomly generated axis ids in the target file. */
chart->axis_id_1 = 47400832;
chart->axis_id_2 = 61387136;
uint8_t data[5][2] = {
{1, 1},
{2, 2},
{3, 3},
{4, 2},
{5, 1}
};
int row, col;
for (row = 0; row < 5; row++)
for (col = 0; col < 2; col++)
worksheet_write_number(worksheet, row, col, data[row][col] , NULL);
chart_add_series(chart,
"=Sheet1!$A$1:$A$5",
"=Sheet1!$B$1:$B$5");
worksheet_insert_chart(worksheet, CELL("E9"), chart);
return workbook_close(workbook);
}

View File

@ -28,12 +28,18 @@ class TestCompareXLSXFiles(base_test_class.XLSXBaseTest):
def test_chart_bar05(self):
self.run_exe_test('test_chart_bar05')
def test_chart_bar08(self):
self.run_exe_test('test_chart_bar08')
def test_chart_bar09(self):
self.run_exe_test('test_chart_bar09')
def test_chart_bar10(self):
self.run_exe_test('test_chart_bar10')
def test_chart_bar11(self):
self.run_exe_test('test_chart_bar11')
def test_chart_bar51(self):
self.run_exe_test('test_chart_bar51')

View File

@ -21,3 +21,18 @@ class TestCompareXLSXFiles(base_test_class.XLSXBaseTest):
def test_chart_column03(self):
self.run_exe_test('test_chart_column03')
def test_chart_column05(self):
self.run_exe_test('test_chart_column05')
def test_chart_column06(self):
self.run_exe_test('test_chart_column06')
def test_chart_column07(self):
self.run_exe_test('test_chart_column07')
def test_chart_column08(self):
self.run_exe_test('test_chart_column08')
def test_chart_column09(self):
self.run_exe_test('test_chart_column09')

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.