Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed May 27, 2017
1 parent fb587d5 commit 55a338d
Show file tree
Hide file tree
Showing 37 changed files with 63 additions and 146 deletions.
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ set(INCLUDE
include/tcframe/runner/ArgsParser.hpp
include/tcframe/runner/Runner.hpp
include/tcframe/runner/RunnerLogger.hpp
include/tcframe/runner/RunnerLoggerFactory.hpp
include/tcframe/runner/SlugParser.hpp
include/tcframe/spec.hpp
include/tcframe/spec/constraint.hpp
Expand Down Expand Up @@ -172,6 +171,12 @@ set(TEST_UNIT
test/unit/tcframe/generator/MockGeneratorLogger.hpp
test/unit/tcframe/generator/MockTestCaseGenerator.hpp
test/unit/tcframe/generator/TestCaseGeneratorTests.cpp
test/unit/tcframe/grader/GraderTests.cpp
test/unit/tcframe/grader/GraderLoggerTests.cpp
test/unit/tcframe/grader/MockGrader.hpp
test/unit/tcframe/grader/MockGraderLogger.hpp
test/unit/tcframe/grader/MockTestCaseGrader.hpp
test/unit/tcframe/grader/TestCaseGraderTests.cpp
test/unit/tcframe/io_manipulator/GridIOSegmentManipulatorTests.cpp
test/unit/tcframe/io_manipulator/IOManipulatorTests.cpp
test/unit/tcframe/io_manipulator/LineIOSegmentManipulatorTests.cpp
Expand All @@ -188,7 +193,6 @@ set(TEST_UNIT
test/unit/tcframe/runner/BaseRunnerTests.hpp
test/unit/tcframe/runner/InteractiveRunnerTests.cpp
test/unit/tcframe/runner/MockRunnerLogger.hpp
test/unit/tcframe/runner/MockRunnerLoggerFactory.hpp
test/unit/tcframe/runner/RunnerTests.cpp
test/unit/tcframe/runner/RunnerLoggerTests.cpp
test/unit/tcframe/runner/SlugParserTests.cpp
Expand All @@ -214,12 +218,6 @@ set(TEST_UNIT
test/unit/tcframe/spec/variable/VariableTests.cpp
test/unit/tcframe/spec/variable/VectorTests.cpp
test/unit/tcframe/spec/variable/WhitespaceManipulatorTests.cpp
test/unit/tcframe/grader/GraderTests.cpp
test/unit/tcframe/grader/GraderLoggerTests.cpp
test/unit/tcframe/grader/MockGrader.hpp
test/unit/tcframe/grader/MockGraderLogger.hpp
test/unit/tcframe/grader/MockTestCaseGrader.hpp
test/unit/tcframe/grader/TestCaseGraderTests.cpp
test/unit/tcframe/util/OptionalTests.cpp
test/unit/tcframe/util/StringUtilsTests.cpp
test/unit/tcframe/util/TestUtils.hpp
Expand Down
4 changes: 0 additions & 4 deletions include/tcframe/aggregator/AggregatorRegistry.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#pragma once

#include <string>

#include "tcframe/aggregator/Aggregator.hpp"
#include "tcframe/aggregator/MinAggregator.hpp"
#include "tcframe/aggregator/SumAggregator.hpp"

using std::string;

namespace tcframe {

class AggregatorRegistry {
Expand Down
2 changes: 0 additions & 2 deletions include/tcframe/evaluator/EvaluationOptions.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#pragma once

#include <map>
#include <string>
#include <tuple>
#include <utility>

#include "tcframe/spec/core.hpp"
#include "tcframe/util.hpp"

using std::map;
using std::move;
using std::string;
using std::tie;
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/evaluator/communicator/Communicator.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <stdexcept>
#include <string>
#include <sys/signal.h>

Expand All @@ -9,6 +10,7 @@
#include "tcframe/util.hpp"
#include "tcframe/verdict.hpp"

using std::runtime_error;
using std::string;

namespace tcframe {
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/evaluator/scorer/CustomScorer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <istream>
#include <stdexcept>
#include <streambuf>
#include <string>
Expand All @@ -9,6 +10,7 @@
#include "tcframe/os.hpp"
#include "tcframe/verdict.hpp"

using std::istream;
using std::runtime_error;
using std::string;

Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/evaluator/scorer/DiffScorer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <istream>
#include <string>

#include "Scorer.hpp"
Expand All @@ -8,6 +9,7 @@
#include "tcframe/util.hpp"
#include "tcframe/verdict.hpp"

using std::istream;
using std::string;

namespace tcframe {
Expand Down
2 changes: 0 additions & 2 deletions include/tcframe/grader/Grader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <vector>

Expand All @@ -17,7 +16,6 @@

using std::map;
using std::max;
using std::set;
using std::string;
using std::vector;

Expand Down
7 changes: 4 additions & 3 deletions include/tcframe/io_manipulator/GridIOSegmentManipulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class GridIOSegmentManipulator {
variable->clear();
variable->parseFrom(in, segment->rows()(), segment->columns()());

return TokenFormatter::formatMatrixElement(variable->name(),
variable->rows() - 1,
variable->columns(variable->rows() - 1) - 1);
return TokenFormatter::formatMatrixElement(
variable->name(),
variable->rows() - 1,
variable->columns(variable->rows() - 1) - 1);
}

static void print(GridIOSegment* segment, ostream* out) {
Expand Down
2 changes: 0 additions & 2 deletions include/tcframe/io_manipulator/IOManipulator.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <iostream>
#include <vector>

#include "GridIOSegmentManipulator.hpp"
Expand All @@ -11,7 +10,6 @@
#include "tcframe/spec/io.hpp"
#include "tcframe/spec/variable.hpp"

using std::endl;
using std::istream;
using std::ostream;
using std::vector;
Expand Down
7 changes: 4 additions & 3 deletions include/tcframe/io_manipulator/LinesIOSegmentManipulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class LinesIOSegmentManipulator {
}
Matrix* matrixVariable = (Matrix*) variable;
matrixVariable->parseAndAddRowFrom(in, j);
lastVariableName = TokenFormatter::formatMatrixElement(variable->name(),
j,
matrixVariable->columns(j) - 1);
lastVariableName = TokenFormatter::formatMatrixElement(
variable->name(),
j,
matrixVariable->columns(j) - 1);
}
isFirstColumn = false;
}
Expand Down
2 changes: 1 addition & 1 deletion include/tcframe/logger/BaseLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BaseLogger {
}
}

virtual void logTestCaseIntroduction(string testCaseName) {
virtual void logTestCaseIntroduction(const string& testCaseName) {
engine_->logHangingParagraph(1, testCaseName + ": ");
}

Expand Down
1 change: 0 additions & 1 deletion include/tcframe/runner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
#include "tcframe/runner/ArgsParser.hpp"
#include "tcframe/runner/Runner.hpp"
#include "tcframe/runner/RunnerLogger.hpp"
#include "tcframe/runner/RunnerLoggerFactory.hpp"
1 change: 0 additions & 1 deletion include/tcframe/runner/Runner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Args.hpp"
#include "ArgsParser.hpp"
#include "RunnerLogger.hpp"
#include "RunnerLoggerFactory.hpp"
#include "SlugParser.hpp"
#include "tcframe/aggregator.hpp"
#include "tcframe/evaluator.hpp"
Expand Down
9 changes: 9 additions & 0 deletions include/tcframe/runner/RunnerLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ class RunnerLogger : public BaseLogger {
}
};

class RunnerLoggerFactory {
public:
virtual ~RunnerLoggerFactory() {}

virtual RunnerLogger* create(LoggerEngine* engine) {
return new RunnerLogger(engine);
}
};

}
17 changes: 0 additions & 17 deletions include/tcframe/runner/RunnerLoggerFactory.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions include/tcframe/spec/core/GradingConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class GradingConfigBuilder {
GradingConfig subject_;

public:
virtual ~GradingConfigBuilder() {}

GradingConfigBuilder() {
subject_.timeLimit_ = 2;
subject_.memoryLimit_ = 64;
Expand Down
2 changes: 0 additions & 2 deletions include/tcframe/spec/core/MultipleTestCasesConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class MultipleTestCasesConfigBuilder {
MultipleTestCasesConfig subject_;

public:
virtual ~MultipleTestCasesConfigBuilder() {}

MultipleTestCasesConfigBuilder& Counter(int& var) {
subject_.counter_ = optional<int*>(&var);
return *this;
Expand Down
2 changes: 1 addition & 1 deletion include/tcframe/spec/core/SeedSetter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SeedSetter {
public:
virtual ~SeedSetter() {}

SeedSetter(function<void(unsigned)> setter)
SeedSetter(const function<void(unsigned)>& setter)
: setter_(setter) {}

virtual void setSeed(unsigned seed) {
Expand Down
2 changes: 0 additions & 2 deletions include/tcframe/spec/core/StyleConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class StyleConfigBuilder {
StyleConfig subject_;

public:
virtual ~StyleConfigBuilder() {}

StyleConfigBuilder() {
subject_.evaluationStyle_ = EvaluationStyle::BATCH;
subject_.needsOutput_ = true;
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/io/LineIOSegment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct LineIOSegment : public IOSegment {
vector<LineIOSegmentVariable> variables_;

public:
virtual ~LineIOSegment() {}

IOSegmentType type() const {
return IOSegmentType::LINE;
}
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/io/LinesIOSegment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct LinesIOSegment : public IOSegment {
function<int()> size_;

public:
virtual ~LinesIOSegment() {}

IOSegmentType type() const {
return IOSegmentType::LINES;
}
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/io/RawLineIOSegment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct RawLineIOSegment : public IOSegment {
Scalar* variable_;

public:
virtual ~RawLineIOSegment() {}

IOSegmentType type() const {
return IOSegmentType::RAW_LINE;
}
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/io/RawLinesIOSegment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct RawLinesIOSegment : public IOSegment {
function<int()> size_;

public:
virtual ~RawLinesIOSegment() {}

IOSegmentType type() const {
return IOSegmentType::RAW_LINES;
}
Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/testcase/OfficialTestCaseData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ struct OfficialTestCaseData : public TestCaseData {
function<void()> closure_;

public:
virtual ~OfficialTestCaseData() {}

OfficialTestCaseData(const function<void()>& closure)
: closure_(closure) {}

Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/testcase/SampleTestCaseData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct SampleTestCaseData : public TestCaseData {
optional<string> output_;

public:
virtual ~SampleTestCaseData() {}

SampleTestCaseData(const string& input)
: input_(input) {}

Expand Down
2 changes: 2 additions & 0 deletions include/tcframe/spec/variable/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class MatrixImpl : public Matrix {
bool hasSpaces_;

public:
virtual ~MatrixImpl() {}

MatrixImpl(vector<vector<T>>& var, const string& name)
: Matrix(name)
, var_(&var)
Expand Down
4 changes: 4 additions & 0 deletions include/tcframe/spec/variable/Scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class ScalarImpl : public Scalar {
T* var_;

public:
virtual ~ScalarImpl() {}

ScalarImpl(T& var, const string& name)
: Scalar(name)
, var_(&var) {}
Expand All @@ -55,6 +57,8 @@ class RawScalarImpl : public ScalarImpl<string> {
string* var_;

public:
virtual ~RawScalarImpl() {}

RawScalarImpl(string& var, const string& name)
: ScalarImpl(var, name)
, var_(&var) {}
Expand Down
4 changes: 4 additions & 0 deletions include/tcframe/spec/variable/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class VectorImpl : public Vector {
vector<T>* var_;

public:
virtual ~VectorImpl() {}

VectorImpl(vector<T>& var, const string& name)
: Vector(name)
, var_(&var) {}
Expand Down Expand Up @@ -105,6 +107,8 @@ class RawVectorImpl : public VectorImpl<string> {
vector<string>* var_;

public:
virtual ~RawVectorImpl() {}

RawVectorImpl(vector<string>& var, const string& name)
: VectorImpl(var, name)
, var_(&var) {}
Expand Down
2 changes: 1 addition & 1 deletion include/tcframe/verifier/Verifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Verifier {
public:
virtual ~Verifier() {}

Verifier(ConstraintSuite constraintSuite)
Verifier(const ConstraintSuite& constraintSuite)
: constraintSuite_(move(constraintSuite)) {}

virtual ConstraintsVerificationResult verifyConstraints(const set<int>& subtaskIds) {
Expand Down
1 change: 0 additions & 1 deletion test/unit/tcframe/aggregator/MinAggregatorTests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "gmock/gmock.h"
#include "../mock.hpp"

#include "tcframe/aggregator/MinAggregator.hpp"

Expand Down
1 change: 0 additions & 1 deletion test/unit/tcframe/aggregator/SumAggregatorTests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "gmock/gmock.h"
#include "../mock.hpp"

#include "tcframe/aggregator/SumAggregator.hpp"

Expand Down
2 changes: 1 addition & 1 deletion test/unit/tcframe/generator/MockGeneratorLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MockGeneratorLogger : public GeneratorLogger {
: GeneratorLogger(nullptr) {}

MOCK_METHOD1(logTestGroupIntroduction, void(int));
MOCK_METHOD1(logTestCaseIntroduction, void(string));
MOCK_METHOD1(logTestCaseIntroduction, void(const string&));
MOCK_METHOD1(logExecutionResults, void(const map<string, ExecutionResult>&));

MOCK_METHOD0(logIntroduction, void());
Expand Down

0 comments on commit 55a338d

Please sign in to comment.