MCPcopy Create free account
hub / github.com/Singular/Singular / Main

Function Main

ppcc/adlib/test2.cc:4–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "set.h"
3
4void Main() {
5 StrArr *arr
6 = ReadProcessLines(new Str("seq"), new StrArr(1, new Str("10000")));
7 Check(arr->len() == 10001, "read process output as lines");
8 Word hash = 0;
9 for (StrArr::Each it(arr); it; ++it) {
10 hash += Hash(*it);
11 }
12 Check((hash & 0xffff) == 0xc756, "hashing strings");
13 Str *data = ReadFile("/dev/null");
14 FileInfo *finfo = FileStat(__FILE__);
15 Check(finfo != NULL && finfo->is_file && finfo->size > 0, "file stat");
16 Check(data && data->len() == 0, "read bytes from file");
17 arr = ReadLines(__FILE__);
18 Check(arr && arr->len() > __LINE__, "read lines from file");
19 Check(WriteFile("/dev/null", S("test")), "write bytes to file");
20 static CStr args[] = { "17" };
21 Check(System(S("exit"), StrArrLit(args)) == 17, "invoke shell");
22 Check(ListFiles(".")->len() > 0, "reading directories");
23 StrSet *files = new StrSet(ListFiles("adlib"));
24 files = new StrSet(ListFileTree(CurrentDir(), ListFilesRelative));
25 Check(files->contains(S(__FILE__)), "reading directories recursively");
26}

Callers

nothing calls this directly

Calls 14

ReadProcessLinesFunction · 0.85
CheckFunction · 0.85
ReadFileFunction · 0.85
FileStatFunction · 0.85
ReadLinesFunction · 0.85
WriteFileFunction · 0.85
SystemFunction · 0.85
ListFilesFunction · 0.85
ListFileTreeFunction · 0.85
CurrentDirFunction · 0.85
HashFunction · 0.70
SFunction · 0.70

Tested by

no test coverage detected