[protozero] 01/06: Imported Upstream version 1.4.1

Bas Couwenberg sebastic at debian.org
Mon Aug 22 05:44:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository protozero.

commit 8bd1f4b656f5c4d005911908c87cd2378830986e
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Mon Aug 22 07:28:47 2016 +0200

    Imported Upstream version 1.4.1
---
 CHANGELOG.md                      | 10 +++++++++
 UPGRADING.md                      |  5 +++++
 include/protozero/pbf_writer.hpp  |  8 +++++--
 include/protozero/version.hpp     |  2 +-
 include_dirs.js                   |  2 ++
 package.json                      |  4 ++--
 test/create_pbf_test_data.sh      |  2 +-
 test/t/enum/data-max.pbf          |  1 +
 test/t/enum/data-min.pbf          |  1 +
 test/t/enum/data-neg.pbf          |  1 +
 test/t/enum/test_cases.cpp        | 45 +++++++++++++++++++++++++++++++++++++++
 test/t/enum/testcase.cpp          |  9 ++++++++
 test/t/enum/testcase.proto        |  7 ++++++
 test/t/enum/writer_test_cases.cpp | 24 +++++++++++++++++++++
 14 files changed, 115 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 43dbe13..34037bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 ### Fixed
 
 
+## [1.4.1] - 2016-08-21
+
+### Fixed
+
+ - GCC 4.8 compile fixed
+
+### Added
+
+- New ability to dynamically require the module as a node module to ease building against from other node C++ modules.
+
 ## [1.4.0] - 2016-07-22
 
 ### Changed
diff --git a/UPGRADING.md b/UPGRADING.md
index 22d198c..16b0fa3 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -13,6 +13,11 @@ macro `PROTOZERO_STRICT_API` in which case Protozero will compile without the
 code used for backwards compatibilty. You will then get compile errors for
 older API usages.
 
+## Upgrading from *v1.4.0* to *v1.4.1*
+
+* You can now do `require('protozero')` in nodejs to print the path
+  to the include paths for the protozero headers.
+
 ## Upgrading from *v1.3.0* to *v1.4.0*
 
 * Functions in `pbf_reader` (and the derived `pbf_message`) called
diff --git a/include/protozero/pbf_writer.hpp b/include/protozero/pbf_writer.hpp
index 3ce0f14..bce1c3f 100644
--- a/include/protozero/pbf_writer.hpp
+++ b/include/protozero/pbf_writer.hpp
@@ -156,12 +156,16 @@ class pbf_writer {
     // The number of bytes to reserve for the varint holding the length of
     // a length-delimited field. The length has to fit into pbf_length_type,
     // and a varint needs 8 bit for every 7 bit.
-    static constexpr const int reserve_bytes = sizeof(pbf_length_type) * 8 / 7 + 1;
+    enum constant_reserve_bytes : int {
+        reserve_bytes = sizeof(pbf_length_type) * 8 / 7 + 1
+    };
 
     // If m_rollpack_pos is set to this special value, it means that when
     // the submessage is closed, nothing needs to be done, because the length
     // of the submessage has already been written correctly.
-    static constexpr const std::size_t size_is_known = std::numeric_limits<std::size_t>::max();
+    enum constant_size_is_known : std::size_t {
+        size_is_known = std::numeric_limits<std::size_t>::max()
+    };
 
     void open_submessage(pbf_tag_type tag, std::size_t size) {
         protozero_assert(m_pos == 0);
diff --git a/include/protozero/version.hpp b/include/protozero/version.hpp
index d427941..975aad8 100644
--- a/include/protozero/version.hpp
+++ b/include/protozero/version.hpp
@@ -23,7 +23,7 @@ documentation.
 #define PROTOZERO_VERSION_MINOR 4
 
 /// The patch number
-#define PROTOZERO_VERSION_PATCH 0
+#define PROTOZERO_VERSION_PATCH 1
 
 /// The complete version number
 #define PROTOZERO_VERSION_CODE (PROTOZERO_VERSION_MAJOR * 10000 + PROTOZERO_VERSION_MINOR * 100 + PROTOZERO_VERSION_PATCH)
diff --git a/include_dirs.js b/include_dirs.js
new file mode 100644
index 0000000..b3c2686
--- /dev/null
+++ b/include_dirs.js
@@ -0,0 +1,2 @@
+var path = require('path');
+console.log(path.join(path.relative('.', __dirname),'include'));
diff --git a/package.json b/package.json
index 679d59c..1eca15a 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
 {
     "name": "protozero",
-    "version": "1.4.0",
+    "version": "1.4.1",
     "description": "Minimalist protocol buffer decoder and encoder in C++",
-    "main": "./package.json",
+    "main": "include_dirs.js",
     "repository"   :  {
       "type" : "git",
       "url"  : "git://github.com/mapbox/protozero.git"
diff --git a/test/create_pbf_test_data.sh b/test/create_pbf_test_data.sh
index 2e25c31..d465623 100755
--- a/test/create_pbf_test_data.sh
+++ b/test/create_pbf_test_data.sh
@@ -21,7 +21,7 @@ echo "Generating $1..."
 cd $1
 if [ -f testcase.proto ]; then
     protoc --cpp_out=. testcase.proto
-    $CXX -std=c++11 -I../../include -o testcase testcase.cpp testcase.pb.cc -lprotobuf-lite -pthreads
+    $CXX -std=c++11 -I../../include -o testcase testcase.cpp testcase.pb.cc -lprotobuf-lite -pthread
     ./testcase
 fi
 cd ../..
diff --git a/test/t/enum/data-max.pbf b/test/t/enum/data-max.pbf
new file mode 100644
index 0000000..f7d9ded
--- /dev/null
+++ b/test/t/enum/data-max.pbf
@@ -0,0 +1 @@
+����
\ No newline at end of file
diff --git a/test/t/enum/data-min.pbf b/test/t/enum/data-min.pbf
new file mode 100644
index 0000000..955e6a2
--- /dev/null
+++ b/test/t/enum/data-min.pbf
@@ -0,0 +1 @@
+���������
\ No newline at end of file
diff --git a/test/t/enum/data-neg.pbf b/test/t/enum/data-neg.pbf
new file mode 100644
index 0000000..1c2f041
--- /dev/null
+++ b/test/t/enum/data-neg.pbf
@@ -0,0 +1 @@
+���������
\ No newline at end of file
diff --git a/test/t/enum/test_cases.cpp b/test/t/enum/test_cases.cpp
index 3e92d70..126042b 100644
--- a/test/t/enum/test_cases.cpp
+++ b/test/t/enum/test_cases.cpp
@@ -23,6 +23,36 @@ TEST_CASE("read enum field") {
         REQUIRE(!item.next());
     }
 
+    SECTION("negative") {
+        const std::string buffer = load_data("enum/data-neg");
+
+        protozero::pbf_reader item(buffer);
+
+        REQUIRE(item.next());
+        REQUIRE(item.get_enum() == -1L);
+        REQUIRE(!item.next());
+    }
+
+    SECTION("max") {
+        const std::string buffer = load_data("enum/data-max");
+
+        protozero::pbf_reader item(buffer);
+
+        REQUIRE(item.next());
+        REQUIRE(item.get_enum() == std::numeric_limits<int32_t>::max());
+        REQUIRE(!item.next());
+    }
+
+    SECTION("min") {
+        const std::string buffer = load_data("enum/data-min");
+
+        protozero::pbf_reader item(buffer);
+
+        REQUIRE(item.next());
+        REQUIRE(item.get_enum() == (std::numeric_limits<int32_t>::min() + 1));
+        REQUIRE(!item.next());
+    }
+
 }
 
 TEST_CASE("write enum field") {
@@ -40,5 +70,20 @@ TEST_CASE("write enum field") {
         REQUIRE(buffer == load_data("enum/data-blue"));
     }
 
+    SECTION("negative") {
+        pw.add_enum(1, -1L);
+        REQUIRE(buffer == load_data("enum/data-neg"));
+    }
+
+    SECTION("max") {
+        pw.add_enum(1, std::numeric_limits<int32_t>::max());
+        REQUIRE(buffer == load_data("enum/data-max"));
+    }
+
+    SECTION("min") {
+        pw.add_enum(1, std::numeric_limits<int32_t>::min() + 1);
+        REQUIRE(buffer == load_data("enum/data-min"));
+    }
+
 }
 
diff --git a/test/t/enum/testcase.cpp b/test/t/enum/testcase.cpp
index 79c95bd..0854ff5 100644
--- a/test/t/enum/testcase.cpp
+++ b/test/t/enum/testcase.cpp
@@ -10,5 +10,14 @@ int main(int c, char *argv[]) {
 
     msg.set_color(TestEnum::BLUE);
     write_to_file(msg, "data-blue.pbf");
+
+    msg.set_color(TestEnum::NEG);
+    write_to_file(msg, "data-neg.pbf");
+
+    msg.set_color(TestEnum::MAX);
+    write_to_file(msg, "data-max.pbf");
+
+    msg.set_color(TestEnum::MIN);
+    write_to_file(msg, "data-min.pbf");
 }
 
diff --git a/test/t/enum/testcase.proto b/test/t/enum/testcase.proto
index 0113b0d..12eef42 100644
--- a/test/t/enum/testcase.proto
+++ b/test/t/enum/testcase.proto
@@ -8,6 +8,13 @@ enum Color {
     RED   = 1;
     GREEN = 2;
     BLUE  = 3;
+    MAX   = 2147483647;
+    NEG   = -1;
+
+    // Older versions (before 2.6.0) of the google protobuf compiler have a
+    // bug and don't allow the real minimum of -2147483648, so we are testing
+    // with this.
+    MIN   = -2147483647;
 }
 
 message Test {
diff --git a/test/t/enum/writer_test_cases.cpp b/test/t/enum/writer_test_cases.cpp
index 22803fb..450725a 100644
--- a/test/t/enum/writer_test_cases.cpp
+++ b/test/t/enum/writer_test_cases.cpp
@@ -26,5 +26,29 @@ TEST_CASE("write enum field and check with libprotobuf") {
         REQUIRE(msg.color() == TestEnum::Color::BLUE);
     }
 
+    SECTION("negative") {
+        pw.add_enum(1, -1L);
+
+        msg.ParseFromString(buffer);
+
+        REQUIRE(msg.color() == TestEnum::Color::NEG);
+    }
+
+    SECTION("max") {
+        pw.add_enum(1, std::numeric_limits<int32_t>::max());
+
+        msg.ParseFromString(buffer);
+
+        REQUIRE(msg.color() == TestEnum::Color::MAX);
+    }
+
+    SECTION("min") {
+        pw.add_enum(1, std::numeric_limits<int32_t>::min() + 1);
+
+        msg.ParseFromString(buffer);
+
+        REQUIRE(msg.color() == TestEnum::Color::MIN);
+    }
+
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/protozero.git



More information about the Pkg-grass-devel mailing list