Skip to content

Commit 38bfe4f

Browse files
committed
Add unittest for Row.getName.
1 parent b27352f commit 38bfe4f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

source/mysql/result.d

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,31 @@ public:
8181
return _names[index];
8282
}
8383

84+
@("getName")
85+
debug(MYSQLN_TESTS)
86+
unittest
87+
{
88+
import mysql.test.common;
89+
import mysql.commands;
90+
mixin(scopedCn);
91+
cn.exec("DROP TABLE IF EXISTS `row_getName`");
92+
cn.exec("CREATE TABLE `row_getName` (someValue INTEGER, another INTEGER) ENGINE=InnoDB DEFAULT CHARSET=utf8");
93+
cn.exec("INSERT INTO `row_getName` VALUES (1, 2), (3, 4)");
94+
95+
enum sql = "SELECT another, someValue FROM `row_getName`";
96+
97+
auto rows = cn.query(sql).array;
98+
assert(rows.length == 2);
99+
assert(rows[0][0] == 2);
100+
assert(rows[0][1] == 1);
101+
assert(rows[0].getName(0) == "another");
102+
assert(rows[0].getName(1) == "someValue");
103+
assert(rows[1][0] == 4);
104+
assert(rows[1][1] == 3);
105+
assert(rows[1].getName(0) == "another");
106+
assert(rows[1].getName(1) == "someValue");
107+
}
108+
84109
/++
85110
Check if a column in the result row was NULL
86111

0 commit comments

Comments
 (0)