SAP / go-ase

SAP ASE Database Client for Go
Apache License 2.0
25 stars 14 forks source link

Decimal better comparison in tests #57

Closed ntnn closed 4 years ago

ntnn commented 4 years ago

Description

@fwilhelm92 found displaying issues which were fixed in #56. While investigating these issues we found that the integration tests were using the string output to compare the sample decimal and the decimal read from ASE. That these issues didn't occur in the tests stemmed from both the sample and the read decimal being passed through the same erroneous error path.

Originally I chose to compare by string because the sample decimal is generated with precision and scale set to match exactly the required sample - while the decimal read from ASE has the precision and scale set to the column constraints. This resulted in the two decimal looking the same when printed but entirely different on a member basis - causing the .Cmp method, which compared the precision, scale and underlying big.Int, to fail.

This PR changes the generation for sample decimals in the tests to use the same precision and scale, allowing to use the more correct .Cmp method to compare the generated sample decimal and the read ASE decimal.

How was the patch tested?

Manually and using make integration.