-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for worksheet range return values.
- Loading branch information
Showing
1 changed file
with
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Tests for the lib_xlsx_writer library. | ||
* | ||
* Copyright 2014-2020, John McNamara, [email protected] | ||
* | ||
*/ | ||
|
||
#include "../ctest.h" | ||
#include "../helper.h" | ||
|
||
#include "xlsxwriter/worksheet.h" | ||
|
||
|
||
// Test the return value for various worksheet functions that handle 1 or 2D ranges. | ||
CTEST(worksheet, bound_checks01) { | ||
|
||
int err; | ||
FILE* testfile = lxw_tmpfile(NULL); | ||
|
||
lxw_row_t MAX_ROW = 1048576; | ||
lxw_col_t MAX_COL = 16384; | ||
|
||
lxw_worksheet *worksheet = lxw_worksheet_new(NULL); | ||
lxw_format *format = lxw_format_new(); | ||
|
||
worksheet->file = testfile; | ||
worksheet_select(worksheet); | ||
|
||
err = worksheet_write_number(worksheet, 0, MAX_COL, 123, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_number(worksheet, MAX_ROW, 0, 123, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_number(worksheet, MAX_ROW, MAX_COL, 123, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_string(worksheet, MAX_ROW, 0, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_string(worksheet, 0, MAX_COL, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_string(worksheet, MAX_ROW, MAX_COL, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_number(worksheet, MAX_ROW, 0, 123, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_number(worksheet, 0, MAX_COL, 123, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_number(worksheet, MAX_ROW, MAX_COL, 123, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_blank(worksheet, MAX_ROW, 0, format); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_blank(worksheet, 0, MAX_COL, format); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_blank(worksheet, MAX_ROW, MAX_COL, format); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_formula(worksheet, MAX_ROW, 0, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_formula(worksheet, 0, MAX_COL, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_formula(worksheet, MAX_ROW, MAX_COL, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_array_formula(worksheet, 0, 0, 0, MAX_COL, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_array_formula(worksheet, 0, 0, MAX_ROW, 0, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_array_formula(worksheet, 0, MAX_COL, 0, 0, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_array_formula(worksheet, MAX_ROW, 0, 0, 0, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_write_array_formula(worksheet, MAX_ROW, MAX_COL, MAX_ROW, MAX_COL, "=A1", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_merge_range(worksheet, 0, 0, 0, MAX_COL, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_merge_range(worksheet, 0, 0, MAX_ROW, 0, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_merge_range(worksheet, 0, MAX_COL, 0, 0, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_merge_range(worksheet, MAX_ROW, 0, 0, 0, "Foo", NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_set_column(worksheet, 6, MAX_COL, 17, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
err = worksheet_set_column(worksheet, MAX_COL, 6, 17, NULL); | ||
ASSERT_EQUAL(LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, err); | ||
|
||
lxw_worksheet_assemble_xml_file(worksheet); | ||
|
||
lxw_worksheet_free(worksheet); | ||
} |