00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WTERMINALCOLOR_TEST_H
00026 #define WTERMINALCOLOR_TEST_H
00027
00028 #include <string>
00029 #include <sstream>
00030
00031 #include <boost/shared_ptr.hpp>
00032 #include <cxxtest/TestSuite.h>
00033
00034 #include "../WTerminalColor.h"
00035
00036
00037
00038
00039 class WTerminalColorTest : public CxxTest::TestSuite
00040 {
00041 public:
00042
00043
00044
00045 void testInstantiation( void )
00046 {
00047 TS_ASSERT_THROWS_NOTHING( WTerminalColor c() );
00048 TS_ASSERT_THROWS_NOTHING( WTerminalColor( WTerminalColor::Bold, WTerminalColor::FGRed, WTerminalColor::BGNone ) );
00049 }
00050
00051
00052
00053
00054 void testColorControlString( void )
00055 {
00056 WTerminalColor c;
00057 TS_ASSERT_THROWS_NOTHING( c = WTerminalColor( WTerminalColor::Bold, WTerminalColor::FGRed, WTerminalColor::BGGreen ) );
00058
00059
00060 std::ostringstream ss;
00061 #ifdef __linux__
00062 char cStart = 0x1B;
00063 ss << cStart << "[" << 1 << ";" << 31 << ";" << 42 << "m";
00064 #endif
00065
00066 TS_ASSERT( ss.str() == c.m_colorString );
00067 }
00068
00069
00070
00071
00072 void testColorResetControlString( void )
00073 {
00074 WTerminalColor c;
00075 TS_ASSERT_THROWS_NOTHING( c = WTerminalColor( WTerminalColor::Bold, WTerminalColor::FGRed, WTerminalColor::BGGreen ) );
00076
00077
00078 std::ostringstream ss;
00079 #ifdef __linux__
00080 char cStart = 0x1B;
00081 ss << cStart << "[0m";
00082 #endif
00083
00084 TS_ASSERT( ss.str() == c.m_colorResetString );
00085 }
00086
00087
00088
00089
00090 void testColorDisabled( void )
00091 {
00092 WTerminalColor c;
00093 TS_ASSERT_THROWS_NOTHING( c = WTerminalColor( WTerminalColor::Bold, WTerminalColor::FGRed, WTerminalColor::BGGreen ) );
00094
00095 c.setEnabled( false );
00096 TS_ASSERT( c.m_colorResetString == "" );
00097 TS_ASSERT( c.m_colorString == "" );
00098 }
00099 };
00100
00101 #endif // WTERMINALCOLOR_TEST_H