Skip to content

Commit

Permalink
Convert tuples into string using stringify().
Browse files Browse the repository at this point in the history
Summary: Removed convertTupleValToStr and stringified the tuples using stringify().

Test Plan: N/A

Reviewers: jcmcdonald

Reviewed By: jcmcdonald

Tags: #goldilocks_project, #programming_dept

Maniphest Tasks: T1507

Revert Plan: N/A

Differential Revision: https://phab.mousepawmedia.com/D469
  • Loading branch information
Gerar Almonte committed Oct 30, 2021
1 parent 5c583aa commit 3a8a9f4
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions goldilocks-source/include/goldilocks/expect/outcomes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,6 @@ class FuncOutcome : public AbstractOutcome
const char* name_hint;
// The arguments to passed to the function.
std::tuple <Args...> args;
// String of args.
std::string strOfArgs;

// Method to iterate through a tuple and convert the arguments to string.
template <size_t I = 0>
void convertTupleValToStr(std::tuple <Args...> tupArgs)
{
// Appends last element to strOfArgs and stops recursion when I reaches the lenght of the tuple.
if constexpr(I == sizeof...(Args) - 1) {
this->strOfArgs += std::to_string(std::get<I>(tupArgs));
} else {
// Get value from tuple and append it to strOfArgs.
this->strOfArgs += std::to_string(std::get<I>(tupArgs)) + ",";
// Goes to the next element to the tuple by calling itself.
convertTupleValToStr<I + 1>(args);
}
}

public:
/** Create a new outcome.
Expand All @@ -249,8 +232,6 @@ class FuncOutcome : public AbstractOutcome
const char* name_hint, Args... args) : AbstractOutcome(passed), returned(returned),
expected(expected), name_hint(name_hint), args(std::make_tuple(args...))
{
//Convert args to strOfArgs.
convertTupleValToStr(this->args);
}

/** Create the string representation of the outcome.
Expand All @@ -270,7 +251,7 @@ class FuncOutcome : public AbstractOutcome
}

// Compose a string from the value, comparison, and outcome strings.
return stringify(name_hint) + "(" + this->strOfArgs + ")" + comparison + stringify(this->returned) + " == " + stringify(this->expected) + outcome;
return stringify(this->name_hint) + "(" + stringify(this->args) + ")" + comparison + stringify(this->returned) + " == " + stringify(this->expected) + outcome;
}

~FuncOutcome() = default;
Expand Down

0 comments on commit 3a8a9f4

Please sign in to comment.