-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #127
- Loading branch information
Showing
5 changed files
with
97 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,22 @@ | ||
name: Rust - test rust_decimal feature | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run the integration tests for the rust_decimal feature set | ||
run: cargo test --test integration --features rust_decimal | ||
|
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
Binary file not shown.
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,69 @@ | ||
// Test case that compares a file generated by rust_xlsxwriter with a file | ||
// created by Excel. | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
#[cfg(feature = "rust_decimal")] | ||
use rust_decimal::Decimal; | ||
|
||
use crate::common; | ||
use rust_xlsxwriter::{Format, Workbook, XlsxError}; | ||
|
||
// Test case to demonstrate creating a basic file with some numeric cell data. | ||
fn create_new_xlsx_file_1(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
let worksheet = workbook.add_worksheet(); | ||
let format = Format::new().set_num_format("\\$0.00"); | ||
|
||
worksheet.write(0, 0, 2.1)?; | ||
worksheet.write_with_format(1, 0, 2.1, &format)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
// Write numbers with rust_decimal. | ||
#[cfg(feature = "rust_decimal")] | ||
fn create_new_xlsx_file_2(filename: &str) -> Result<(), XlsxError> { | ||
let mut workbook = Workbook::new(); | ||
let worksheet = workbook.add_worksheet(); | ||
let format = Format::new().set_num_format("\\$0.00"); | ||
|
||
let decimal = Decimal::new(210, 2); | ||
|
||
worksheet.write(0, 0, decimal)?; | ||
worksheet.write_with_format(1, 0, decimal, &format)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
workbook.save(filename)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn decimal01_1() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("decimal01") | ||
.set_function(create_new_xlsx_file_1) | ||
.unique("1") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} | ||
|
||
#[test] | ||
fn decimal01_2() { | ||
let test_runner = common::TestRunner::new() | ||
.set_name("decimal01") | ||
.set_function(create_new_xlsx_file_2) | ||
.unique("2") | ||
.initialize(); | ||
|
||
test_runner.assert_eq(); | ||
test_runner.cleanup(); | ||
} |
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