Skip to content

Commit 86218af

Browse files
committed
add c++ support
1 parent b5ad636 commit 86218af

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ _language_: cee.Language – Pass the language the code is written in, for examp
6767
- **Batch** (Windows)
6868
- **Bash** (Linux)
6969
- **C** (Linux)
70+
- **C++** (Linux)
7071

7172
More supported languages coming soon.
7273

runners/linux/cpp.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
timeout -s SIGKILL 10 g++ $1 -o $1.out
3+
chmod +x $1.out
4+
timeout -s SIGKILL 10 $1.out
5+
rm $1.out

src/executor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default async function execute(
2828
var temppath: string = uniqueFilename(tmpdir());
2929
if (language == Language.C) temppath += ".c";
3030
else if (language == Language.BATCH) temppath += ".bat";
31+
else if (language == Language.CPP) temppath += ".c";
3132
writeFileSync(temppath, input, { encoding: "utf-8" });
3233

3334
// Command to execute runner

src/languages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ enum Language {
55
BATCH = "bat",
66
JAVASCRIPT = "js",
77
RUBY = "ruby",
8+
CPP = "cpp",
89
}
910

1011
export default Language;

tests/all.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ describe("Testing Basic Languages", () => {
1818
expect(response).toBe("123");
1919
});
2020
});
21+
test("C++", () => {
22+
return cee
23+
.execute(
24+
`#include "iostream"
25+
int main(void)
26+
{
27+
std::cout << "123";
28+
return 0;
29+
}`,
30+
cee.languages.CPP
31+
)
32+
.then((response) => {
33+
expect(response).toBe("123");
34+
});
35+
});
2136
// test("LXC", () => {
2237
// var executor = new cee.LXC("cee");
2338
// return executor.execute("whoami", cee.languages.BASH).then((response) => {

0 commit comments

Comments
 (0)