Skip to content

Commit 11378ab

Browse files
committed
Update Catch2 dependency
* Allow parsing of numbers beginning with + * Added CSV_BIGINT data type * Use FetchContent to include Catch2
1 parent 35f1849 commit 11378ab

25 files changed

+97
-18003
lines changed

include/internal/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ target_sources(csv
2020
csv_utility.cpp
2121
csv_utility.hpp
2222
csv_writer.hpp
23-
data_type.h
23+
"data_type.hpp"
2424
)
2525

2626
set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX)

include/internal/csv_reader.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "../external/mio.hpp"
1919
#include "basic_csv_parser.hpp"
2020
#include "common.hpp"
21-
#include "data_type.h"
21+
#include "data_type.hpp"
2222
#include "csv_format.hpp"
2323

2424
/** The all encompassing namespace */
@@ -87,8 +87,7 @@ namespace csv {
8787
CONSTEXPR_14 pointer operator->() { return &(this->row); }
8888

8989
iterator& operator++(); /**< Pre-increment iterator */
90-
iterator operator++(int); /**< Post-increment ierator */
91-
iterator& operator--();
90+
iterator operator++(int); /**< Post-increment iterator */
9291

9392
/** Returns true if iterators were constructed from the same CSVReader
9493
* and point to the same row

include/internal/csv_row.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <vector>
1515

1616
#include "common.hpp"
17-
#include "data_type.h"
17+
#include "data_type.hpp"
1818
#include "col_names.hpp"
1919

2020
namespace csv {

include/internal/csv_utility.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "common.hpp"
33
#include "csv_format.hpp"
44
#include "csv_reader.hpp"
5-
#include "data_type.h"
5+
#include "data_type.hpp"
66

77
#include <string>
88
#include <type_traits>

include/internal/csv_writer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <vector>
1212

1313
#include "common.hpp"
14-
#include "data_type.h"
14+
#include "data_type.hpp"
1515

1616
namespace csv {
1717
namespace internals {

include/internal/data_type.h renamed to include/internal/data_type.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace csv {
2525
CSV_INT16, /**< 16-bit integer (short on MSVC/GCC) */
2626
CSV_INT32, /**< 32-bit integer (int on MSVC/GCC) */
2727
CSV_INT64, /**< 64-bit integer (long long on MSVC/GCC) */
28+
CSV_BIGINT, /**< Value too big to fit in a 64-bit in */
2829
CSV_DOUBLE /**< Floating point value */
2930
};
3031

@@ -220,7 +221,7 @@ namespace csv {
220221
else if (number <= internals::CSV_INT64_MAX)
221222
return DataType::CSV_INT64;
222223
else // Conversion to long long will cause an overflow
223-
return DataType::CSV_DOUBLE;
224+
return DataType::CSV_BIGINT;
224225
}
225226

226227
/** Distinguishes numeric from other text values. Used by various
@@ -266,6 +267,12 @@ namespace csv {
266267
return DataType::CSV_STRING;
267268
}
268269
}
270+
break;
271+
case '+':
272+
if (!ws_allowed) {
273+
return DataType::CSV_STRING;
274+
}
275+
269276
break;
270277
case '-':
271278
if (!ws_allowed) {

single_include/csv.hpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -5085,6 +5085,7 @@ namespace csv {
50855085
CSV_INT16, /**< 16-bit integer (short on MSVC/GCC) */
50865086
CSV_INT32, /**< 32-bit integer (int on MSVC/GCC) */
50875087
CSV_INT64, /**< 64-bit integer (long long on MSVC/GCC) */
5088+
CSV_BIGINT, /**< Value too big to fit in a 64-bit in */
50885089
CSV_DOUBLE /**< Floating point value */
50895090
};
50905091

@@ -5280,7 +5281,7 @@ namespace csv {
52805281
else if (number <= internals::CSV_INT64_MAX)
52815282
return DataType::CSV_INT64;
52825283
else // Conversion to long long will cause an overflow
5283-
return DataType::CSV_DOUBLE;
5284+
return DataType::CSV_BIGINT;
52845285
}
52855286

52865287
/** Distinguishes numeric from other text values. Used by various
@@ -5326,6 +5327,12 @@ namespace csv {
53265327
return DataType::CSV_STRING;
53275328
}
53285329
}
5330+
break;
5331+
case '+':
5332+
if (!ws_allowed) {
5333+
return DataType::CSV_STRING;
5334+
}
5335+
53295336
break;
53305337
case '-':
53315338
if (!ws_allowed) {
@@ -6274,8 +6281,7 @@ namespace csv {
62746281
CONSTEXPR_14 pointer operator->() { return &(this->row); }
62756282

62766283
iterator& operator++(); /**< Pre-increment iterator */
6277-
iterator operator++(int); /**< Post-increment ierator */
6278-
iterator& operator--();
6284+
iterator operator++(int); /**< Post-increment iterator */
62796285

62806286
/** Returns true if iterators were constructed from the same CSVReader
62816287
* and point to the same row

single_include_test/csv.hpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -5085,6 +5085,7 @@ namespace csv {
50855085
CSV_INT16, /**< 16-bit integer (short on MSVC/GCC) */
50865086
CSV_INT32, /**< 32-bit integer (int on MSVC/GCC) */
50875087
CSV_INT64, /**< 64-bit integer (long long on MSVC/GCC) */
5088+
CSV_BIGINT, /**< Value too big to fit in a 64-bit in */
50885089
CSV_DOUBLE /**< Floating point value */
50895090
};
50905091

@@ -5280,7 +5281,7 @@ namespace csv {
52805281
else if (number <= internals::CSV_INT64_MAX)
52815282
return DataType::CSV_INT64;
52825283
else // Conversion to long long will cause an overflow
5283-
return DataType::CSV_DOUBLE;
5284+
return DataType::CSV_BIGINT;
52845285
}
52855286

52865287
/** Distinguishes numeric from other text values. Used by various
@@ -5326,6 +5327,12 @@ namespace csv {
53265327
return DataType::CSV_STRING;
53275328
}
53285329
}
5330+
break;
5331+
case '+':
5332+
if (!ws_allowed) {
5333+
return DataType::CSV_STRING;
5334+
}
5335+
53295336
break;
53305337
case '-':
53315338
if (!ws_allowed) {
@@ -6274,8 +6281,7 @@ namespace csv {
62746281
CONSTEXPR_14 pointer operator->() { return &(this->row); }
62756282

62766283
iterator& operator++(); /**< Pre-increment iterator */
6277-
iterator operator++(int); /**< Post-increment ierator */
6278-
iterator& operator--();
6284+
iterator operator++(int); /**< Post-increment iterator */
62796285

62806286
/** Returns true if iterators were constructed from the same CSVReader
62816287
* and point to the same row

tests/CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
include(FetchContent)
2+
3+
FetchContent_Declare(
4+
Catch2
5+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
6+
GIT_TAG v3.6.0
7+
)
8+
9+
FetchContent_MakeAvailable(Catch2)
10+
111
add_executable(csv_test "")
212
target_sources(csv_test
313
PRIVATE
414
${CSV_INCLUDE_DIR}/csv.hpp
5-
catch.hpp
615
main.cpp
716
test_csv_field.cpp
817
test_csv_field_array.cpp
@@ -20,6 +29,7 @@ target_sources(csv_test
2029
test_round_trip.cpp
2130
)
2231
target_link_libraries(csv_test csv)
32+
target_link_libraries(csv_test Catch2::Catch2WithMain)
2333

2434
if(MSVC)
2535
# Workaround to enable debugging unit tests in Visual Studio

0 commit comments

Comments
 (0)