Skip to content

Commit

Permalink
Update Catch2 dependency
Browse files Browse the repository at this point in the history
 * Allow parsing of numbers beginning with +
 * Added CSV_BIGINT data type
 * Use FetchContent to include Catch2
  • Loading branch information
vincentlaucsb committed May 20, 2024
1 parent 35f1849 commit 11378ab
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 18,003 deletions.
2 changes: 1 addition & 1 deletion include/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ target_sources(csv
csv_utility.cpp
csv_utility.hpp
csv_writer.hpp
data_type.h
"data_type.hpp"
)

set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX)
Expand Down
5 changes: 2 additions & 3 deletions include/internal/csv_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "../external/mio.hpp"
#include "basic_csv_parser.hpp"
#include "common.hpp"
#include "data_type.h"
#include "data_type.hpp"
#include "csv_format.hpp"

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

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

/** Returns true if iterators were constructed from the same CSVReader
* and point to the same row
Expand Down
2 changes: 1 addition & 1 deletion include/internal/csv_row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <vector>

#include "common.hpp"
#include "data_type.h"
#include "data_type.hpp"
#include "col_names.hpp"

namespace csv {
Expand Down
2 changes: 1 addition & 1 deletion include/internal/csv_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "common.hpp"
#include "csv_format.hpp"
#include "csv_reader.hpp"
#include "data_type.h"
#include "data_type.hpp"

#include <string>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion include/internal/csv_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <vector>

#include "common.hpp"
#include "data_type.h"
#include "data_type.hpp"

namespace csv {
namespace internals {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace csv {
CSV_INT16, /**< 16-bit integer (short on MSVC/GCC) */
CSV_INT32, /**< 32-bit integer (int on MSVC/GCC) */
CSV_INT64, /**< 64-bit integer (long long on MSVC/GCC) */
CSV_BIGINT, /**< Value too big to fit in a 64-bit in */
CSV_DOUBLE /**< Floating point value */
};

Expand Down Expand Up @@ -220,7 +221,7 @@ namespace csv {
else if (number <= internals::CSV_INT64_MAX)
return DataType::CSV_INT64;
else // Conversion to long long will cause an overflow
return DataType::CSV_DOUBLE;
return DataType::CSV_BIGINT;
}

/** Distinguishes numeric from other text values. Used by various
Expand Down Expand Up @@ -266,6 +267,12 @@ namespace csv {
return DataType::CSV_STRING;
}
}
break;
case '+':
if (!ws_allowed) {
return DataType::CSV_STRING;
}

break;
case '-':
if (!ws_allowed) {
Expand Down
12 changes: 9 additions & 3 deletions single_include/csv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5085,6 +5085,7 @@ namespace csv {
CSV_INT16, /**< 16-bit integer (short on MSVC/GCC) */
CSV_INT32, /**< 32-bit integer (int on MSVC/GCC) */
CSV_INT64, /**< 64-bit integer (long long on MSVC/GCC) */
CSV_BIGINT, /**< Value too big to fit in a 64-bit in */
CSV_DOUBLE /**< Floating point value */
};

Expand Down Expand Up @@ -5280,7 +5281,7 @@ namespace csv {
else if (number <= internals::CSV_INT64_MAX)
return DataType::CSV_INT64;
else // Conversion to long long will cause an overflow
return DataType::CSV_DOUBLE;
return DataType::CSV_BIGINT;
}

/** Distinguishes numeric from other text values. Used by various
Expand Down Expand Up @@ -5326,6 +5327,12 @@ namespace csv {
return DataType::CSV_STRING;
}
}
break;
case '+':
if (!ws_allowed) {
return DataType::CSV_STRING;
}

break;
case '-':
if (!ws_allowed) {
Expand Down Expand Up @@ -6274,8 +6281,7 @@ namespace csv {
CONSTEXPR_14 pointer operator->() { return &(this->row); }

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

/** Returns true if iterators were constructed from the same CSVReader
* and point to the same row
Expand Down
12 changes: 9 additions & 3 deletions single_include_test/csv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5085,6 +5085,7 @@ namespace csv {
CSV_INT16, /**< 16-bit integer (short on MSVC/GCC) */
CSV_INT32, /**< 32-bit integer (int on MSVC/GCC) */
CSV_INT64, /**< 64-bit integer (long long on MSVC/GCC) */
CSV_BIGINT, /**< Value too big to fit in a 64-bit in */
CSV_DOUBLE /**< Floating point value */
};

Expand Down Expand Up @@ -5280,7 +5281,7 @@ namespace csv {
else if (number <= internals::CSV_INT64_MAX)
return DataType::CSV_INT64;
else // Conversion to long long will cause an overflow
return DataType::CSV_DOUBLE;
return DataType::CSV_BIGINT;
}

/** Distinguishes numeric from other text values. Used by various
Expand Down Expand Up @@ -5326,6 +5327,12 @@ namespace csv {
return DataType::CSV_STRING;
}
}
break;
case '+':
if (!ws_allowed) {
return DataType::CSV_STRING;
}

break;
case '-':
if (!ws_allowed) {
Expand Down Expand Up @@ -6274,8 +6281,7 @@ namespace csv {
CONSTEXPR_14 pointer operator->() { return &(this->row); }

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

/** Returns true if iterators were constructed from the same CSVReader
* and point to the same row
Expand Down
12 changes: 11 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
include(FetchContent)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.6.0
)

FetchContent_MakeAvailable(Catch2)

add_executable(csv_test "")
target_sources(csv_test
PRIVATE
${CSV_INCLUDE_DIR}/csv.hpp
catch.hpp
main.cpp
test_csv_field.cpp
test_csv_field_array.cpp
Expand All @@ -20,6 +29,7 @@ target_sources(csv_test
test_round_trip.cpp
)
target_link_libraries(csv_test csv)
target_link_libraries(csv_test Catch2::Catch2WithMain)

if(MSVC)
# Workaround to enable debugging unit tests in Visual Studio
Expand Down

0 comments on commit 11378ab

Please sign in to comment.