Skip to content

Commit db207ce

Browse files
committed
update cookbook_when documentation and tests remove characters. A pattern of a function is not found and the characters ascii a and v are not removed
1 parent efa8cc4 commit db207ce

5 files changed

Lines changed: 73 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"new string 1": "string without spaces",
3+
"new string 2": "string \nall \nin \na \nline",
4+
"new string 3": "a character have to be erase",
5+
"new string 4": "a \b c d e \f g h i j k l m \n o p q \r s \t u v w x y z",
6+
"to remove": "a"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"new_string_1":"stringwithoutspaces","new_string_2":"string all in a line","new_string_3":"a character have to be erase","new_string_4":"acdeghijklmopqsuvwxyz","to_remove":"a"}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Given I have a 'string' named 'new string 1'
2+
Given I have a 'string' named 'new string 2'
3+
Given I have a 'string' named 'new string 3'
4+
Given I have a 'string' named 'new string 4'
5+
Given I have a 'string' named 'to remove'
6+
7+
#removes all spaces in a string
8+
When I remove spaces in 'new string 1'
9+
10+
#removes all newlines from a string
11+
When I remove newlines in 'new string 2'
12+
13+
#remove space ad letters b, f, n, r, t
14+
When I compact ascii strings in 'new string 4'
15+
16+
Then print data

docs/pages/zencode-cookbook-when.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,25 @@ the output will be
469469

470470
### Remove characters
471471

472+
The following function allow to remove specific charaters from a string.
473+
The third function allows to remove from a string all spaces and the characters b, f, n, r, t if preceded by "\"
474+
Given the following strings of data
475+
476+
[](../_media/examples/zencode_cookbook/cookbook_when/when_remove_char.data.json ':include :type=code json')
477+
478+
the codes
479+
480+
[](../_media/examples/zencode_cookbook/cookbook_when/when_remove_char.zen ':include :type=code gherkin')
481+
482+
will give the output
483+
484+
[](../_media/examples/zencode_cookbook/cookbook_when/when_remove_char.out.json ':include :type=code json')
485+
486+
472487
```gherkin
473-
When I remove spaces in ''
474-
When I remove newlines in ''
488+
#could be a bug here?
475489
When I remove all occurrences of character '' in ''
476-
When I compact ascii strings in ''
490+
477491
```
478492

479493
### Count character occurrences

test/zencode/cookbook_when.bats

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,4 +1320,36 @@ Then print the data
13201320
EOF
13211321
save_output when_table_pickup.out.json
13221322
assert_output '{"dictionary":{"string_1":"string_dic_1","string_2":"string_dic_2","string_3":"string_dic_3"},"string_1":"string_dic_1","string_2":"c3RyaW5nX2RpY18y","string_3":"string_dic_3"}'
1323+
}
1324+
1325+
@test "remove characters" {
1326+
cat <<EOF | save_asset when_remove_char.data.json
1327+
{
1328+
"new string 1": "string without spaces",
1329+
"new string 2": "string \nall \nin \na \nline",
1330+
"new string 3": "a character have to be erase",
1331+
"new string 4": "a \b c d e \f g h i j k l m \n o p q \r s \t u v w x y z",
1332+
"to remove": "a"
1333+
}
1334+
EOF
1335+
cat <<EOF | zexe when_remove_char.zen when_remove_char.data.json
1336+
Given I have a 'string' named 'new string 1'
1337+
Given I have a 'string' named 'new string 2'
1338+
Given I have a 'string' named 'new string 3'
1339+
Given I have a 'string' named 'new string 4'
1340+
Given I have a 'string' named 'to remove'
1341+
1342+
#removes all spaces in a string
1343+
When I remove spaces in 'new string 1'
1344+
1345+
#removes all newlines from a string
1346+
When I remove newlines in 'new string 2'
1347+
1348+
#remove spaces ad letters b, f, n, r, t
1349+
When I compact ascii strings in 'new string 4'
1350+
1351+
Then print data
1352+
EOF
1353+
save_output when_remove_char.out.json
1354+
assert_output '{"new_string_1":"stringwithoutspaces","new_string_2":"string all in a line","new_string_3":"a character have to be erase","new_string_4":"acdeghijklmopqsuvwxyz","to_remove":"a"}'
13231355
}

0 commit comments

Comments
 (0)