-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4f07ca
commit 1eb6cf9
Showing
11 changed files
with
259 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a, b, c d, e | ||
"Hello World", \"Hello World\", Hello World, 2 | ||
"Hello World", \"Hello World\", Hello World, 2 | ||
"Hello World", \"Hello World\", Hello World, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Ballerina generates this directory during the compilation of a package. | ||
# It contains compiler-generated artifacts and the final executable if this is an application package. | ||
target/ | ||
|
||
# Ballerina maintains the compiler-generated source code here. | ||
# Remove this if you want to commit generated sources. | ||
generated/ | ||
|
||
# Contains configuration values used during development time. | ||
# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details. | ||
Config.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
org = "ballerina" | ||
name = "unicode_tests" | ||
version = "0.1.0" | ||
|
||
[[dependency]] | ||
org = "ballerina" | ||
name = "csv_commons" | ||
repository = "local" | ||
version = "0.1.0" | ||
|
||
[platform.java17] | ||
graalvmCompatible = true |
55 changes: 55 additions & 0 deletions
55
ballerina-tests/unicode-tests/tests/escape_character_test.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import ballerina/data.csv as csv; | ||
import ballerina/test; | ||
|
||
@test:Config | ||
function testEscapedCharactres() returns error? { | ||
string csvString = string `a, b | ||
quote\"\"quoted\"quote, 1 | ||
backslash\\backslash, 2 | ||
newline\nnewline, 3 | ||
tab\ttab, 5 | ||
unicode\u0061unicode, 6 | ||
slash\/slash, 9 | ||
quoted string \\'abc\\', 10`; | ||
|
||
record{string a; int b;}[]|csv:Error rec = csv:parseStringToRecord(csvString); | ||
test:assertEquals(rec, [ | ||
{a: string `quote""quoted"quote`, b: 1}, | ||
{a: string `backslash${"\\"}backslash`, b: 2}, | ||
{a: string `newline${"\n"}newline`, b: 3}, | ||
{a: string `tab${"\t"}tab`, b: 5}, | ||
{a: string `unicodeaunicode`, b: 6}, | ||
{a: string `slash/slash`, b: 9}, | ||
{a: string `quoted string \'abc\'`, b: 10} | ||
]); | ||
} | ||
|
||
@test:Config | ||
function testEscapedCharactres2() returns error? { | ||
string csvString = string `a, b | ||
backspace\bbackspace, 7`; | ||
|
||
record{string a; int b;}[]|csv:Error rec = csv:parseStringToRecord(csvString); | ||
test:assertTrue(rec is record{string a; int b;}[]); | ||
} | ||
|
||
@test:Config | ||
function testEscapedCharactres3() returns error? { | ||
string csvString = string ` a c, b | ||
carriage return\r carriage return, 4`; | ||
|
||
record{}[]|csv:Error rec = csv:parseStringToRecord(csvString); | ||
test:assertEquals(rec, [ | ||
{"a c": string `carriage return${"\r"} carriage return`, b: 4} | ||
]); | ||
} | ||
|
||
@test:Config | ||
function testEscapedCharactres4() returns error? { | ||
string csvString = string `a, b | ||
form feed\f form feed, 8`; | ||
|
||
record{string a; int b;}[]|csv:Error rec = csv:parseStringToRecord(csvString); | ||
test:assertTrue(rec is record {string a; int b;}[]); | ||
// TODO: Add tests after supports \f by Ballerina | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.