summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-05-20 13:34:51 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-05-24 21:27:08 +0200
commitcf52dd174ecf0e6055f4443be9c1fea8bc37b65e (patch)
tree63eba68da735d7d8280e624ae1be9a3d3f78588b /unittest
parentd8e2fa0c49d506bde037fe448dc9840e8e14cf92 (diff)
downloadmariadb-git-cf52dd174ecf0e6055f4443be9c1fea8bc37b65e.tar.gz
MDEV-22545: my_vsnprintf behaves not as in C standard
Added parameter %T for string which should be visibly truncated.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/mysys/my_vsnprintf-t.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/unittest/mysys/my_vsnprintf-t.c b/unittest/mysys/my_vsnprintf-t.c
index 872e88ddd7e..1a0b4080a2d 100644
--- a/unittest/mysys/my_vsnprintf-t.c
+++ b/unittest/mysys/my_vsnprintf-t.c
@@ -61,7 +61,7 @@ static void test_many(const char **res, const char *fmt, ...)
int main(void)
{
- plan(43);
+ plan(47);
test1("Constant string",
"Constant string");
@@ -99,27 +99,33 @@ int main(void)
test1("Width is ignored for strings <x> <y>",
"Width is ignored for strings <%04s> <%5s>", "x", "y");
- test1("Precision works for strings <ab...>",
+ test1("Precision works for strings <abcde>",
"Precision works for strings <%.5s>", "abcdef!");
+ test1("Precision works for strings <ab...>",
+ "Precision works for strings <%.5T>", "abcdef!");
+
+ test1("Flag '`' (backtick) works: `abcd` `op``q` (mysql extension)",
+ "Flag '`' (backtick) works: %`s %`.4s (mysql extension)",
+ "abcd", "op`qrst");
test1("Flag '`' (backtick) works: `abcd` `op``q...` (mysql extension)",
- "Flag '`' (backtick) works: %`s %`.7s (mysql extension)",
+ "Flag '`' (backtick) works: %`T %`.7T (mysql extension)",
"abcd", "op`qrstuuuuuuuuu");
test1("Flag '`' (backtick) works: `abcd` `.` (mysql extension)",
- "Flag '`' (backtick) works: %`s %`.1s (mysql extension)",
+ "Flag '`' (backtick) works: %`T %`.1T (mysql extension)",
"abcd", "op`qrstuuuuuuuuu");
test1("Flag '`' (backtick) works: `abcd` `...` (mysql extension)",
- "Flag '`' (backtick) works: %`s %`.3s (mysql extension)",
+ "Flag '`' (backtick) works: %`T %`.3T (mysql extension)",
"abcd", "op`qrstuuuuuuuuu");
test1("Flag '`' (backtick) works: `abcd` `op...` (mysql extension)",
- "Flag '`' (backtick) works: %`s %`.5s (mysql extension)",
+ "Flag '`' (backtick) works: %`T %`.5T (mysql extension)",
"abcd", "op`qrstuuuuuuuuu");
test1("Flag '`' (backtick) works: `abcd` `op``...` (mysql extension)",
- "Flag '`' (backtick) works: %`s %`.6s (mysql extension)",
+ "Flag '`' (backtick) works: %`T %`.6T (mysql extension)",
"abcd", "op`qrstuuuuuuuuu");
test1("Length modifiers work: 1 * -1 * 2 * 3",
@@ -141,15 +147,21 @@ int main(void)
test1("Asterisk '*' as a width works: < 4>",
"Asterisk '*' as a width works: <%*d>", 5, 4);
- test1("Asterisk '*' as a precision works: <qwe...>",
+ test1("Asterisk '*' as a precision works: <qwerty>",
"Asterisk '*' as a precision works: <%.*s>", 6, "qwertyuiop");
+ test1("Asterisk '*' as a precision works: <qwe...>",
+ "Asterisk '*' as a precision works: <%.*T>", 6, "qwertyuiop");
+
test1("Positional arguments for a width: < 4>",
"Positional arguments for a width: <%1$*2$d>", 4, 5);
- test1("Positional arguments for a precision: <qwe...>",
+ test1("Positional arguments for a precision: <qwerty>",
"Positional arguments for a precision: <%1$.*2$s>", "qwertyuiop", 6);
+ test1("Positional arguments for a precision: <qwe...>",
+ "Positional arguments for a precision: <%1$.*2$T>", "qwertyuiop", 6);
+
test1("Positional arguments and a width: <0000ab>",
"Positional arguments and a width: <%1$06x>", 0xab);