-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Catch enum-to-string converters to tests (#446)
- Loading branch information
Showing
22 changed files
with
97 additions
and
105 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
// Copyright (c) Sleipnir contributors | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include <catch2/catch_tostring.hpp> | ||
#include <sleipnir/autodiff/ExpressionType.hpp> | ||
#include <sleipnir/optimization/SolverExitCondition.hpp> | ||
|
||
namespace Catch { | ||
|
||
template <> | ||
struct StringMaker<sleipnir::ExpressionType> { | ||
static std::string convert(const sleipnir::ExpressionType& type) { | ||
using enum sleipnir::ExpressionType; | ||
|
||
switch (type) { | ||
case kNone: | ||
return "kNone"; | ||
case kConstant: | ||
return "kConstant"; | ||
case kLinear: | ||
return "kLinear"; | ||
case kQuadratic: | ||
return "kQuadratic"; | ||
case kNonlinear: | ||
return "kNonlinear"; | ||
} | ||
|
||
return ""; | ||
} | ||
}; | ||
|
||
template <> | ||
struct StringMaker<sleipnir::SolverExitCondition> { | ||
static std::string convert( | ||
const sleipnir::SolverExitCondition& exitCondition) { | ||
using enum sleipnir::SolverExitCondition; | ||
|
||
switch (exitCondition) { | ||
case kSuccess: | ||
return "kSuccess"; | ||
case kSolvedToAcceptableTolerance: | ||
return "kSolvedToAcceptableTolerance"; | ||
case kCallbackRequestedStop: | ||
return "kCallbackRequestedStop"; | ||
case kTooFewDOFs: | ||
return "kTooFewDOFs"; | ||
case kLocallyInfeasible: | ||
return "kLocallyInfeasible"; | ||
case kFeasibilityRestorationFailed: | ||
return "kFeasibilityRestorationFailed"; | ||
case kNonfiniteInitialCostOrConstraints: | ||
return "kNonfiniteInitialCostOrConstraints"; | ||
case kDivergingIterates: | ||
return "kDivergingIterates"; | ||
case kMaxIterationsExceeded: | ||
return "kMaxIterationsExceeded"; | ||
case kMaxWallClockTimeExceeded: | ||
return "kMaxWallClockTimeExceeded"; | ||
} | ||
|
||
return ""; | ||
} | ||
}; | ||
|
||
} // namespace Catch |
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
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
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
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
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
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