3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "IO/CSVLine.hpp"
24 #include "TestUtil.hpp"
32 CSVLine
line("1,2,x,4,5,6,7,8,9,10");
35 ok1(line
.Read(-1) == 1);
38 const auto rest
= line
.Rest();
39 ok1(std::string(rest
.begin(), rest
.end()) == "2,x,4,5,6,7,8,9,10");
42 ok1(line
.Skip() == 1);
46 ok1(line
.Read(-1) == 6);
48 // Test read_first_char()
49 ok1(line
.ReadFirstChar() == '7');
54 ok1(strcmp(temp
, "8") == 0);
56 // Test read_compare(char)
57 ok1(line
.ReadCompare("9"));
60 ok1(line
.Read(-1l) == 10l);
62 // Test default-value at line-end
63 ok1(line
.Read(11) == 11);
65 // Test default-value at line-end
67 ok1(!line
.ReadChecked(temp_int
));
73 CSVLine
line("A0,4.5555,4.5555,42,0,1.337,42.42,42,xxx");
76 ok1(line
.ReadHex(-1) == 160);
79 ok1(equals(fixed(line
.Read(0.0)), 4.5555));
82 ok1(equals(line
.Read(fixed(0)), 4.5555));
85 ok1(line
.Read(false) == true);
86 ok1(line
.Read(false) == false);
88 // Test read_checked()
90 ok1(line
.ReadChecked(temp_double
) && equals(fixed(temp_double
), 1.337));
93 ok1(line
.ReadChecked(temp_fixed
) && equals(temp_fixed
, 42.42));
96 ok1(line
.ReadChecked(temp_int
) && temp_int
== 42);
97 ok1(!line
.ReadChecked(temp_int
) && temp_int
== 42);
101 main(int argc
, char **argv
)
108 return exit_status();