diff --git a/scripts/check-padding b/scripts/check-padding new file mode 100755 index 000000000..b10d34b73 --- /dev/null +++ b/scripts/check-padding @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +set -eu +set -o pipefail + +cpp="/tmp/alignment.cpp" +app="/tmp/alignment" + +function usage() { + echo "Usage:" + echo "" + echo "./scripts/rebuild.sh [header] [class name]" + echo "" + echo "Please pass a header file and a class name" + echo "" + echo " ./scripts/check-padding include/mapnik/attribute.hpp mapnik::attribute" + echo "" + exit 1 + +} + +function add() { + echo $1 >> ${cpp} +} + +CXX=${CXX:-clang++} + +function compile() { + ${CXX} -o ${app} ${cpp} -Wpadded -I./ -isystem ./mason_packages/.link/include `mapnik-config --all-flags` -Ideps -Lsrc -Ideps/agg/include -Iinclude +} + +if [[ ${1:-unset} == "unset" ]] || [[ ${2:-unset} == "unset" ]] || [[ $@ == '-h' ]] || [[ $@ == '--help' ]]; then + usage +fi + +echo '' > ${cpp} + +add "#include " +add "#include " + +add "#include \"$1\"" + +add "" + +add '#define REPORT(type) std::clog << "sizeof(" #type ") " << sizeof(type) << "\n";' + +add "int main() {" +add "" + +add "REPORT(std::string)" +add "REPORT(unsigned int)" +add "REPORT(int)" +add "REPORT(bool)" +add "REPORT(std::vector)" +add "REPORT(std::size_t)" + +add "REPORT($2)" + +add "return 0;" +add "}" + +compile +${app} diff --git a/tests/data/json/escaped.geojson b/tests/data/json/escaped.geojson index 0836c2838..6f1531846 100644 --- a/tests/data/json/escaped.geojson +++ b/tests/data/json/escaped.geojson @@ -3,7 +3,6 @@ "features": [ { - "type":"Feature", "geometry": { "type":"Point", @@ -24,7 +23,8 @@ "NOM_FR":"Qu\u00e9bec", "object": {"value":{"type":"\u041c\u0430pni\u043a","array": [3,0,"x"]}}, "array" : [ [ [1], ["deux"]],[["\u0442\u0440\u0438","four","\u4e94"]]] - } + }, + "type":"Feature" } ] } diff --git a/tests/visual_tests/compare.py b/tests/visual_tests/compare.py index 65720af1a..30ccfc260 100644 --- a/tests/visual_tests/compare.py +++ b/tests/visual_tests/compare.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import mapnik +import os from unittest import TestCase try: @@ -8,28 +9,6 @@ try: except ImportError: import simplejson as json - -# returns true if pixels are not nearly identical -def compare_pixels(pixel1, pixel2, alpha=True, pixel_threshold=0): - if pixel1 == pixel2: - return False - r_diff = abs((pixel1 & 0xff) - (pixel2 & 0xff)) - g_diff = abs(((pixel1 >> 8) & 0xff) - ((pixel2 >> 8) & 0xff)) - b_diff = abs(((pixel1 >> 16) & 0xff)- ((pixel2 >> 16) & 0xff)) - if alpha: - a_diff = abs(((pixel1 >> 24) & 0xff) - ((pixel2 >> 24) & 0xff)) - if(r_diff > pixel_threshold or - g_diff > pixel_threshold or - b_diff > pixel_threshold or - a_diff > pixel_threshold): - return True - else: - if(r_diff > pixel_threshold or - g_diff > pixel_threshold or - b_diff > pixel_threshold): - return True - return False - # compare two images and return number of different pixels def compare(actual, expected, alpha=True): im1 = mapnik.Image.open(actual) diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index b8d69fa14..75549c0f7 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -7,6 +7,7 @@ import mapnik #mapnik.logger.set_severity(mapnik.severity_type.Debug) import shutil import os.path +import os from compare import compare, compare_grids import platform import glob @@ -27,9 +28,14 @@ defaults = { 'grid': mapnik.has_grid_renderer() } -cairo_threshold = 0 -agg_threshold = 0 -grid_threshold = 0 +if os.name == 'nt': + cairo_threshold = 10 + agg_threshold = 0 + grid_threshold = 0 +else: + cairo_threshold = 0 + agg_threshold = 0 + grid_threshold = 0 def render_cairo(m, output, scale_factor): mapnik.render_to_file(m, output, 'ARGB32', scale_factor)