-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #82
- Loading branch information
Showing
14 changed files
with
330 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <tcframe/experimental/runner.hpp> | ||
|
||
using namespace tcframe; | ||
|
||
class ProblemSpec : public BaseProblemSpec { | ||
protected: | ||
int T; | ||
int A, B; | ||
int res; | ||
|
||
void InputFormat() { | ||
LINE(A, B); | ||
} | ||
|
||
void OutputFormat() { | ||
LINE(res); | ||
} | ||
|
||
void Config() { | ||
MultipleTestCasesCount(T); | ||
} | ||
|
||
void MultipleTestCasesConstraints() { | ||
CONS(1 <= T && T <= 5); | ||
} | ||
|
||
void Constraints() { | ||
CONS(1 <= A && A <= 100); | ||
CONS(1 <= B && B <= 100); | ||
} | ||
}; | ||
|
||
class TestSpec : public BaseTestSpec<ProblemSpec> { | ||
protected: | ||
void SampleTestCase1() { | ||
Input({ | ||
"1 5" | ||
}); | ||
Output({ | ||
"6" | ||
}); | ||
} | ||
|
||
void TestGroup1() { | ||
CASE(A = 1, B = 3); | ||
CASE(A = 2, B = 4); | ||
} | ||
|
||
void TestGroup2() { | ||
CASE(A = 20, B = 30); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
timeLimit: 3 | ||
memoryLimit: 128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <cstdio> | ||
|
||
int T; | ||
int A, B; | ||
|
||
int main() { | ||
scanf("%d", &T); | ||
|
||
for (int tc = 0; tc < T; tc++) { | ||
scanf("%d %d", &A, &B); | ||
printf("%d\n", A + B); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <tcframe/experimental/runner.hpp> | ||
|
||
using namespace tcframe; | ||
|
||
class ProblemSpec : public BaseProblemSpec { | ||
protected: | ||
int A, B; | ||
int res; | ||
|
||
void InputFormat() { | ||
LINE(A, B); | ||
} | ||
|
||
void OutputFormat() { | ||
LINE(res); | ||
} | ||
|
||
void Constraints() { | ||
CONS(1 <= A && A <= 10); | ||
CONS(1 <= B && B <= 10); | ||
} | ||
}; | ||
|
||
class TestSpec : public BaseTestSpec<ProblemSpec> { | ||
protected: | ||
void SampleTestCase1() { | ||
Input({ | ||
"1 5" | ||
}); | ||
Output({ | ||
"6" | ||
}); | ||
} | ||
|
||
void TestCases() { | ||
CASE(A = 1, B = 3); | ||
CASE(A = 2, B = 4); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
timeLimit: 3 | ||
memoryLimit: 128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <cstdio> | ||
|
||
int A, B; | ||
|
||
int main() { | ||
scanf("%d %d", &A, &B); | ||
printf("%d\n", A + B); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
export TCFRAME_HOME=../../tcframe | ||
|
||
slug=$1 | ||
g++ -o ${slug}_solution ${slug}_solution.cpp | ||
$TCFRAME_HOME/scripts/tcframe | ||
./${slug} --solution=./${slug}_solution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <tcframe/experimental/runner.hpp> | ||
|
||
using namespace tcframe; | ||
|
||
class ProblemSpec : public BaseProblemSpec { | ||
protected: | ||
int A, B; | ||
int res; | ||
|
||
void InputFormat() { | ||
LINE(A, B); | ||
} | ||
|
||
void OutputFormat() { | ||
LINE(res); | ||
} | ||
|
||
void Subtask1() { | ||
CONS(1 <= A && A <= 10); | ||
CONS(1 <= B && B <= 10); | ||
} | ||
|
||
void Subtask2() { | ||
CONS(1 <= A && A <= 100); | ||
CONS(1 <= B && B <= 100); | ||
} | ||
}; | ||
|
||
class TestSpec : public BaseTestSpec<ProblemSpec> { | ||
protected: | ||
void SampleTestCase1() { | ||
Subtasks({1, 2}); | ||
Input({ | ||
"1 5" | ||
}); | ||
Output({ | ||
"6" | ||
}); | ||
} | ||
|
||
void SampleTestCase2() { | ||
Subtasks({2}); | ||
Input({ | ||
"11 12" | ||
}); | ||
Output({ | ||
"23" | ||
}); | ||
} | ||
|
||
void TestGroup1() { | ||
Subtasks({1, 2}); | ||
|
||
CASE(A = 1, B = 3); | ||
CASE(A = 2, B = 4); | ||
} | ||
|
||
void TestGroup2() { | ||
Subtasks({2}); | ||
|
||
CASE(A = 20, B = 30); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
timeLimit: 3 | ||
memoryLimit: 128 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <cstdio> | ||
|
||
int A, B; | ||
|
||
int main() { | ||
scanf("%d %d", &A, &B); | ||
printf("%d\n", A + B); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "gmock/gmock.h" | ||
|
||
#include <cstdlib> | ||
#include <iostream> | ||
#include <memory> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
using ::testing::Test; | ||
|
||
using std::istringstream; | ||
using std::shared_ptr; | ||
using std::string; | ||
using std::vector; | ||
|
||
namespace tcframe { | ||
|
||
class BaseEteTests : public Test { | ||
protected: | ||
int execStatus(const string& command) { | ||
return system(command.c_str()); | ||
} | ||
|
||
string exec(const string& command) { | ||
char buf[128]; | ||
string res; | ||
shared_ptr<FILE> pipe(popen(command.c_str(), "r"), pclose); | ||
while (!feof(pipe.get())) { | ||
if (fgets(buf, 128, pipe.get()) != nullptr) { | ||
res += buf; | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
vector<string> ls(const string& dir) { | ||
istringstream sin(exec("ls -1 " + dir)); | ||
vector<string> files; | ||
string file; | ||
while (sin >> file) { | ||
files.push_back(file); | ||
} | ||
return files; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "gmock/gmock.h" | ||
|
||
#include "BaseEteTests.cpp" | ||
|
||
using ::testing::Eq; | ||
using ::testing::Test; | ||
using ::testing::UnorderedElementsAre; | ||
|
||
namespace tcframe { | ||
|
||
class GenerationEteTests : public BaseEteTests {}; | ||
|
||
TEST_F(GenerationEteTests, Normal) { | ||
ASSERT_THAT(execStatus("cd ete/normal && ../scripts/generate.sh normal"), Eq(0)); | ||
|
||
EXPECT_THAT(ls("ete/normal/tc"), UnorderedElementsAre( | ||
"normal_sample_1.in", | ||
"normal_sample_1.out", | ||
"normal_1.in", | ||
"normal_1.out", | ||
"normal_2.in", | ||
"normal_2.out" | ||
)); | ||
} | ||
|
||
TEST_F(GenerationEteTests, Subtasks) { | ||
ASSERT_THAT(execStatus("cd ete/subtasks && ../scripts/generate.sh subtasks"), Eq(0)); | ||
|
||
EXPECT_THAT(ls("ete/subtasks/tc"), UnorderedElementsAre( | ||
"subtasks_sample_1.in", | ||
"subtasks_sample_1.out", | ||
"subtasks_sample_2.in", | ||
"subtasks_sample_2.out", | ||
"subtasks_1_1.in", | ||
"subtasks_1_1.out", | ||
"subtasks_1_2.in", | ||
"subtasks_1_2.out", | ||
"subtasks_2_1.in", | ||
"subtasks_2_1.out" | ||
)); | ||
} | ||
|
||
TEST_F(GenerationEteTests, Multi) { | ||
ASSERT_THAT(execStatus("cd ete/multi && ../scripts/generate.sh multi"), Eq(0)); | ||
|
||
EXPECT_THAT(ls("ete/multi/tc"), UnorderedElementsAre( | ||
"multi_sample.in", | ||
"multi_sample.out", | ||
"multi_1.in", | ||
"multi_1.out", | ||
"multi_2.in", | ||
"multi_2.out" | ||
)); | ||
} | ||
|
||
} |