main
1#define _DEFAULT_SOURCE
2#include <stdio.h>
3#define KC_IMPLEMENT
4#define KC_USE_PLATFORM_LIBC
5//#define KC_ZERO_MEMORY_STRICT
6
7#include "../include/memory.h"
8#include "../include/types.h"
9#include "../platform/assert.h"
10
11#include "../include/testing.h"
12#include "../io/file.h"
13
14KC_TESTFUNC( test0,
15 printf("Good riddance!\n");
16 *((volatile u8*)0) = 'd';
17)
18
19int main(void) {
20 Arena a;
21 Arena scratch;
22
23 assert(OK( Arena_create( &a, GiB(4) )) );
24 assert(OK( Arena_create( &scratch, MiB(1) )) );
25
26 File f = {0};
27
28 STATIC_STRING( testfile_name, "./testfile" );
29
30 assert(OK( File_open( &f, (string*)&testfile_name, FILEOPT_READ, Arena_from( &scratch ) ) ));
31
32 SourceGeneric s = {0};
33
34 File_to_stream_source( &f, &s );
35
36 u64 amount = 0;
37 Stream_into_arena( &s, &a, 64, &amount );
38
39 printf("%lu", amount );
40 putchar('\n');
41 write(1, a.start, amount);
42
43
44 assert(OK( File_close( &f ) ));
45
46 assert(OK(Arena_destroy(&a)));
47}