From 75e7fb05c29be5de12294dbb6fbd48a8275ca121 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 28 Mar 2018 00:03:57 +0200 Subject: [PATCH] Unit tests update --- include/final/fc.h | 5 +- include/final/foptiattr.h | 7 ++ include/final/foptimove.h | 8 ++ include/final/fterm.h | 3 - src/foptimove.cpp | 35 +++++- src/test/Makefile.am | 3 + src/test/Makefile.in | 36 +++++- src/test/fmouse-test.cpp | 10 +- src/test/fobject-test.cpp | 2 +- src/test/foptimove-test.cpp | 215 ++++++++++++++++++++++++++++++++++++ 10 files changed, 306 insertions(+), 18 deletions(-) create mode 100644 src/test/foptimove-test.cpp diff --git a/include/final/fc.h b/include/final/fc.h index 424a63d9..253035fd 100644 --- a/include/final/fc.h +++ b/include/final/fc.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2017 Markus Gans * +* Copyright 2015-2018 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -27,6 +27,9 @@ #error "Only can be included directly." #endif +// Typecast to c-string +#define C_STR const_cast + // ASCII sequences #define ESC "\033" // Escape #define CSI ESC "[" // Control sequence introducer (7-bit) diff --git a/include/final/foptiattr.h b/include/final/foptiattr.h index 2a917d8a..8bdec076 100644 --- a/include/final/foptiattr.h +++ b/include/final/foptiattr.h @@ -121,6 +121,9 @@ class FOptiAttr friend bool operator == (const char_data&, const char_data&); friend bool operator != (const char_data&, const char_data&); + // Accessors + const char* getClassName() const; + // Mutators void setMaxColor (const int&); void setNoColorVideo (int); @@ -357,6 +360,10 @@ inline bool operator != ( const FOptiAttr::char_data& lhs, const FOptiAttr::char_data& rhs ) { return ! ( lhs == rhs ); } +//---------------------------------------------------------------------- +inline const char* FOptiAttr::getClassName() const +{ return "FOptiAttr"; } + //---------------------------------------------------------------------- inline void FOptiAttr::setMaxColor (const int& c) { max_color = c; } diff --git a/include/final/foptimove.h b/include/final/foptimove.h index 7ee4d4fb..2be696e3 100644 --- a/include/final/foptimove.h +++ b/include/final/foptimove.h @@ -80,6 +80,9 @@ class FOptiMove // Destructor ~FOptiMove(); + // Accessors + const char* getClassName() const; + // Mutators void setBaudRate (int); void setTabStop (int); @@ -108,6 +111,7 @@ class FOptiMove void set_eat_newline_glitch (const bool&); // Methods + void check_boundaries (int&, int&, int&, int&); char* moveCursor (int, int, int, int); void printDurations(); @@ -190,6 +194,10 @@ class FOptiMove // FOptiMove inline functions +//---------------------------------------------------------------------- +inline const char* FOptiMove::getClassName() const +{ return "FOptiMove"; } + //---------------------------------------------------------------------- inline void FOptiMove::set_auto_left_margin (const bool& bcap) { automatic_left_margin = bcap; } diff --git a/include/final/fterm.h b/include/final/fterm.h index ed47a90a..b6db6b97 100644 --- a/include/final/fterm.h +++ b/include/final/fterm.h @@ -51,9 +51,6 @@ #error "Only can be included directly." #endif -// Typecast to c-string -#define C_STR const_cast - #include "final/fconfig.h" #if defined(__linux__) diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 3b382846..d3d3cb93 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -22,6 +22,7 @@ #include +#include "final/fc.h" #include "final/foptimove.h" @@ -63,6 +64,11 @@ FOptiMove::FOptiMove (int baud) assert ( baud >= 0 ); move_buf[0] = '\0'; calculateCharDuration(); + + // ANSI set cursor address preset for undefined terminals + set_cursor_address (C_STR(CSI "%i%p1%d;%p2%dH")); + // Set carriage return preset + set_carriage_return (C_STR("\r")); } //---------------------------------------------------------------------- @@ -485,11 +491,36 @@ int FOptiMove::set_clr_eol (char cap[]) return F_clr_eol.length; } +//---------------------------------------------------------------------- +void FOptiMove::check_boundaries ( int& xold, int& yold + , int& xnew, int& ynew ) +{ + if ( xold < 0 || xold >= screen_width ) + xold = -1; + + if ( yold < 0 || yold >= screen_height ) + yold = -1; + + if ( xnew < 0 ) + xnew = 0; + + if ( ynew < 0 ) + ynew = 0; + + if ( xnew >= screen_width ) + xnew = screen_width - 1; + + if ( ynew >= screen_height ) + ynew = screen_height - 1; +} + //---------------------------------------------------------------------- char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew) { - int method = 0; - int move_time = LONG_DURATION; + int method = 0; + int move_time = LONG_DURATION; + + check_boundaries (xold, yold, xnew, ynew); // Method 0: direct cursor addressing if ( isMethod0Faster(move_time, xnew, ynew) ) diff --git a/src/test/Makefile.am b/src/test/Makefile.am index b8353111..815fbbc2 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -9,18 +9,21 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -Wall -Werror noinst_PROGRAMS = \ fobject_test \ fmouse_test \ + foptimove_test \ fstring_test \ fpoint_test \ frect_test fobject_test_SOURCES = fobject-test.cpp fmouse_test_SOURCES = fmouse-test.cpp +foptimove_test_SOURCES = foptimove-test.cpp fstring_test_SOURCES = fstring-test.cpp fpoint_test_SOURCES = fpoint-test.cpp frect_test_SOURCES = frect-test.cpp TESTS = fobject_test \ fmouse_test \ + foptimove_test \ fstring_test \ fpoint_test \ frect_test diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 6e3b58b7..0beac013 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -83,9 +83,12 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @CPPUNIT_TEST_TRUE@noinst_PROGRAMS = fobject_test$(EXEEXT) \ -@CPPUNIT_TEST_TRUE@ fmouse_test$(EXEEXT) fstring_test$(EXEEXT) \ -@CPPUNIT_TEST_TRUE@ fpoint_test$(EXEEXT) frect_test$(EXEEXT) +@CPPUNIT_TEST_TRUE@ fmouse_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ foptimove_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ fstring_test$(EXEEXT) fpoint_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ frect_test$(EXEEXT) @CPPUNIT_TEST_TRUE@TESTS = fobject_test$(EXEEXT) fmouse_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ foptimove_test$(EXEEXT) \ @CPPUNIT_TEST_TRUE@ fstring_test$(EXEEXT) fpoint_test$(EXEEXT) \ @CPPUNIT_TEST_TRUE@ frect_test$(EXEEXT) @CPPUNIT_TEST_TRUE@check_PROGRAMS = $(am__EXEEXT_1) @@ -105,8 +108,10 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @CPPUNIT_TEST_TRUE@am__EXEEXT_1 = fobject_test$(EXEEXT) \ -@CPPUNIT_TEST_TRUE@ fmouse_test$(EXEEXT) fstring_test$(EXEEXT) \ -@CPPUNIT_TEST_TRUE@ fpoint_test$(EXEEXT) frect_test$(EXEEXT) +@CPPUNIT_TEST_TRUE@ fmouse_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ foptimove_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ fstring_test$(EXEEXT) fpoint_test$(EXEEXT) \ +@CPPUNIT_TEST_TRUE@ frect_test$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am__fmouse_test_SOURCES_DIST = fmouse-test.cpp @CPPUNIT_TEST_TRUE@am_fmouse_test_OBJECTS = fmouse-test.$(OBJEXT) @@ -120,6 +125,11 @@ am__fobject_test_SOURCES_DIST = fobject-test.cpp @CPPUNIT_TEST_TRUE@am_fobject_test_OBJECTS = fobject-test.$(OBJEXT) fobject_test_OBJECTS = $(am_fobject_test_OBJECTS) fobject_test_LDADD = $(LDADD) +am__foptimove_test_SOURCES_DIST = foptimove-test.cpp +@CPPUNIT_TEST_TRUE@am_foptimove_test_OBJECTS = \ +@CPPUNIT_TEST_TRUE@ foptimove-test.$(OBJEXT) +foptimove_test_OBJECTS = $(am_foptimove_test_OBJECTS) +foptimove_test_LDADD = $(LDADD) am__fpoint_test_SOURCES_DIST = fpoint-test.cpp @CPPUNIT_TEST_TRUE@am_fpoint_test_OBJECTS = fpoint-test.$(OBJEXT) fpoint_test_OBJECTS = $(am_fpoint_test_OBJECTS) @@ -167,10 +177,11 @@ am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(fmouse_test_SOURCES) $(fobject_test_SOURCES) \ - $(fpoint_test_SOURCES) $(frect_test_SOURCES) \ - $(fstring_test_SOURCES) + $(foptimove_test_SOURCES) $(fpoint_test_SOURCES) \ + $(frect_test_SOURCES) $(fstring_test_SOURCES) DIST_SOURCES = $(am__fmouse_test_SOURCES_DIST) \ $(am__fobject_test_SOURCES_DIST) \ + $(am__foptimove_test_SOURCES_DIST) \ $(am__fpoint_test_SOURCES_DIST) $(am__frect_test_SOURCES_DIST) \ $(am__fstring_test_SOURCES_DIST) am__can_run_installinfo = \ @@ -532,6 +543,7 @@ top_srcdir = @top_srcdir@ @CPPUNIT_TEST_TRUE@AM_CPPFLAGS = -I$(top_srcdir)/include -Wall -Werror @CPPUNIT_TEST_TRUE@fobject_test_SOURCES = fobject-test.cpp @CPPUNIT_TEST_TRUE@fmouse_test_SOURCES = fmouse-test.cpp +@CPPUNIT_TEST_TRUE@foptimove_test_SOURCES = foptimove-test.cpp @CPPUNIT_TEST_TRUE@fstring_test_SOURCES = fstring-test.cpp @CPPUNIT_TEST_TRUE@fpoint_test_SOURCES = fpoint-test.cpp @CPPUNIT_TEST_TRUE@frect_test_SOURCES = frect-test.cpp @@ -596,6 +608,10 @@ fobject_test$(EXEEXT): $(fobject_test_OBJECTS) $(fobject_test_DEPENDENCIES) $(EX @rm -f fobject_test$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(fobject_test_OBJECTS) $(fobject_test_LDADD) $(LIBS) +foptimove_test$(EXEEXT): $(foptimove_test_OBJECTS) $(foptimove_test_DEPENDENCIES) $(EXTRA_foptimove_test_DEPENDENCIES) + @rm -f foptimove_test$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(foptimove_test_OBJECTS) $(foptimove_test_LDADD) $(LIBS) + fpoint_test$(EXEEXT): $(fpoint_test_OBJECTS) $(fpoint_test_DEPENDENCIES) $(EXTRA_fpoint_test_DEPENDENCIES) @rm -f fpoint_test$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(fpoint_test_OBJECTS) $(fpoint_test_LDADD) $(LIBS) @@ -616,6 +632,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmouse-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fobject-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptimove-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpoint-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frect-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstring-test.Po@am__quote@ @@ -854,6 +871,13 @@ fmouse_test.log: fmouse_test$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +foptimove_test.log: foptimove_test$(EXEEXT) + @p='foptimove_test$(EXEEXT)'; \ + b='foptimove_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) fstring_test.log: fstring_test$(EXEEXT) @p='fstring_test$(EXEEXT)'; \ b='fstring_test'; \ diff --git a/src/test/fmouse-test.cpp b/src/test/fmouse-test.cpp index 6b447790..34429555 100644 --- a/src/test/fmouse-test.cpp +++ b/src/test/fmouse-test.cpp @@ -269,7 +269,7 @@ void FMouseTest::x11MouseTest() x11_mouse.setRawData (rawdata1, sizeof(rawdata1)); CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() ); - CPPUNIT_ASSERT ( strcmp(rawdata1, "@@") == 0 ); + CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 ); timeval tv; FObject::getCurrentTime(&tv); @@ -573,7 +573,7 @@ void FMouseTest::sgrMouseTest() sgr_mouse.setRawData (rawdata1, sizeof(rawdata1)); CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() ); - CPPUNIT_ASSERT ( strcmp(rawdata1, "@@") == 0 ); + CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 ); timeval tv; FObject::getCurrentTime(&tv); @@ -861,7 +861,7 @@ void FMouseTest::sgrMouseTest() CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() ); - CPPUNIT_ASSERT ( strcmp(rawdata11, "@") == 0 ); + CPPUNIT_ASSERT ( std::strcmp(rawdata11, "@") == 0 ); } //---------------------------------------------------------------------- @@ -876,7 +876,7 @@ void FMouseTest::urxvtMouseTest() urxvt_mouse.setRawData (rawdata1, sizeof(rawdata1)); CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() ); - CPPUNIT_ASSERT ( strcmp(rawdata1, "@@") == 0 ); + CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 ); timeval tv; FObject::getCurrentTime(&tv); @@ -1163,7 +1163,7 @@ void FMouseTest::urxvtMouseTest() CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() ); - CPPUNIT_ASSERT ( strcmp(rawdata11, "@") == 0 ); + CPPUNIT_ASSERT ( std::strcmp(rawdata11, "@") == 0 ); // Negative values char rawdata12[] = { 0x1b, '[', '3', '2', ';', '-', '5', ';', '5', 'M' diff --git a/src/test/fobject-test.cpp b/src/test/fobject-test.cpp index 0795a3bb..c8baf633 100644 --- a/src/test/fobject-test.cpp +++ b/src/test/fobject-test.cpp @@ -1,5 +1,5 @@ /*********************************************************************** -* fobject-test.cpp - FPoint unit tests * +* fobject-test.cpp - FPoint unit tests * * * * This file is part of the Final Cut widget toolkit * * * diff --git a/src/test/foptimove-test.cpp b/src/test/foptimove-test.cpp new file mode 100644 index 00000000..aa629203 --- /dev/null +++ b/src/test/foptimove-test.cpp @@ -0,0 +1,215 @@ +/*********************************************************************** +* foptimove-test.cpp - FOptiMove unit tests * +* * +* This file is part of the Final Cut widget toolkit * +* * +* Copyright 2018 Markus Gans * +* * +* The Final Cut is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Lesser General Public License * +* as published by the Free Software Foundation; either version 3 of * +* the License, or (at your option) any later version. * +* * +* The Final Cut is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public * +* License along with this program. If not, see * +* . * +***********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + + +#define CPPUNIT_ASSERT_CSTRING(expected, actual) \ + check_c_string (expected, actual, CPPUNIT_SOURCELINE()) + +//---------------------------------------------------------------------- +void check_c_string ( const char* s1 + , const char* s2 + , CppUnit::SourceLine sourceLine ) +{ + if ( std::strcmp (s1, s2) == 0 ) + return; + + ::CppUnit::Asserter::fail ("Strings are not equal", sourceLine); +} + + +//---------------------------------------------------------------------- +// class FOptiMoveTest +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class FOptiMoveTest : public CPPUNIT_NS::TestFixture +{ + public: + FOptiMoveTest() + { } + + protected: + void classNameTest(); + void noArgumentTest(); + void ansiTest(); + + private: + std::string printSequence (const std::string&); + + // Adds code needed to register the test suite + CPPUNIT_TEST_SUITE (FOptiMoveTest); + + // Add a methods to the test suite + CPPUNIT_TEST (classNameTest); + CPPUNIT_TEST (noArgumentTest); + CPPUNIT_TEST (ansiTest); + + // End of test suite definition + CPPUNIT_TEST_SUITE_END(); +}; +#pragma pack(pop) + + +//---------------------------------------------------------------------- +void FOptiMoveTest::classNameTest() +{ + FOptiMove opti_move; + const char* const classname = opti_move.getClassName(); + CPPUNIT_ASSERT_CSTRING ( classname, "FOptiMove"); +} + +//---------------------------------------------------------------------- +void FOptiMoveTest::noArgumentTest() +{ + FOptiMove om; + CPPUNIT_ASSERT_CSTRING (om.moveCursor (1, 1, 5, 5), C_STR(CSI "6;6H")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 9, 9), C_STR(CSI "10;10H")); + + // No set cursor address preset + om.set_cursor_address (0); + CPPUNIT_ASSERT (om.moveCursor (1, 1, 5, 5) == 0); +} + +//---------------------------------------------------------------------- +void FOptiMoveTest::ansiTest() +{ + FOptiMove om; + om.setTermSize (80, 25); + om.setBaudRate (19200); + om.setTabStop (8); + om.set_tabular (C_STR("\t")); + om.set_back_tab (C_STR(CSI "Z")); + om.set_cursor_home (C_STR(CSI "H")); + om.set_carriage_return (C_STR("\r")); + om.set_cursor_up (C_STR(CSI "A")); + om.set_cursor_down (C_STR(CSI "B")); + om.set_cursor_left (C_STR(CSI "D")); + om.set_cursor_right (C_STR(CSI "C")); + om.set_cursor_address (C_STR(CSI "%i%p1%d;%p2%dH")); + om.set_column_address (C_STR(CSI "%i%p1%dG")); + om.set_row_address (C_STR(CSI "%i%p1%dd")); + om.set_parm_up_cursor (C_STR(CSI "%p1%dA")); + om.set_parm_down_cursor (C_STR(CSI "%p1%dB")); + om.set_parm_left_cursor (C_STR(CSI "%p1%dD")); + om.set_parm_right_cursor (C_STR(CSI "%p1%dC")); + + CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(CSI "6;6H")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR(CSI "H")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 1), C_STR("\r")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (79, 1, 0, 2), C_STR("\r" CSI "B")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 10, 4), C_STR(CSI "C")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 4, 9, 4), C_STR(CSI "D")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (9, 4, 11, 4), C_STR(CSI "12G")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (11, 4, 9, 4), C_STR(CSI "10G")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (1, 0, 8, 0), C_STR("\t")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 0, 16, 1), C_STR(CSI "B")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 1, 16, 0), C_STR(CSI "A")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 0, 16, 2), C_STR(CSI "3d")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (16, 2, 16, 0), C_STR(CSI "1d")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (3, 2, 79, 2), C_STR(CSI "80G")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 75, 20), C_STR(CSI "21;76H")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (39, 0, 32, 0), C_STR(CSI "Z")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 0, 8, 0), C_STR("\r\t")); + + // xold is outside screen + CPPUNIT_ASSERT_CSTRING (om.moveCursor (99, 10, 79, 10), C_STR(CSI "11;80H")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (-3, 33, 50, 10), C_STR(CSI "11;51H")); + + // ynew is outside screen + CPPUNIT_ASSERT_CSTRING (om.moveCursor (23, 33, 23, 10), C_STR(CSI "11;24H")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (23, -3, 12, 10), C_STR(CSI "11;13H")); + + // xnew is outside screen + CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 22, 100, 22), C_STR(CSI "80G")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (3, 22, -5, 22), C_STR("\r")); + + // ynew is outside screen + CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 22, 53, 40), C_STR(CSI "25d")); + CPPUNIT_ASSERT_CSTRING (om.moveCursor (53, 2, 53, -3), C_STR(CSI "1d")); + + //om.printDurations();S +/* + om.set_cursor_to_ll (TCAP(fc::t_cursor_to_ll)); + om.set_auto_left_margin (FTermcap::automatic_left_margin); + om.set_eat_newline_glitch (FTermcap::eat_nl_glitch); +*/ +} + +//---------------------------------------------------------------------- +std::string FOptiMoveTest::printSequence (const std::string& s) +{ + std::ostringstream sequence; + + for (std::string::size_type i = 0; i < s.length(); ++i) + { + switch ( int(s[i]) ) + { + case 0x08: + sequence << "BS "; + break; + + case 0x09: + sequence << "TAB "; + break; + + case 0x0a: + sequence << "LF "; + break; + + case 0x0d: + sequence << "CR "; + break; + + case 0x1b: + sequence << "Esc "; + break; + + default: + sequence << s[i]; + sequence << ' '; + } + } + + return sequence.str(); +} + +// Put the test suite in the registry +CPPUNIT_TEST_SUITE_REGISTRATION (FOptiMoveTest); + +// The general unit test main part +#include