summaryrefslogtreecommitdiff
path: root/src/voidc.cc
blob: fbb9577bb5c7a895f1e956d782d7efab57e10482 (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
34
35
36
37
38
#include <cstdlib>
#include <cstring>

#include "common.cc"
#include "memory.cc"
#include "source.cc"

static const char* SOURCE = R"(
#include <stdlib.h>

int main() {
  return EXIT_FAILURE;
}

)";

static const char* SOURCE_FILE = "source.c";

int main() {
  String source(SOURCE);
  String file(SOURCE_FILE);

  Buffer_Stack stack{};
  Buffer* buffer = nullptr;

  bool ret = buffer_init(heap_allocator(), &source, &file, &buffer);
  if (!ret) return EXIT_FAILURE;

  buffer_stack_push(&stack, buffer);
  buffer_stack_push(&stack, buffer);

  int c = 0;
  while(buffer_stack_pop(&stack, &buffer)) {
    c += 1;
  }

  assert(c == 2);
}