avast / avast/retdec

New integration test: bitstrng.c

Open
#198 0 comments 0 reactions 0 assignees View on GitHub
C-regression-tests enhancement
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Add the following source to integration tests for as many architectures, compilers, formats, optimizations as possible:

```c
/* +++Date last modified: 05-Jul-1997 */

/*
** bitstring(): print bit pattern of bytes formatted to string.
**
** By J. Blauth, Sept. 1992. Hereby placed into the public domain.
**
** byze: value to transform to bitstring.
** biz: count of bits to be shown (counted from lowest bit, can be any
** even or odd number).
** strwid: total width the string shall have. Since between every 4 bits a
** blank (0x20) is inserted (not added after lowest bit), width of
** bitformat only is (biz+(biz/4-1)). Bits are printed right aligned,
** positions from highest bit to start of string filled with blanks.
** If value of strwid smaller than space needed to print all bits,
** strwid is ignored (e.g.:
** bitstr(s,b,16,5) results in 19 chars +'\0').
**
** EXAMPLE:
** for (j = 1; j <= 16; j++) { bitstring(s, j, j, 16); puts(s); }
** 1: 1
** 2: 10
** 3: 011
** d: 0 0000 0000 1101
** e: 00 0000 0000 1110
** f: 000 0000 0000 1111
*/

void bitstring(char *str, long byze, int biz, int strwid)
{
int i, j;

j = strwid - (biz + (biz >> 2)- (biz % 4 ? 0 : 1));
for (i = 0; i < j; i++)
*str++ = ' ';
while (--biz >= 0)
{
*str++ = ((byze >> biz) & 1) + '0';
if (!(biz % 4) && biz)
*str++ = ' ';
}
*str = '\0';
}

#ifndef TEST

#include

int main(void)
{
char s[80]; long j;
for (j = 1L; j <= 16L; j++)
{
bitstring(s, (long)j, (int)j, 16);
printf("%2ld: %s\n", j, s);
}
return EXIT_SUCCESS;
}

#endif /* TEST */
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the integration-test corpus and add the supplied bitstrng.c source there. Start by checking how existing integration tests cover architectures, compilers, formats, and optimizations; done means the source is included and exercised across as many of those configurations as the test setup supports.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.