/* * Tests for the lib_xlsx_writer library. * * Copyright 2014-2021, John McNamara, jmcnamara@cpan.org * */ #include "../ctest.h" #include "../helper.h" #include "../../../include/xlsxwriter/chart.h" // Test assembling a complete Chart file. CTEST(chart, chart01) { lxw_chart_series *series1; lxw_chart_series *series2; uint8_t data[5][3] = { {1, 2, 3}, {2, 4, 6}, {3, 6, 9}, {4, 8, 12}, {5, 10, 15} }; char* got; char exp[] = "\n" "" "" "" "" "" "" "" "" "" "" "" "" "" "Sheet1!$A$1:$A$5" "" "General" "" "" "1" "" "" "2" "" "" "3" "" "" "4" "" "" "5" "" "" "" "" "" "" "" "" "" "" "Sheet1!$B$1:$B$5" "" "General" "" "" "2" "" "" "4" "" "" "6" "" "" "8" "" "" "10" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; FILE* testfile = lxw_tmpfile(NULL); lxw_chart *chart = lxw_chart_new(LXW_CHART_BAR); chart->file = testfile; series1 = chart_add_series(chart, NULL, "Sheet1!$A$1:$A$5"); series2 = chart_add_series(chart, NULL, "Sheet1!$B$1:$B$5"); lxw_chart_add_data_cache(series1->values, data[0], 5, 3, 0); lxw_chart_add_data_cache(series2->values, data[0], 5, 3, 1); lxw_chart_assemble_xml_file(chart); RUN_XLSX_STREQ_SHORT(exp, got); lxw_chart_free(chart); }