[view_curses] add some tests for mvwattrline

pull/97/head
Timothy Stack 10 years ago
parent 112986da79
commit f77b601e9a

@ -283,15 +283,27 @@ public:
/** @return The attributes for the string. */
string_attrs_t &get_attrs() { return this->al_attrs; };
attr_line_t &with_string(const std::string &str) {
this->al_string = str;
return *this;
}
attr_line_t &with_attr(const string_attr &sa) {
this->al_attrs.push_back(sa);
return *this;
};
size_t length() const { return this->al_string.length(); };
void operator=(const std::string &rhs) { this->al_string = rhs; };
/** Clear the string and the attributes for the string. */
void clear()
attr_line_t &clear()
{
this->al_string.clear();
this->al_attrs.clear();
return *this;
};
private:

@ -19,6 +19,7 @@ check_PROGRAMS = \
drive_grep_proc \
drive_listview \
drive_logfile \
drive_mvwattrline \
drive_sequencer \
drive_sql \
drive_view_colors \
@ -104,6 +105,9 @@ drive_data_scanner_LDADD = \
-lpcrecpp \
$(CURSES_LIB)
drive_mvwattrline_SOURCES = drive_mvwattrline.cc
drive_mvwattrline_LDADD = ../src/libdiag.a $(CURSES_LIB)
drive_view_colors_SOURCES = drive_view_colors.cc
drive_view_colors_LDADD = ../src/libdiag.a $(CURSES_LIB)
@ -138,6 +142,7 @@ dist_noinst_SCRIPTS = \
test_line_buffer.sh \
test_listview.sh \
test_logfile.sh \
test_mvwattrline.sh \
test_sessions.sh \
test_sql.sh \
test_sql_coll_func.sh \
@ -175,6 +180,7 @@ dist_noinst_DATA = \
logfile_syslog.1 \
logfile_tcsh_history.0 \
logfile_with_a_really_long_name_to_test_a_bug_with_long_names.0 \
mvwattrline_output.0 \
simple-db.sql \
view_colors_output.0 \
vt52_curses_input.0 \
@ -198,6 +204,7 @@ TESTS = \
test_line_buffer2 \
test_line_buffer.sh \
test_listview.sh \
test_mvwattrline.sh \
test_grep_proc.sh \
test_grep_proc2 \
test_hist_source \

@ -82,10 +82,10 @@ host_triplet = @host@
check_PROGRAMS = drive_data_scanner$(EXEEXT) \
drive_line_buffer$(EXEEXT) drive_grep_proc$(EXEEXT) \
drive_listview$(EXEEXT) drive_logfile$(EXEEXT) \
drive_sequencer$(EXEEXT) drive_sql$(EXEEXT) \
drive_view_colors$(EXEEXT) drive_vt52_curses$(EXEEXT) \
drive_readline_curses$(EXEEXT) slicer$(EXEEXT) \
scripty$(EXEEXT) test_ansi_scrubber$(EXEEXT) \
drive_mvwattrline$(EXEEXT) drive_sequencer$(EXEEXT) \
drive_sql$(EXEEXT) drive_view_colors$(EXEEXT) \
drive_vt52_curses$(EXEEXT) drive_readline_curses$(EXEEXT) \
slicer$(EXEEXT) scripty$(EXEEXT) test_ansi_scrubber$(EXEEXT) \
test_auto_fd$(EXEEXT) test_auto_mem$(EXEEXT) \
test_bookmarks$(EXEEXT) test_grep_proc2$(EXEEXT) \
test_hist_source$(EXEEXT) test_line_buffer2$(EXEEXT) \
@ -94,11 +94,11 @@ check_PROGRAMS = drive_data_scanner$(EXEEXT) \
TESTS = test_ansi_scrubber$(EXEEXT) test_auto_fd$(EXEEXT) \
test_auto_mem$(EXEEXT) test_bookmarks$(EXEEXT) test_cmds.sh \
test_line_buffer2$(EXEEXT) test_line_buffer.sh \
test_listview.sh test_grep_proc.sh test_grep_proc2$(EXEEXT) \
test_hist_source$(EXEEXT) test_json_format.sh \
test_pcrepp$(EXEEXT) test_sessions.sh test_sql.sh \
test_sql_coll_func.sh test_sql_fs_func.sh test_sql_str_func.sh \
test_view_colors.sh test_vt52_curses.sh \
test_listview.sh test_mvwattrline.sh test_grep_proc.sh \
test_grep_proc2$(EXEEXT) test_hist_source$(EXEEXT) \
test_json_format.sh test_pcrepp$(EXEEXT) test_sessions.sh \
test_sql.sh test_sql_coll_func.sh test_sql_fs_func.sh \
test_sql_str_func.sh test_view_colors.sh test_vt52_curses.sh \
test_top_status$(EXEEXT) test_data_parser.sh \
test_yajlpp$(EXEEXT)
subdir = test
@ -137,6 +137,10 @@ am_drive_logfile_OBJECTS = drive_logfile.$(OBJEXT)
drive_logfile_OBJECTS = $(am_drive_logfile_OBJECTS)
drive_logfile_DEPENDENCIES = ../src/libdiag.a $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_drive_mvwattrline_OBJECTS = drive_mvwattrline.$(OBJEXT)
drive_mvwattrline_OBJECTS = $(am_drive_mvwattrline_OBJECTS)
drive_mvwattrline_DEPENDENCIES = ../src/libdiag.a \
$(am__DEPENDENCIES_1)
am_drive_readline_curses_OBJECTS = drive_readline_curses.$(OBJEXT)
drive_readline_curses_OBJECTS = $(am_drive_readline_curses_OBJECTS)
drive_readline_curses_DEPENDENCIES = ../src/libdiag.a \
@ -229,18 +233,7 @@ am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(drive_data_scanner_SOURCES) $(drive_grep_proc_SOURCES) \
$(drive_line_buffer_SOURCES) $(drive_listview_SOURCES) \
$(drive_logfile_SOURCES) $(drive_readline_curses_SOURCES) \
$(drive_sequencer_SOURCES) $(drive_sql_SOURCES) \
$(drive_view_colors_SOURCES) $(drive_vt52_curses_SOURCES) \
$(scripty_SOURCES) $(slicer_SOURCES) \
$(test_ansi_scrubber_SOURCES) $(test_auto_fd_SOURCES) \
$(test_auto_mem_SOURCES) $(test_bookmarks_SOURCES) \
$(test_grep_proc2_SOURCES) $(test_hist_source_SOURCES) \
$(test_line_buffer2_SOURCES) $(test_pcrepp_SOURCES) \
$(test_top_status_SOURCES) $(test_yajlpp_SOURCES)
DIST_SOURCES = $(drive_data_scanner_SOURCES) \
$(drive_grep_proc_SOURCES) $(drive_line_buffer_SOURCES) \
$(drive_listview_SOURCES) $(drive_logfile_SOURCES) \
$(drive_logfile_SOURCES) $(drive_mvwattrline_SOURCES) \
$(drive_readline_curses_SOURCES) $(drive_sequencer_SOURCES) \
$(drive_sql_SOURCES) $(drive_view_colors_SOURCES) \
$(drive_vt52_curses_SOURCES) $(scripty_SOURCES) \
@ -250,6 +243,18 @@ DIST_SOURCES = $(drive_data_scanner_SOURCES) \
$(test_hist_source_SOURCES) $(test_line_buffer2_SOURCES) \
$(test_pcrepp_SOURCES) $(test_top_status_SOURCES) \
$(test_yajlpp_SOURCES)
DIST_SOURCES = $(drive_data_scanner_SOURCES) \
$(drive_grep_proc_SOURCES) $(drive_line_buffer_SOURCES) \
$(drive_listview_SOURCES) $(drive_logfile_SOURCES) \
$(drive_mvwattrline_SOURCES) $(drive_readline_curses_SOURCES) \
$(drive_sequencer_SOURCES) $(drive_sql_SOURCES) \
$(drive_view_colors_SOURCES) $(drive_vt52_curses_SOURCES) \
$(scripty_SOURCES) $(slicer_SOURCES) \
$(test_ansi_scrubber_SOURCES) $(test_auto_fd_SOURCES) \
$(test_auto_mem_SOURCES) $(test_bookmarks_SOURCES) \
$(test_grep_proc2_SOURCES) $(test_hist_source_SOURCES) \
$(test_line_buffer2_SOURCES) $(test_pcrepp_SOURCES) \
$(test_top_status_SOURCES) $(test_yajlpp_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -662,6 +667,8 @@ drive_data_scanner_LDADD = \
-lpcrecpp \
$(CURSES_LIB)
drive_mvwattrline_SOURCES = drive_mvwattrline.cc
drive_mvwattrline_LDADD = ../src/libdiag.a $(CURSES_LIB)
drive_view_colors_SOURCES = drive_view_colors.cc
drive_view_colors_LDADD = ../src/libdiag.a $(CURSES_LIB)
drive_vt52_curses_SOURCES = drive_vt52_curses.cc
@ -692,6 +699,7 @@ dist_noinst_SCRIPTS = \
test_line_buffer.sh \
test_listview.sh \
test_logfile.sh \
test_mvwattrline.sh \
test_sessions.sh \
test_sql.sh \
test_sql_coll_func.sh \
@ -729,6 +737,7 @@ dist_noinst_DATA = \
logfile_syslog.1 \
logfile_tcsh_history.0 \
logfile_with_a_really_long_name_to_test_a_bug_with_long_names.0 \
mvwattrline_output.0 \
simple-db.sql \
view_colors_output.0 \
vt52_curses_input.0 \
@ -813,6 +822,10 @@ drive_logfile$(EXEEXT): $(drive_logfile_OBJECTS) $(drive_logfile_DEPENDENCIES) $
@rm -f drive_logfile$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(drive_logfile_OBJECTS) $(drive_logfile_LDADD) $(LIBS)
drive_mvwattrline$(EXEEXT): $(drive_mvwattrline_OBJECTS) $(drive_mvwattrline_DEPENDENCIES) $(EXTRA_drive_mvwattrline_DEPENDENCIES)
@rm -f drive_mvwattrline$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(drive_mvwattrline_OBJECTS) $(drive_mvwattrline_LDADD) $(LIBS)
drive_readline_curses$(EXEEXT): $(drive_readline_curses_OBJECTS) $(drive_readline_curses_DEPENDENCIES) $(EXTRA_drive_readline_curses_DEPENDENCIES)
@rm -f drive_readline_curses$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(drive_readline_curses_OBJECTS) $(drive_readline_curses_LDADD) $(LIBS)
@ -892,6 +905,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_line_buffer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_listview.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_logfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_mvwattrline.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_readline_curses.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_sequencer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drive_sql.Po@am__quote@
@ -1175,6 +1189,13 @@ test_listview.sh.log: test_listview.sh
--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)
test_mvwattrline.sh.log: test_mvwattrline.sh
@p='test_mvwattrline.sh'; \
b='test_mvwattrline.sh'; \
$(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)
test_grep_proc.sh.log: test_grep_proc.sh
@p='test_grep_proc.sh'; \
b='test_grep_proc.sh'; \

@ -0,0 +1,100 @@
/**
* Copyright (c) 2014, Timothy Stack
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Timothy Stack nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "view_curses.hh"
int main(int argc, char *argv[])
{
int c, retval = EXIT_SUCCESS;
bool wait_for_input = false;
while ((c = getopt(argc, argv, "w")) != -1) {
switch (c) {
case 'w':
wait_for_input = true;
break;
}
}
{
screen_curses sc;
WINDOW *win = sc.get_window();
struct line_range lr(0, 40);
attr_line_t al;
int y = 0;
noecho();
view_colors::singleton().init();
al.with_string("Plain text");
view_curses::mvwattrline(win, y++, 0, al, lr);
al.clear().with_string("\tLeading tab")
.with_attr(string_attr(line_range(0, 1),
&view_curses::VC_STYLE,
A_REVERSE));
view_curses::mvwattrline(win, y++, 0, al, lr);
al.clear().with_string("Tab\twith text")
.with_attr(string_attr(line_range(1, 4),
&view_curses::VC_STYLE,
A_REVERSE));
view_curses::mvwattrline(win, y++, 0, al, lr);
al.clear().with_string("Tab\twith text #2")
.with_attr(string_attr(line_range(3, 4),
&view_curses::VC_STYLE,
A_REVERSE));
view_curses::mvwattrline(win, y++, 0, al, lr);
al.clear().with_string("Text with mixed attributes.")
.with_attr(string_attr(line_range(5, 9),
&view_curses::VC_STYLE,
view_colors::ansi_color_pair(COLOR_RED, COLOR_BLACK)))
.with_attr(string_attr(line_range(7, 12),
&view_curses::VC_STYLE,
A_REVERSE));
view_curses::mvwattrline(win, y++, 0, al, lr);
wmove(win, y, 0);
refresh();
if (wait_for_input) {
getch();
}
}
return retval;
}

@ -0,0 +1 @@
read 1b29301b371b5b3f3437681b5b313b3234721b5b6d1b5b346c1b5b6d1b5b6d1b5b33376d1b5b34306d1b5b313b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b323b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b333b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b343b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b353b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b363b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b373b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b383b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b393b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31303b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31313b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31323b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31333b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31343b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31353b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31363b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31373b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31383b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b31393b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b32303b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b32313b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b32323b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b32333b314820202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020201b5b32343b3148202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200820081b5b3468201b5b346c1b5b481b5b33376d1b5b34306d506c61696e20746578742020202020202020202020202020202020202020202020202020202020200d0a1b5b376d20202020202020201b5b6d1b5b33376d1b5b34306d4c656164696e67207461622020202020202020202020202020202020202020200d0a541b5b376d616220202020201b5b6d1b5b33376d1b5b34306d77697468207465787420202020202020202020202020202020202020202020200d0a5461621b5b376d20202020201b5b6d1b5b33376d1b5b34306d77697468207465787420233220202020202020202020202020202020202020200d0a54657874201b5b33316d1b5b34306d77691b5b376d74681b5b33376d1b5b34306d206d691b5b6d1b5b33376d1b5b34306d78656420617474726962757465732e202020202020202020202020200d0a1b5b6d1b5b6d1b5b33376d1b5b34306d1b5b6d1b5b3138421b5b4b1b5b32343b31481b5b324a1b5b3f34376c1b380d1b5b3f316c1b3e

@ -0,0 +1,6 @@
#! /bin/bash
run_test ./scripty -n -e ${srcdir}/mvwattrline_output.0 -- \
./drive_mvwattrline < /dev/null
on_error_fail_with "mvwattrline does not work"
Loading…
Cancel
Save