Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: kwio: Adds load_module_text to kwio.sh
load_module_text is a function that creates a dictionary from a .txt file following a particular syntax, as follows: [key]: text The created dictionary is accessed by ${module_text_dictionary[key]}. This is useful to store long strings outside of the code. Adds a little test suite for this function in kwio_test, and a couple test samples in tests/samples. Co-authored-by: Miguel de Mello Carpi <miguelmello@usp.br> Co-authored-by: Lourenço Henrique Moinheiro Martins Sborz Bogo <louhmmsb@usp.br> Signed-off-by: Rodrigo Siqueira <siqueirajordao@riseup.net> Signed-off-by: Eduardo Brancher Urenha <eduardo.urenha@usp.br>
- Loading branch information
1 parent
8076ae1
commit fa872ad
Showing
7 changed files
with
225 additions
and
0 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,26 @@ | ||
[key1]: | ||
Hello, there! How are you? I hope you are enjoying reading this test suit! | ||
[key2]: | ||
Hey, you still there? [] | ||
[key3]: | ||
This should work with multiple lines. | ||
Line 1 | ||
Line 2 | ||
Line 3 | ||
Line 4 | ||
Line 5 | ||
[key4]: | ||
done. | ||
[key5]: | ||
[key6]: | ||
|
||
|
||
|
||
|
||
|
||
The one above should have an empty value. | ||
|
||
[key7]: | ||
|
||
This value should be ok | ||
|
Empty file.
11 changes: 11 additions & 0 deletions
11
tests/samples/load_module_text_test_samples/file_repeated_keys
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 @@ | ||
[Sagan]: | ||
If you wish | ||
to | ||
make an | ||
apple pie | ||
from scratch | ||
you must first invent the Universe. | ||
|
||
[Sagan]: | ||
Extraordinary claims require | ||
extraordinary evidence. |
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 @@ | ||
[this]: This file has text, but does not have a key. |
20 changes: 20 additions & 0 deletions
20
tests/samples/load_module_text_test_samples/file_wrong_key
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,20 @@ | ||
[key]: | ||
This key is fine. | ||
|
||
[k1y3]: | ||
This is also fine. | ||
|
||
[~???????????????\\\\\\]: | ||
This should give an error. | ||
|
||
[So, how are you]: | ||
This should not work. | ||
|
||
[]]: | ||
This also should not work. | ||
|
||
[[]: | ||
Neither this. | ||
|
||
[[]]: | ||
Neither this. |