Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agauniyal committed Mar 19, 2016
1 parent 3961c44 commit acc80e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
31 changes: 0 additions & 31 deletions test/RCBTest.cpp

This file was deleted.

4 changes: 2 additions & 2 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test1 = executable('RCBTest', 'RCBTest.cpp', include_directories : inc)
test1 = executable('CTest', 'test.cpp', include_directories : inc)
test2 = executable('VTest', 'visualTest.cpp', include_directories : inc)

test('Redirect Cout Buffer', test1)
test('Catch Tests', test1)
test('Visual Test', test2)
29 changes: 29 additions & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#define CATCH_CONFIG_MAIN
#include "catch.hpp"

#include "rang.hpp"
#include <fstream>
#include <string>

TEST_CASE("Rang printing to non-terminals", "[file]")
{
std::string s = "Hello World";

SECTION("output is to a file")
{
std::ofstream out("out.txt");
std::streambuf *coutbuf = std::cout.rdbuf();
std::cout.rdbuf(out.rdbuf());

std::cout << rang::fg::blue << s << rang::style::reset;

std::cout.rdbuf(coutbuf);
out.close();

std::ifstream in("out.txt");
std::string output;
std::getline(in, output);

REQUIRE(s == output);
}
}

0 comments on commit acc80e9

Please sign in to comment.