3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
33 * Tests for help string formatting functions and classes.
35 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36 * \ingroup module_onlinehelp
38 #include <gtest/gtest.h>
40 #include "gromacs/onlinehelp/helpformat.h"
42 #include "testutils/stringtest.h"
47 const char g_wrapText[] = "A quick brown fox jumps over the lazy dog";
48 const char g_wrapText2[] = "A quick brown fox jumps\nover the lazy dog";
50 /********************************************************************
51 * Tests for TextTableFormatter
54 class TextTableFormatterTest : public gmx::test::StringTestBase
57 TextTableFormatterTest();
59 gmx::TextTableFormatter formatter_;
62 TextTableFormatterTest::TextTableFormatterTest()
64 formatter_.addColumn("Col1", 4, false);
65 formatter_.addColumn("Col2", 4, false);
66 formatter_.addColumn("Col3Wrap", 14, true);
67 formatter_.addColumn("Col4Wrap", 14, true);
70 TEST_F(TextTableFormatterTest, HandlesBasicCase)
73 formatter_.addColumnLine(0, "foo");
74 formatter_.addColumnLine(1, "bar");
75 formatter_.addColumnLine(2, g_wrapText);
76 formatter_.addColumnLine(3, g_wrapText2);
77 checkText(formatter_.formatRow(), "FormattedTable");
80 TEST_F(TextTableFormatterTest, HandlesOverflowingLines)
83 formatter_.addColumnLine(0, "foobar");
84 formatter_.addColumnLine(1, "barfoo");
85 formatter_.addColumnLine(2, g_wrapText);
86 formatter_.addColumnLine(3, g_wrapText2);
87 checkText(formatter_.formatRow(), "FormattedTable");
89 formatter_.addColumnLine(0, "foobar");
90 formatter_.addColumnLine(1, "barfoo");
91 formatter_.setColumnFirstLineOffset(1, 1);
92 formatter_.addColumnLine(2, g_wrapText);
93 formatter_.addColumnLine(3, g_wrapText2);
94 checkText(formatter_.formatRow(), "FormattedRow2");
96 formatter_.addColumnLine(0, "foobar");
97 formatter_.addColumnLine(1, "barfoo");
98 formatter_.setColumnFirstLineOffset(1, 1);
99 formatter_.addColumnLine(2, g_wrapText);
100 formatter_.setColumnFirstLineOffset(2, 2);
101 formatter_.addColumnLine(3, g_wrapText2);
102 checkText(formatter_.formatRow(), "FormattedRow3");
105 TEST_F(TextTableFormatterTest, HandlesEmptyColumns)
108 formatter_.addColumnLine(0, "foo");
109 formatter_.addColumnLine(1, "bar");
110 formatter_.addColumnLine(3, "Text");
111 checkText(formatter_.formatRow(), "FormattedTable");
113 formatter_.addColumnLine(0, "foo");
114 formatter_.addColumnLine(1, "bar");
115 formatter_.setColumnFirstLineOffset(2, 1);
116 formatter_.addColumnLine(3, "Text");
117 checkText(formatter_.formatRow(), "FormattedRow2");
119 formatter_.addColumnLine(0, "foo");
120 formatter_.addColumnLine(1, "bar");
121 formatter_.addColumnLine(2, "");
122 formatter_.setColumnFirstLineOffset(2, 1);
123 formatter_.addColumnLine(3, "Text");
124 checkText(formatter_.formatRow(), "FormattedRow3");