Commit 4d53a758 authored by Monty's avatar Monty

Updated tests in decimal.c that match current API and usage

parent 0df51e61
......@@ -2619,7 +2619,8 @@ void test_d2f(const char *s, int ex)
void test_d2b2d(const char *str, int p, int s, const char *orig, int ex)
{
char s1[100], buf[100], *end;
char s1[100], *end;
uchar buf[100];
int res, i, size=decimal_bin_size(p, s);
sprintf(s1, "'%s'", str);
......@@ -2937,27 +2938,27 @@ int main()
test_f2d(1234500009876.5, 0);
printf("==== ulonglong2decimal ====\n");
test_ull2d(ULL(12345), "12345", 0);
test_ull2d(ULL(0), "0", 0);
test_ull2d(ULL(18446744073709551615), "18446744073709551615", 0);
test_ull2d(12345ULL, "12345", 0);
test_ull2d(0ULL, "0", 0);
test_ull2d(18446744073709551615ULL, "18446744073709551615", 0);
printf("==== decimal2ulonglong ====\n");
test_d2ull("12345", "12345", 0);
test_d2ull("0", "0", 0);
test_d2ull("18446744073709551615", "18446744073709551615", 0);
test_d2ull("18446744073709551616", "18446744073", 2);
test_d2ull("18446744073709551616", "18446744073709551615", 2);
test_d2ull("-1", "0", 2);
test_d2ull("1.23", "1", 1);
test_d2ull("9999999999999999999999999.000", "9999999999999999", 2);
test_d2ull("9999999999999999999999999.000", "18446744073709551615", 2);
printf("==== longlong2decimal ====\n");
test_ll2d(LL(-12345), "-12345", 0);
test_ll2d(LL(-1), "-1", 0);
test_ll2d(LL(-9223372036854775807), "-9223372036854775807", 0);
test_ll2d(ULL(9223372036854775808), "-9223372036854775808", 0);
test_ll2d(-12345LL, "-12345", 0);
test_ll2d(-1LL, "-1", 0);
test_ll2d(-9223372036854775807LL, "-9223372036854775807", 0);
test_ll2d(9223372036854775808ULL, "-9223372036854775808", 0);
printf("==== decimal2longlong ====\n");
test_d2ll("18446744073709551615", "18446744073", 2);
test_d2ll("18446744073709551615", "9223372036854775807", 2);
test_d2ll("-1", "-1", 0);
test_d2ll("-1.23", "-1", 1);
test_d2ll("-9223372036854775807", "-9223372036854775807", 0);
......@@ -3131,12 +3132,12 @@ int main()
printf("==== decimal2string ====\n");
test_pr("123.123", 0, 0, 0, "123.123", 0);
test_pr("123.123", 7, 3, '0', "123.123", 0);
test_pr("123.123", 9, 3, '0', "00123.123", 0);
test_pr("123.123", 9, 4, '0', "0123.1230", 0);
test_pr("123.123", 9, 5, '0', "123.12300", 0);
test_pr("123.123", 9, 2, '0', "000123.12", 1);
test_pr("123.123", 9, 6, '0', "23.123000", 2);
test_pr("123.123", 7, 3, '0', "0123.123", 0);
test_pr("123.123", 9, 3, '0', "000123.123", 0);
test_pr("123.123", 9, 4, '0', "00123.1230", 0);
test_pr("123.123", 9, 5, '0', "0123.12300", 0);
test_pr("123.123", 9, 2, '0', "0000123.12", 1);
test_pr("123.123", 8, 6, '0', "23.123000", 2);
printf("==== decimal_shift ====\n");
test_sh("123.123", 1, "1231.23", 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment