summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/runnable/teststdio.d
blob: b5cc44480dca51abcb8d00a020080d2d26a4a003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// PERMUTE_ARGS:
// EXTRA_FILES: extra-files/teststdio.txt

import std.stdio;
import core.stdc.stdio;

void main()
{
    auto f = std.stdio.File("runnable/extra-files/teststdio.txt", "r");
    FILE* fp = f.getFP();
    string buf;
    int i;
    do
    {
        buf = f.readln('\n');
        foreach (c; buf)
            printf("%x\n", c);
        printf("\n");
        switch (i)
        {
            case 0:     assert(buf == "asdfasdf\n"); break;
            case 1:     assert(buf == "a\n"); break;
            case 2:     assert(buf == "sdf\n"); break;
            case 3:     assert(buf == "asdf\n"); break;
            case 4:     assert(buf == "\n"); break;
            case 5:     assert(buf == "\n"); break;
            case 6:     assert(buf == null); break;
            default:    assert(0);
        }
        i++;
    } while (!feof(fp));
    //fclose(fp);
}