Skip to content

Commit 233ac22

Browse files
committed
AJ-865:add test case about illegal_string
1 parent 6044159 commit 233ac22

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

test/com/xxdb/DBConnectionTest.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.xxdb;
22

33
import com.alibaba.fastjson2.JSONObject;
4+
import com.sun.org.apache.xml.internal.utils.StringVector;
45
import com.xxdb.data.Dictionary;
56
import com.xxdb.data.Vector;
67
import com.xxdb.data.*;
@@ -5057,6 +5058,39 @@ public void test_DBConnection_upload_illegal_string() throws IOException {
50575058
assertEquals("", table2.getColumn(3).get(1).getString());
50585059
assertEquals("blob1AMZN", table2.getColumn(3).get(2).getString());
50595060
}
5061+
@Test
5062+
public void test_DBConnection_upload_illegal_string1() throws IOException {
5063+
DBConnection connection = new DBConnection();
5064+
connection.connect(HOST, PORT, "admin", "123456");
5065+
5066+
BasicString sv = new BasicString("blob1AM\0ZN");
5067+
Map<String, Entity> upObj = new HashMap<String, Entity>();
5068+
upObj.put("SV", (Entity) sv);
5069+
conn.upload(upObj);
5070+
Entity sv1 = conn.run("SV;\n");
5071+
Assert.assertEquals("blob1AM",sv1.getString());
5072+
}
5073+
@Test
5074+
public void test_DBConnection_upload_ASCII_char() throws IOException {
5075+
DBConnection connection = new DBConnection();
5076+
connection.connect(HOST, PORT, "admin", "123456");
5077+
5078+
for (int i = 1; i <= 0x7F; i++) {
5079+
char c = (char) i;
5080+
System.out.printf("Unicode: \\u%04X | Dec: %3d | Char: %s%n",
5081+
i, i,
5082+
(i < 32 || i == 127) ? "[控制字符]" : c);
5083+
BasicString sv = new BasicString(String.valueOf(c));
5084+
Map<String, Entity> upObj = new HashMap<String, Entity>();
5085+
upObj.put("SV", (Entity) sv);
5086+
conn.upload(upObj);
5087+
Entity sv1 = conn.run("SV;\n");
5088+
if (i != 13){
5089+
Assert.assertEquals(sv1,(Entity)sv);
5090+
}
5091+
}
5092+
}
5093+
50605094
@Test
50615095
public void test_DBConnection_run_ASCII_char() throws IOException, InterruptedException {
50625096
DBConnection connection = new DBConnection();
@@ -5106,7 +5140,7 @@ public void test_connection_enableSeqNo_true() throws Exception {
51065140
assertEquals(30000, res2.rows());
51075141
connection.close();
51085142
}
5109-
5143+
51105144
@Test
51115145
public void test_connection_enableSeqNo_false() throws Exception {
51125146
DBConnection connection = new DBConnection(false, false, false);

0 commit comments

Comments
 (0)