Re: [OUTREACHY] Final Application For Git Internshhip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 28, 2023 at 9:25 AM Christian Couder
<christian.couder@xxxxxxxxx> wrote:
>
> On Wed, Oct 25, 2023 at 2:14 PM Naomi Ibe <naomi.ibeh69@xxxxxxxxx> wrote:
> >>
> >> It could help to say if your contribution has been merged to 'master',
> >> 'next', 'seen' or not at all.
> >
> >  My microproject contribution has been scheduled to be merged to the master branch.
>
> Great, please add this information to your application.
>
> >> I think that one of the important tasks to be done early is to
> >> identify what code in t/helper is unit testing C code and what code is
> >> really about helping other tests in the t/t*.sh scripts. It would be
> >> nice if you could give an example of each kind of code.
> >
> > In my opinion, helper/test-ctype.c is a unit test file containing a set of unit tests for character classification functions,
>
> Right.
>
> > while helper/test-dir-iterator.c is a unit test file which works together with the t/t0066-dir-iterator.sh file to iterate through a directory and give details on its contents. It likely is used for testing and inspecting directory structures and file types within a specified path.
>
> Actually "t/helper/test-dir-iterator.c" and "t/t0066-dir-iterator.sh"
> are used together to test the code in "dir-iterator.h" and
> "dir-iterator.c", so it's kind of special. Ideally this could be
> ported to the unit test framework as the goal is to test quite low
> level code (instead of a full git command for example), but I am not
> sure how easy it would be, and if it would even be worth it.
>
> >> An example of how you would migrate parts of a test, or how a migrated
> >> test would look like, would be nice.
> >
> > I'd first create a new test file, then include "test-libtap/tap.h" and "test-tool.h" header files, then I would initialize TAP with this command plan_tests(x), where x defines the number of tests to be run inside that file.
> > Below the plan_tests();, I'd migrate and edit my specific test function and requirements, and after that, I'd add my "done_testing();" and then "return exit_status();"
>
> These are quite good guidelines, but not quite an example.
>

Using the test-ctype.c file as an example, the migrated unit test file
would look like this:

#include "test-tool.h"
#include "test-libtap/tap.h"
#include <stdio.h>
#include <string.h>

static int is_in(const char *s, int ch) {
    if (ch == '\0')
        return ch == *s;
    if (*s == '\0')
        s++;
    return !!strchr(s, ch);
}

int main() {
    // Init TAP with the number of planned tests (1 test per character class)
    plan(12);

    // Character classes
    char *classes[] = {
        "DIGIT", " \n\r\t",
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
        "*?[\\", "$()*+.?[\\^{|", "!\"#%&',-/:;<=>@_`~",
        "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
        "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
        "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
        "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
        "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
        "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
        "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
        "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
    };

    // Test each character class
    for (int i = 0; i < 12; i++) {
        char description[50];
        sprintf(description, "Testing %s character class", classes[i]);
        for (int ch = 0; ch < 256; ch++) {
            int result = is_in(classes[i], ch);
            if (ch == EOF)
                ok(result == is_in(classes[i], ch), description);
            else
                is_int(result, is_in(classes[i], ch), description);
        }
    }

    // After testing all
    done_testing();

    return exit_status();
}


> Thanks,
> Christian.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux