Skip to content

Commit 89860f8

Browse files
committed
updated README.md on test coverage, updated makefile for test cov
1 parent 27655e4 commit 89860f8

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

README.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,31 @@ Finally, it can be in some systems that we can't turn off the audio input sourc
191191
* [wikipedia on Companding](https://en.wikipedia.org/wiki/Companding)
192192
* [University of British Columbia lab on Companding](https://people.ece.ubc.ca/edc/4550.jan2018/lab2.pdf)
193193

194+
### Code Coverage
195+
Code coverage is achieved using gcov from the gcc test suite. To see the code coverage:
196+
197+
```bash
198+
make clean
199+
make
200+
./test-library.out
201+
gcov companders.c
202+
This generates the file lib.c.gcov, which can be viewed in any text editor. Lines with #### have never been run.
203+
```
204+
205+
194206
## Versions
195207

196-
* 1.0.6 08 Aug 2024 -- added ci testing
197-
* 1.0.5 30 May 2024 -- cleaned up release
198-
* 1.0.4 30 May 2024 -- add ulaw, updated docs, added full test
199-
* 1.0.4 23 Jan 2023 -- updated docs
200-
* 1.0.3 28 Jul 2019 -- updated docs, ver example
201-
* 1.0.2 15 Jul 2016 -- updated README.md to markdown format. updated license to be OSI compliant. no code changes. some minor doc updates. Thanks to John R Strohm giving me the nudge to update the docs here.
202-
* 1.0.1 3 Sep 2012 -- original release in github
208+
* 1.0.6 08 Aug 2024 -- added ci testing
209+
* 1.0.5 30 May 2024 -- cleaned up release
210+
* 1.0.4 30 May 2024 -- add ulaw, updated docs, added full test
211+
* 1.0.4 23 Jan 2023 -- updated docs
212+
* 1.0.3 28 Jul 2019 -- updated docs, ver example
213+
* 1.0.2 15 Jul 2016 -- updated README.md to markdown format. updated license to be OSI compliant. no code changes. some minor doc updates. Thanks to John R Strohm giving me the nudge to update the docs here.
214+
* 1.0.1 3 Sep 2012 -- original release in github
203215

204216
## License
205217

206-
See attached LICENSE.txt file (OSI approved BSD 2.0)
218+
See attached LICENSE.txt file (OSI approved BSD 2 Clause)
207219

208220
Copyright (c) 2001-2024, M. A. Chatterjee < deftio at deftio dot com >
209221
All rights reserved.
@@ -228,3 +240,5 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
228240
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
229241
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
230242
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
243+
244+

companders.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ static DIO_s8 MuLawLogTable[256] =
130130
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
131131
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
132132
};
133-
#define cBias 0x84
134-
#define cClip 32635
133+
135134

136135
DIO_s8 DIO_LinearToULaw(DIO_s16 sample)
137136
{
137+
const DIO_s16 cBias=0x84;
138+
const DIO_s16 cClip=32635;
138139
DIO_s32 sign, exponent, mantissa;
139140
DIO_s8 compandedValue;
140141

companders_fulltest.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ unsigned char LinearToMuLawSample(short sample)
8282
//=========================================================
8383

8484
void test_LinearToALaw() {
85-
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 980};
86-
DIO_s8 expectedResults[] = {22, 64, 85, -54, -5};
85+
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 980, 32700};
86+
DIO_s8 expectedResults[] = {22, 64, 85, -54, -5, -86};
8787
size_t numSamples = sizeof(testSamples) / sizeof(testSamples[0]);
8888
for (size_t i = 0; i < numSamples; ++i) {
8989
DIO_s8 companded = DIO_LinearToALaw(testSamples[i]);
@@ -104,8 +104,8 @@ void test_ALawToLinear() {
104104
}
105105

106106
void test_LinearToULaw() {
107-
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 7000};
108-
DIO_s8 expectedResults[] = { 59, 98, 127, 220, 164};
107+
DIO_s16 testSamples[] = {-2460, -338, -1, 499, 7000,32700};
108+
DIO_s8 expectedResults[] = { 59, 98, 127, 220, 164, -128};
109109
size_t numSamples = sizeof(testSamples) / sizeof(testSamples[0]);
110110
for (size_t i = 0; i < numSamples; ++i) {
111111
DIO_s8 companded = DIO_LinearToULaw(testSamples[i]);

makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TEST_OBJ = companders.o companders_fulltest.o
1212
$(CC) -c -o $@ $< $(CFLAGS_TEST)
1313

1414
compandit: $(OBJ)
15-
$(CC) -o $@ $^ $(CFLAGS) -lm
15+
$(CC) -o $@ $^ $(CFLAGS_TEST) -lm
1616

1717
companders_fulltest: $(TEST_OBJ)
1818
$(CC) -o $@ $^ $(CFLAGS_TEST) -lm
@@ -22,4 +22,4 @@ test: companders_fulltest
2222
./companders_fulltest
2323

2424
clean:
25-
rm *.o compandit companders_fulltest -f
25+
rm *.o *.asm *.lst *.sym *.rel *.s *.gc* -f *.info

0 commit comments

Comments
 (0)