Skip to content

Commit

Permalink
net-sf-ucanaccess-fork: Test case overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Nov 4, 2023
1 parent 3f51528 commit 3dd5cee
Show file tree
Hide file tree
Showing 28 changed files with 435 additions and 544 deletions.
28 changes: 15 additions & 13 deletions src/test/java/net/ucanaccess/console/MainTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.ucanaccess.console;

import static org.assertj.core.api.Assertions.assertThat;

import net.ucanaccess.test.util.AbstractBaseTest;
import org.junit.jupiter.api.Test;

Expand All @@ -12,54 +14,54 @@ class MainTest extends AbstractBaseTest {
void testTokenize() throws IOException {
// normal space as token delimiter
List<String> tokens = Main.tokenize("export -t License License.csv");
assertListEquals(tokens, "export", "-t", "License", "License.csv");
assertThat(tokens).containsExactly("export", "-t", "License", "License.csv");

// tab (\t), line-feed (\n) and carriage-return (\r) as token delimiter
tokens = Main.tokenize("export\t-t\nLicense\rLicense.csv");
assertListEquals(tokens, "export", "-t", "License", "License.csv");
assertThat(tokens).containsExactly("export", "-t", "License", "License.csv");

// backslash escapes are not interpreted outside of quote
tokens = Main.tokenize("export -t License c:\\temp\\License.csv");
assertListEquals(tokens, "export", "-t", "License", "c:\\temp\\License.csv");
assertThat(tokens).containsExactly("export", "-t", "License", "c:\\temp\\License.csv");

// backslash escapes are interpreted inside quote, so we have to double escape
tokens = Main.tokenize("export -t License 'c:\\\\temp\\\\License.csv");
assertListEquals(tokens, "export", "-t", "License", "c:\\temp\\License.csv");
assertThat(tokens).containsExactly("export", "-t", "License", "c:\\temp\\License.csv");

// octal escapes are not interpreted outside of quote
tokens = Main.tokenize("export -t License c:\\101");
assertListEquals(tokens, "export", "-t", "License", "c:\\101");
assertThat(tokens).containsExactly("export", "-t", "License", "c:\\101");

// octal escapes are interpreted inside a quote
tokens = Main.tokenize("export -t License 'c:\\101'");
assertListEquals(tokens, "export", "-t", "License", "c:A");
assertThat(tokens).containsExactly("export", "-t", "License", "c:A");

// embedded space inside double quote
tokens = Main.tokenize("export \"License and Address.csv\"");
assertListEquals(tokens, "export", "License and Address.csv");
assertThat(tokens).containsExactly("export", "License and Address.csv");

// embedded space inside single quote
tokens = Main.tokenize("export 'License and Address.csv'");
assertListEquals(tokens, "export", "License and Address.csv");
assertThat(tokens).containsExactly("export", "License and Address.csv");

// single quote and embedded space inside double quote
tokens = Main.tokenize("export \"License 'and' Address.csv\"");
assertListEquals(tokens, "export", "License 'and' Address.csv");
assertThat(tokens).containsExactly("export", "License 'and' Address.csv");

// double quote and embedded space inside single quote
tokens = Main.tokenize("export 'License \"and\" Address.csv'");
assertListEquals(tokens, "export", "License \"and\" Address.csv");
assertThat(tokens).containsExactly("export", "License \"and\" Address.csv");

// backslash escaped double quote inside double quote
tokens = Main.tokenize("export \"\\\"License and Address.csv\\\"\"");
assertListEquals(tokens, "export", "\"License and Address.csv\"");
assertThat(tokens).containsExactly("export", "\"License and Address.csv\"");

// non-breaking-white-space U+00A0 is treated like a normal character
tokens = Main.tokenize("export License\u00A0and\u00A0Address.csv");
assertListEquals(tokens, "export", "License\u00A0and\u00A0Address.csv");
assertThat(tokens).containsExactly("export", "License\u00A0and\u00A0Address.csv");

// any unicode > U+00FF is treated like a normal character, U+202F is NARROW NO-BREAK SPACE
tokens = Main.tokenize("export License\u202Fand\u202FAddress.csv");
assertListEquals(tokens, "export", "License\u202Fand\u202FAddress.csv");
assertThat(tokens).containsExactly("export", "License\u202Fand\u202FAddress.csv");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void testLikeExternal(AccessVersion _accessVersion) throws SQLException, IOExcep

@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("net.ucanaccess.test.util.AccessVersion#getDefaultAccessVersion()")
void testNotLikeExternal(AccessVersion _accessVersion) throws SQLException, IOException {
void testNotLikeExternal(AccessVersion _accessVersion) throws SQLException {
init(_accessVersion);

String tableName = "Tx21";
Expand Down
Loading

0 comments on commit 3dd5cee

Please sign in to comment.