[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / utils / test / TestHTMLTable.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "utils/HTMLTable.h"
22
23 #include "gtest/gtest.h"
24
25 // class CHTMLRow
26 // {
27 // public:
28 //   CHTMLRow(void);
29 //   virtual ~CHTMLRow(void);
30 //   int GetColumns() const;
31 //   const CStdString& GetColumValue(int iColumn) const;
32 //   void Parse(const CStdString& strTableRow);
33 // 
34 // protected:
35 //   std::vector<CStdString> m_vecColums;
36 // };
37 // 
38 // class CHTMLTable
39 // {
40 // public:
41 //   CHTMLTable(void);
42 //   virtual ~CHTMLTable(void);
43 //   void Parse(const CStdString& strHTML);
44 //   int GetRows() const;
45 //   const CHTMLRow& GetRow(int iRow) const;
46 // protected:
47 //   std::vector<CHTMLRow> m_vecRows;
48 // };
49
50 TEST(TestHTMLTable, General)
51 {
52   HTML::CHTMLTable table;
53   HTML::CHTMLRow row1, row2;
54   CStdString str;
55   str = "<table>\n"
56         "  <tr>\n"
57         "    <td>r1c1</td>\n"
58         "    <td>r1c2</td>\n"
59         "  </tr>\n"
60         "  <tr>\n"
61         "    <td>r2c1</td>\n"
62         "    <td>r2c2</td>\n"
63         "  </tr>\n"
64         "  <tr>\n"
65         "    <td>r3c1</td>\n"
66         "    <td>r3c2</td>\n"
67         "  </tr>\n"
68         "</table>\n";
69   table.Parse(str);
70   EXPECT_EQ(3, table.GetRows());
71
72   row1 = table.GetRow(0);
73   EXPECT_EQ(2, row1.GetColumns());
74   EXPECT_STREQ("r1c1", row1.GetColumValue(0));
75
76   str = "<tr>\n"
77         "  <td>new row1 column1</td>\n"
78         "  <td>new row1 column2</td>\n"
79         "  <td>new row1 column3</td>\n"
80         "</tr>\n";
81   row2.Parse(str);
82   EXPECT_EQ(3, row2.GetColumns());
83   EXPECT_STREQ("new row1 column2", row2.GetColumValue(1));
84 }