Skip to content

Commit

Permalink
Remove dependency on <format>
Browse files Browse the repository at this point in the history
  • Loading branch information
solar-mist committed Jul 6, 2023
1 parent f6aa6f8 commit 6d82d00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 4 additions & 2 deletions framework/src/lexer/Token.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <lexer/Token.h>

#include <format>
#include <sstream>

namespace Lexing
{
Expand Down Expand Up @@ -50,7 +50,9 @@ namespace Lexing

std::string Token::toString() const
{
return std::format("{}({})", TypeToString(mTokenType), mText);
std::stringstream ret;
ret << TypeToString(mTokenType) << "(" << mText << ")";
return ret.str();
}

bool Token::operator==(Token other)
Expand Down
8 changes: 3 additions & 5 deletions tests/src/Test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <Test.h>

#include <format>


struct failedTest
{
Expand Down Expand Up @@ -42,10 +40,10 @@ void testFailed(std::source_location sourceLocation, const char* condition)

void diagnostics()
{
std::cout << std::format("\n{} tests run. \x1b[;32m{} succeeded, \x1b[;31m{} failed.\x1b[;0m\n\n", tests.size(), tests.size() - failedTests.size(), failedTests.size());
std::cout << "\n" << tests.size() << " tests run. \x1b[;32m" << tests.size() - failedTests.size() << " succeeded, \x1b[;31m" << failedTests.size() << "failed.\x1b[;0m\n\n";
for (failedTest& test : failedTests)
{
std::cout << std::format("\x1b[;31mTest {}::{}({}:{}:{}) failed with expansion:\x1b[;0m\n\t{}\n", test.suite, test.name, test.file, test.line, test.col, test.condition);
std::cout << "\x1b[;31mTest " << test.suite << "::" << test.name << "(" << test.file << ":" << test.line << ":" << test.col << ") failed with expansion:\x1b[;0m\n\t" << test.condition << "\n";
}
if (failedTests.empty())
{
Expand All @@ -61,7 +59,7 @@ void runTests()
{
for (TestCase& test : tests)
{
std::cout << std::format("Running test {}::{}\n", test.suite, test.name);
std::cout << "Running test " << test.suite << "::" << test.name << "\n";
test.method();
}
diagnostics();
Expand Down

0 comments on commit 6d82d00

Please sign in to comment.