summaryrefslogtreecommitdiff
path: root/unittest/my_decimal
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-12-13 00:10:40 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-13 00:10:40 +0100
commit162399515813a4e23c8735473f9d2dd622a6679b (patch)
tree39077fdabea60983c59899ce3d28e84c4d97c7e6 /unittest/my_decimal
parent5908d7ebb81bc2d52c67e519a4643372cb9f08bd (diff)
parent0ed474484c037a32bea32abaecd3ff770f40bd49 (diff)
downloadmariadb-git-162399515813a4e23c8735473f9d2dd622a6679b.tar.gz
Merge branch '5.5' into 10.0
Diffstat (limited to 'unittest/my_decimal')
-rw-r--r--unittest/my_decimal/my_decimal-t.cc34
1 files changed, 32 insertions, 2 deletions
diff --git a/unittest/my_decimal/my_decimal-t.cc b/unittest/my_decimal/my_decimal-t.cc
index 48d00465af9..92c4bdee8e4 100644
--- a/unittest/my_decimal/my_decimal-t.cc
+++ b/unittest/my_decimal/my_decimal-t.cc
@@ -61,12 +61,42 @@ test_copy_and_compare()
}
+static int
+test_decimal2string()
+{
+ decimal_t d1;
+ decimal_digit_t buffer[DECIMAL_BUFF_LENGTH+2];
+ char *str_end;
+ const char strnum[]= "0.1234567890123456789012345678901234567890123467";
+ char strbuff[50];
+ int len= 40;
+ int i;
+
+ bzero(strbuff, sizeof(strbuff));
+ str_end= (char *)(strnum + (sizeof(strnum) - 1));
+
+ d1.len= DECIMAL_BUFF_LENGTH + 2;
+ d1.buf= buffer;
+
+ string2decimal(strnum, &d1, &str_end);
+ decimal2string(&d1, strbuff, &len, 0, 0, 'X');
+
+ /* last digit is not checked due to possible rounding */
+ for (i= 0; i < 38 && strbuff[i] == strnum[i]; i++);
+ ok(i == 38, "Number");
+ for (i= 39; i < 50 && strbuff[i] == 0; i++);
+ ok(i == 50, "No overrun");
+
+ return 0;
+
+}
int main()
{
- plan(13);
+ plan(15);
diag("Testing my_decimal constructor and assignment operators");
test_copy_and_compare();
-
+ test_decimal2string();
+
return exit_status();
}