-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from SasinduDilshara/development-revamp
Allow empty strings to represent nil values using user configs
- Loading branch information
Showing
11 changed files
with
187 additions
and
41 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
4 changes: 4 additions & 0 deletions
4
ballerina-tests/type-compatible-tests/tests/csv_content_2.txt
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 World1", \"Hello World2\", Hello World3, 21 | ||
"Hello World1", \"Hello World2\", Hello World3, 22 | ||
"Hello World1", \"Hello World2\", Hello World3, 23 |
58 changes: 58 additions & 0 deletions
58
ballerina-tests/type-compatible-tests/tests/nill_type_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,58 @@ | ||
import ballerina/data.csv; | ||
import ballerina/test; | ||
|
||
type Book1 record { | ||
()|string name; | ||
()|string author; | ||
()|string year; | ||
}; | ||
|
||
string csvString1 = string `name,author,year | ||
,b,c | ||
a,,c | ||
a,b,`; | ||
|
||
@test:Config{} | ||
function testEmptyStringWithNilConfig() { | ||
Book1[]|error books1 = csv:parseString(csvString1, {nilValue: ""}); | ||
test:assertEquals(books1, [ | ||
{name: null, author: "b", year: "c"}, | ||
{name: "a", author: null, year: "c"}, | ||
{name: "a", author: "b", year: null} | ||
]); | ||
|
||
Book1[]|error books2 = csv:parseString(csvString1); | ||
test:assertEquals(books2, [ | ||
{name: "", author: "b", year: "c"}, | ||
{name: "a", author: "", year: "c"}, | ||
{name: "a", author: "b", year: ""} | ||
]); | ||
|
||
(boolean|()|string|int)[][]|error arrbooks1 = csv:parseString(csvString1, {nilValue: ""}); | ||
test:assertEquals(arrbooks1, [ | ||
[null, "b", "c"], | ||
["a", null, "c"], | ||
["a", "b", null] | ||
]); | ||
|
||
(boolean|()|string|int)[][2]|error arrbooks2 = csv:parseString(csvString1, {nilValue: ""}); | ||
test:assertEquals(arrbooks2, [ | ||
[null, "b"], | ||
["a", null], | ||
["a", "b"] | ||
]); | ||
|
||
(boolean|()|string|int)[][]|error arrbooks3 = csv:parseString(csvString1); | ||
test:assertEquals(arrbooks3, [ | ||
["", "b", "c"], | ||
["a", "", "c"], | ||
["a", "b", ""] | ||
]); | ||
|
||
(boolean|()|string|int)[][2]|error arrbooks4 = csv:parseString(csvString1); | ||
test:assertEquals(arrbooks4, [ | ||
["", "b"], | ||
["a", ""], | ||
["a", "b"] | ||
]); | ||
} |
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
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.