Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db6b8a8

Browse files
author
egberts
committed
Added Unit Testing to README.md
1 parent c4e27cf commit db6b8a8

9 files changed

+123
-350
lines changed

‎README.md‎

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Standardized INI Table Format
3232
--------------------------
3333
Next is to standardize the INI to a common syntax format:
3434
```
35-
[section]keyword=keyvale
35+
[section]keyword=keyvalue
3636
```
3737

3838
An example INI file might look like this:
@@ -58,9 +58,9 @@ Parsable AWK/SED/GREP Galore!
5858
With a common `[section]keyword=keyvalue`, it now becomes possible to work with INI line-records in a faster manner using `sed`, `awk` and `tail`.
5959

6060

61-
How To Use bash-ini-file
61+
How To Use bash-ini-parser
6262
====
63-
Simply source the lone script file: `bash-ini-file.sh`
63+
Simply source the lone script file: `bash-ini-parser.sh`
6464
and start calling APIs such as:
6565

6666
| API | `$?` | `STDOUT` | Description |
@@ -129,7 +129,119 @@ Done.
129129

130130
Unit Test
131131
=========
132-
`tests` subdirectory performs the comprehensive unit test, in case you tweaked it, this will find any errors of yours.
132+
The accompanied `tests` subdirectory performs the comprehensive unit testing, in case you have decided to tweaked it to your normative scenario; hopefully, this will find any errors of yours.
133+
134+
To exercise the test, your modified `bash-ini-parser.sh must reside above the `tests` directory as all the unit tests will perform:
135+
136+
```bash
137+
#!/bin/bash
138+
# Title: my script file
139+
140+
source ../bash-ini-parser.sh
141+
142+
...
143+
```
144+
145+
Supreme Unit Testing
146+
---
147+
To start the global unit test, execute:
148+
149+
```bash
150+
cd tests
151+
./test-all.sh
152+
```
153+
and the output is long, very long, very very long.
154+
155+
Selective Unit Test
156+
---
157+
158+
To perform a specific unit test, for example, `ini_keyvalue_get()`, execute:
159+
160+
```console
161+
$ bash test-ini-keyvalue-get.sh
162+
assert_keyvalue_get([Default]DNS=): pass # same keyword, 'Default' section
163+
assert_keyvalue_get([Resolve]DNS=): pass # same keyword, 'Resolve' section
164+
assert_keyvalue_get([Default]DNS=): pass # empty ini_file
165+
assert_keyvalue_get([Default]DNS=): pass # new line
166+
assert_keyvalue_get([Default]DNS=): pass # hash mark no-comment
167+
assert_keyvalue_get([Default]DNS=): pass # semicolon no-comment
168+
assert_keyvalue_get([Default]DNS=): pass # slash-slash no-comment
169+
assert_keyvalue_get([Default]DNS=): pass # hash mark comment
170+
assert_keyvalue_get([Default]DNS=): pass # semicolon comment
171+
assert_keyvalue_get([Default]DNS=): pass # slash-slash comment
172+
assert_keyvalue_get([NoSuchSection]DNS=): pass # same keyword, 'NoSuchSection' section
173+
assert_keyvalue_get([]=): pass # unused keyword
174+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
175+
assert_keyvalue_get([Resolve]DNS=): pass # unused keyword, 'Resolve' section
176+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
177+
assert_keyvalue_get([]=): pass # unused keyword
178+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
179+
assert_keyvalue_get([Resolve]DNS=): pass # unused keyword, 'Resolve' section
180+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
181+
assert_keyvalue_get([]=): pass # unused keyword
182+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
183+
assert_keyvalue_get([Default]FallbackDNS=): pass # standard
184+
assert_keyvalue_get([Resolve]DNS=): pass # incomplete but matching keyword, 'Resolve' section
185+
assert_keyvalue_get([Resolve]DNS_Server1=): pass # incomplete but matching keyword, 'Resolve' section, NULL answer
186+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
187+
assert_keyvalue_get([]=): pass # unused keyword
188+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
189+
assert_keyvalue_get([Gateway]Hidden_DNS_Master=): pass # unique section, underscored keyword
190+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unique section, unused keyword, noSuchSection
191+
assert_keyvalue_get([]=): pass # unused keyword
192+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
193+
assert_keyvalue_get([Resolve]DNS=): pass # keyword 2 of 2, 'Resolve' section
194+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
195+
assert_keyvalue_get([]=): pass # unused keyword
196+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
197+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
198+
assert_keyvalue_get([Default]FallbackDNS=): pass # standard
199+
assert_keyvalue_get([Resolve]DNS_Server1=): pass # standard
200+
assert_keyvalue_get([DifferentSection]DNS=): pass # standard
201+
assert_keyvalue_get([Resolve]DNS_Server2=): pass # standard
202+
assert_keyvalue_get([DifferentSection2]DNS_2=): pass # standard
203+
assert_keyvalue_get([Resolve]DNS=): pass # standard
204+
assert_keyvalue_get([]=): pass # unused keyword
205+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
206+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
207+
assert_keyvalue_get([Default]FallbackDNS=): pass # standard
208+
assert_keyvalue_get([Resolve]DNS_Server1=): pass # standard
209+
assert_keyvalue_get([DifferentSection]DNS=): pass # standard
210+
assert_keyvalue_get([Resolve]DNS_Server2=): pass # standard
211+
assert_keyvalue_get([DifferentSection2]DNS_2=): pass # standard
212+
assert_keyvalue_get([Resolve]DNS=): pass # standard
213+
assert_keyvalue_get([Gateway]Hidden_DNS_Master=): pass # standard
214+
assert_keyvalue_get([]=): pass # unused keyword
215+
assert_keyvalue_get([]DNS=): pass # unused keyword, 'no-section default
216+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused keyword, noSuchSection
217+
assert_keyvalue_get([Default]FallbackDNS=): pass # standard
218+
assert_keyvalue_get([Resolve]DNS_Server1=): pass # standard
219+
assert_keyvalue_get([DifferentSection]DNS=): pass # standard
220+
assert_keyvalue_get([Resolve]DNS_Server2=): pass # standard
221+
assert_keyvalue_get([DifferentSection2]DNS_2=): pass # standard
222+
assert_keyvalue_get([Resolve]DNS=): pass # standard
223+
assert_keyvalue_get([Gateway]Hidden_DNS_Master=): pass # standard
224+
assert_keyvalue_get([Gateway]Hidden_DNS_Master2=): pass # standard
225+
assert_keyvalue_get([]=): pass # no section, no keyword
226+
assert_keyvalue_get([]DNS=): pass # no-section, unused keyword
227+
assert_keyvalue_get([NoSuchSection]DNS=): pass # unused section, unused keyword
228+
assert_keyvalue_get([Default]FallbackDNS=): pass # # inside double-quote
229+
assert_keyvalue_get([Resolve]DNS_Server1=): pass # ; inside double-quote
230+
assert_keyvalue_get([DifferentSection]DNS=): pass # // inside double-quote
231+
assert_keyvalue_get([Resolve]DNS_Server2=): pass # ; inside LHS double-quote
232+
assert_keyvalue_get([DifferentSection2]DNS_2=): pass # // inside LHS double-quote
233+
assert_keyvalue_get([Resolve]DNS=): pass # ; inside RHS double-quote
234+
assert_keyvalue_get([Gateway]Hidden_DNS_Master=): pass # # inside RHS double-quote
235+
assert_keyvalue_get([Gateway]Hidden_DNS_Master2=): pass # // inside RHS double-quote
236+
assert_keyvalue_get([Default]FallbackDNS=): pass # # inside double-quote and outside
237+
assert_keyvalue_get([Resolve]DNS_Server1=): pass # ; inside quote and outside
238+
assert_keyvalue_get([Resolve]DNS_Server2=): pass # ; inside LHS double-quote and outside
239+
assert_keyvalue_get([Resolve]DNS=): pass # ; inside RHS double-quote and outside
240+
assert_keyvalue_get([Gateway]Hidden_DNS_Master2=): failed # // inside RHS double-quote and outside
241+
expected: '"78.78.78.78//"'
242+
actual : '"78.78.78.78//" // inline '/' '/' RHS double-quote'
243+
```
244+
133245

134246

135247

‎tests/test-ini-file-read.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
. ../bash-ini-parser.sh
44

‎tests/test-ini-keyword-name-normalize.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
. ../bash-ini-parser.sh
44

‎tests/test-ini-keyword-valid.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
. ../bash-ini-parser.sh
44

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /